public class SimpleAuthenticatorModule extends Object implements AuthenticatorModule
Modifier and Type | Field and Description |
---|---|
String |
host
The hostname or address of the host for which credentials
are to be returned.
|
char[] |
password
The password of the authenticated user.
|
int |
port
The port of the service for which credentials are to be returned.
|
String |
prompt
The prompt (AKA realm) used by the service for which credentials
are to be returned.
|
String |
scheme
The authentication scheme (BASIC, DIGEST, etc) used by the service
for which credentials are to be returned.
|
String |
username
The username of the authenticated user.
|
Constructor and Description |
---|
SimpleAuthenticatorModule(String info)
Constructs an authenticator module initialized using specified info.
|
SimpleAuthenticatorModule(String host,
int port,
String prompt,
String scheme,
String username,
char[] password)
Constructs an authenticator module initialized using specified fields.
|
Modifier and Type | Method and Description |
---|---|
void |
clearCredentials()
If usernames/passwords are cached, invoking this method definitely
clears such cached information.
|
static String |
encodeCredentials(String host,
int portNumber,
String prompt,
String scheme,
String username,
char[] password)
Returns a string for use by the -auth command-line option.
|
ModularAuthenticator |
getModularAuthenticator()
Returns the modular authenticator to which this module belongs.
|
PasswordAuthentication |
getPasswordAuthentication()
Returns the PasswordAuthentication found for the context which can be
queried using the
ModularAuthenticator interface. |
static void |
main(String[] args)
Command-line utility which may be used to encode
authentication credentials in the format expected by
SimpleAuthenticatorModule(String) . |
void |
setModularAuthenticator(ModularAuthenticator authenticator)
Invoked by the modular authenticator to specify to its module to which
``parent'' it belongs.
|
String |
toString() |
public final String host
null
matches any host.public final int port
public final String prompt
null
matches any prompt.public final String scheme
null
matches any scheme.public final String username
public final char[] password
public SimpleAuthenticatorModule(String info) throws IllegalArgumentException
info
- consists in fields host, port, prompt, scheme, username
and password joined using the newline char ('\n'
),
then converted to UTF-8 bytes, then encoded in base 64.
All fields except username and password can be left empty.IllegalArgumentException
- if specified info cannot be
successfully decoded and then parsed.SimpleAuthenticatorModule(String, int, String, String,
String, char[])
,
encodeCredentials(java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, char[])
public SimpleAuthenticatorModule(String host, int port, String prompt, String scheme, String username, char[] password)
host
- The hostname or address of the host for which credentials
are to be returned. null
matches any host.port
- The port of the service for which credentials are
to be returned. A negative or null number matches any port.prompt
- The prompt (AKA realm) used by the service for which
credentials are to be returned. null
matches any prompt.scheme
- The authentication scheme (BASIC, DIGEST, etc)
used by the service for which credentials are to be returned.
null
matches any scheme.username
- The username of the authenticated user.password
- The password of the authenticated user.SimpleAuthenticatorModule(String)
public void setModularAuthenticator(ModularAuthenticator authenticator)
AuthenticatorModule
setModularAuthenticator
in interface AuthenticatorModule
public ModularAuthenticator getModularAuthenticator()
AuthenticatorModule
getModularAuthenticator
in interface AuthenticatorModule
public void clearCredentials()
AuthenticatorModule
clearCredentials
in interface AuthenticatorModule
public PasswordAuthentication getPasswordAuthentication()
AuthenticatorModule
ModularAuthenticator
interface. Returns
null
if, given this context, this module cannot determine
the PasswordAuthentication object.getPasswordAuthentication
in interface AuthenticatorModule
public static String encodeCredentials(String host, int portNumber, String prompt, String scheme, String username, char[] password)
host
- The hostname or address of the host for which credentials
are to be returned. null
matches any host.portNumber
- The port of the service for which credentials are
to be returned. A negative or null number matches any port.prompt
- The prompt (AKA realm) used by the service for which
credentials are to be returned. null
matches any prompt.scheme
- The authentication scheme (BASIC, DIGEST, etc)
used by the service for which credentials are to be returned.
null
matches any scheme.username
- The username of the authenticated user.password
- The password of the authenticated user.SimpleAuthenticatorModule(String)
.public static void main(String[] args) throws Exception
SimpleAuthenticatorModule(String)
.