Applications use this class by creating a subclass, and registering an instance of that subclass with the session when it is created. When authentication is required, the system will invoke a method on the subclass (like getPasswordAuthentication). The subclass's method can query about the authentication being requested with a number of inherited methods (getRequestingXXX()), and form an appropriate message for the user.
All methods that request authentication have a default implementation that fails.
java.net.Authenticator , jakarta.mail.Session#getInstance(java.util.Properties, jakarta.mail.Authenticator) , jakarta.mail.Session#getDefaultInstance(java.util.Properties, jakarta.mail.Authenticator) , jakarta.mail.Session#requestPasswordAuthentication , jakarta.mail.PasswordAuthentication
| Modifier and Type | Field and Description |
|---|---|
| private int | |
| private String | |
| private String | |
| private InetAddress | |
| private String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected final String | |
| protected PasswordAuthentication | Returns: The PasswordAuthentication collected from the user, or null if none is provided.Called when password authentication is needed. |
| protected final int | |
| protected final String | |
| protected final String | |
| protected final InetAddress | Returns: the InetAddress of the site requesting authorization, or null if it's not available.
|
| pack-priv final synchronized PasswordAuthentication | Returns: The username/password, or null if one can't be gotten.The InetAddress of the site requesting authorization,
or null if not known. addr, int the port for the requested connection port, String The protocol that's requesting the connection
protocol, String java.A prompt string for the user prompt, String defaultUserName)Ask the authenticator for a password. |
| requestingPort | back to summary |
|---|---|
| private int requestingPort | |
| requestingPrompt | back to summary |
|---|---|
| private String requestingPrompt | |
| requestingProtocol | back to summary |
|---|---|
| private String requestingProtocol | |
| requestingSite | back to summary |
|---|---|
| private InetAddress requestingSite | |
| requestingUserName | back to summary |
|---|---|
| private String requestingUserName | |
| Authenticator | back to summary |
|---|---|
| public Authenticator() Creates a default
| |
| getDefaultUserName | back to summary |
|---|---|
protected final String getDefaultUserName()
| |
| getPasswordAuthentication | back to summary |
|---|---|
| protected PasswordAuthentication getPasswordAuthentication() Called when password authentication is needed. Subclasses should override the default implementation, which returns null. Note that if this method uses a dialog to prompt the user for this information, the dialog needs to block until the user supplies the information. This method can not simply return after showing the dialog.
| |
| getRequestingPort | back to summary |
|---|---|
protected final int getRequestingPort()
| |
| getRequestingPrompt | back to summary |
|---|---|
protected final String getRequestingPrompt()
| |
| getRequestingProtocol | back to summary |
|---|---|
| protected final String getRequestingProtocol() Give the protocol that's requesting the connection. Often this will be based on a URLName.
| |
| getRequestingSite | back to summary |
|---|---|
protected final InetAddress getRequestingSite()
| |
| requestPasswordAuthentication | back to summary |
|---|---|
| pack-priv final synchronized PasswordAuthentication requestPasswordAuthentication(InetAddress addr, int port, String protocol, String prompt, String defaultUserName) Ask the authenticator for a password.
| |