- java.lang.Object
-
- javax.mail.Authenticator
-
public abstract class Authenticator extends Object
The class Authenticator represents an object that knows how to obtain authentication for a network connection. Usually, it will do this by prompting the user for information.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.
- Author:
- Bill Foote, Bill Shannon
- See Also:
Authenticator
,Session.getInstance(java.util.Properties, javax.mail.Authenticator)
,Session.getDefaultInstance(java.util.Properties, javax.mail.Authenticator)
,Session.requestPasswordAuthentication(java.net.InetAddress, int, java.lang.String, java.lang.String, java.lang.String)
,PasswordAuthentication
-
-
Constructor Summary
Constructors Constructor and Description Authenticator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description protected String
getDefaultUserName()
protected PasswordAuthentication
getPasswordAuthentication()
Called when password authentication is needed.protected int
getRequestingPort()
protected String
getRequestingPrompt()
protected String
getRequestingProtocol()
Give the protocol that's requesting the connection.protected InetAddress
getRequestingSite()
-
-
-
Method Detail
-
getRequestingSite
protected final InetAddress getRequestingSite()
- Returns:
- the InetAddress of the site requesting authorization, or null if it's not available.
-
getRequestingPort
protected final int getRequestingPort()
- Returns:
- the port for the requested connection
-
getRequestingProtocol
protected final String getRequestingProtocol()
Give the protocol that's requesting the connection. Often this will be based on a URLName.- Returns:
- the protcol
- See Also:
URLName.getProtocol()
-
getRequestingPrompt
protected final String getRequestingPrompt()
- Returns:
- the prompt string given by the requestor
-
getDefaultUserName
protected final String getDefaultUserName()
- Returns:
- the default user name given by the requestor
-
getPasswordAuthentication
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.
- Returns:
- The PasswordAuthentication collected from the user, or null if none is provided.
-
-
Traduction non disponible
Les API Java ne sont pas encore traduites en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Version en cache
21/08/2025 20:13:22 Cette version de la page est en cache (à la date du 21/08/2025 20:13:22) afin d'accélérer le traitement.Vous pouvez activer le mode utilisateur dans le menu en haut pour afficher la version plus récente de la page.
Document créé le 14/04/2008, dernière modification le 18/08/2025
Source du document imprimé : https://www.gaudry.be/java-api-javaee-rf-javax/mail/authenticator.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.