View Javadoc
1   /*******************************************************************************
2    * Copyright (c) 2010, 2012 Sonatype, Inc.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the Eclipse Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/epl-v10.html
7    *
8    * Contributors:
9    *    Sonatype, Inc. - initial API and implementation
10   *******************************************************************************/
11  package org.eclipse.aether.repository;
12  
13  import java.util.Map;
14  
15  /**
16   * The authentication to use for accessing a protected resource. This acts basically as an extensible callback mechanism
17   * from which network operations can request authentication data like username and password when needed.
18   */
19  public interface Authentication
20  {
21  
22      /**
23       * Fills the given authentication context with the data from this authentication callback. To do so, implementors
24       * have to call {@link AuthenticationContext#put(String, Object)}. <br>
25       * <br>
26       * The {@code key} parameter supplied to this method acts merely as a hint for interactive callbacks that want to
27       * prompt the user for only that authentication data which is required. Implementations are free to ignore this
28       * parameter and put all the data they have into the authentication context at once.
29       * 
30       * @param context The authentication context to populate, must not be {@code null}.
31       * @param key The key denoting a specific piece of authentication data that is being requested for a network
32       *            operation, may be {@code null}.
33       * @param data Any (read-only) extra data in form of key value pairs that might be useful when getting the
34       *            authentication data, may be {@code null}.
35       */
36      void fill( AuthenticationContext context, String key, Map<String, String> data );
37  
38      /**
39       * Updates the given digest with data from this authentication callback. To do so, implementors have to call the
40       * {@code update()} methods in {@link AuthenticationDigest}.
41       * 
42       * @param digest The digest to update, must not be {@code null}.
43       */
44      void digest( AuthenticationDigest digest );
45  
46  }