public final class AuthenticationContext extends Object implements Closeable
Authentication callbacks which exist for a
 potentially long time like the duration of a repository system session, an authentication context has a supposedly
 short lifetime and should be closed as soon as the corresponding network operation has finished:
 
 
 AuthenticationContext context = AuthenticationContext.forRepository( session, repository );
 try {
     // get credentials
     char[] password = context.get( AuthenticationContext.PASSWORD, char[].class );
     // perform network operation using retrieved credentials
     ...
 } finally {
     // erase confidential authentication data from heap memory
     AuthenticationContext.close( context );
 }
 
 
 The same authentication data can often be presented using different data types, e.g. a password can be presented
 using a character array or (less securely) using a string. For ease of use, an authentication context treats the
 following groups of data types as equivalent and converts values automatically during retrieval:
 String, char[]String, File| Modifier and Type | Field and Description | 
|---|---|
| static String | HOST_KEY_ACCEPTANCEThe key used to store the acceptance policy for unknown host keys. | 
| static String | HOST_KEY_LOCALThe key used to store the fingerprint of the public key expected from remote host as recorded in a known hosts
 database. | 
| static String | HOST_KEY_REMOTEThe key used to store the fingerprint of the public key advertised by remote host. | 
| static String | NTLM_DOMAINThe key used to store the NTLM domain. | 
| static String | NTLM_WORKSTATIONThe key used to store the NTML workstation. | 
| static String | PASSWORDThe key used to store the password. | 
| static String | PRIVATE_KEY_PASSPHRASEThe key used to store the passphrase protecting the private key. | 
| static String | PRIVATE_KEY_PATHThe key used to store the pathname to a private key file. | 
| static String | SSL_CONTEXTThe key used to store the SSL context. | 
| static String | SSL_HOSTNAME_VERIFIERThe key used to store the SSL hostname verifier. | 
| static String | USERNAMEThe key used to store the username. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | close()Closes this authentication context and erases sensitive authentication data from heap memory. | 
| static void | close(AuthenticationContext context)Closes the specified authentication context. | 
| static AuthenticationContext | forProxy(RepositorySystemSession session,
                RemoteRepository repository)Gets an authentication context for the proxy of the specified repository. | 
| static AuthenticationContext | forRepository(RepositorySystemSession session,
                          RemoteRepository repository)Gets an authentication context for the specified repository. | 
| String | get(String key)Gets the authentication data for the specified key. | 
| <T> T | get(String key,
      Class<T> type)Gets the authentication data for the specified key. | 
| <T> T | get(String key,
      Map<String,String> data,
      Class<T> type)Gets the authentication data for the specified key. | 
| Proxy | getProxy()Gets the proxy (if any) to be authenticated with. | 
| RemoteRepository | getRepository()Gets the repository requiring authentication. | 
| RepositorySystemSession | getSession()Gets the repository system session during which the authentication happens. | 
| void | put(String key,
      Object value)Puts the specified authentication data into this context. | 
public static final String USERNAME
String.public static final String PASSWORD
char[] or
 String.public static final String NTLM_DOMAIN
String.public static final String NTLM_WORKSTATION
String.public static final String PRIVATE_KEY_PATH
String or File.public static final String PRIVATE_KEY_PASSPHRASE
char[] or String.public static final String HOST_KEY_ACCEPTANCE
Boolean. When querying this authentication data, the extra data should provide
 HOST_KEY_REMOTE and HOST_KEY_LOCAL, e.g. to enable a well-founded decision of the user during
 an interactive prompt.public static final String HOST_KEY_REMOTE
get(String, Map, Class) when getting HOST_KEY_ACCEPTANCE, not
 the authentication data in a context.public static final String HOST_KEY_LOCAL
get(String, Map, Class) when
 getting HOST_KEY_ACCEPTANCE, not the authentication data in a context.public static final String SSL_CONTEXT
SSLContext.public static final String SSL_HOSTNAME_VERIFIER
HostnameVerifier.public static AuthenticationContext forRepository(RepositorySystemSession session, RemoteRepository repository)
session - The repository system session during which the repository is accessed, must not be null.repository - The repository for which to create an authentication context, must not be null.null if no authentication is configured for it.public static AuthenticationContext forProxy(RepositorySystemSession session, RemoteRepository repository)
session - The repository system session during which the repository is accessed, must not be null.repository - The repository for whose proxy to create an authentication context, must not be null.null if no proxy is set or no authentication is
         configured for it.public RepositorySystemSession getSession()
null.public RemoteRepository getRepository()
getProxy() is not null, the data gathered by
 this authentication context does not apply to the repository's host but rather the proxy.null.public Proxy getProxy()
null if authenticating directly with the repository's host.public String get(String key)
key - The key whose authentication data should be retrieved, must not be null.null if none.public <T> T get(String key, Class<T> type)
T - The data type of the authentication data.key - The key whose authentication data should be retrieved, must not be null.type - The expected type of the authentication data, must not be null.null if none or if the data doesn't match the expected type.public <T> T get(String key, Map<String,String> data, Class<T> type)
T - The data type of the authentication data.key - The key whose authentication data should be retrieved, must not be null.data - Any (read-only) extra data in form of key value pairs that might be useful when getting the
            authentication data, may be null.type - The expected type of the authentication data, must not be null.null if none or if the data doesn't match the expected type.public void put(String key, Object value)
Authentication.fill(AuthenticationContext, String, Map). Passed in character arrays are not cloned and
 become owned by this context, i.e. get erased when the context gets closed.key - The key to associate the authentication data with, must not be null.value - The (cleartext) authentication data to store, may be null.public void close()
close in interface Closeableclose in interface AutoCloseablepublic static void close(AuthenticationContext context)
null check before
 calling close() on the given context.context - The authentication context to close, may be null.Copyright © 2010–2018 The Apache Software Foundation. All rights reserved.