Geen cache-versie.

Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code LNG204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.
java.net

Class 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 overriding getPasswordAuthentication() in a sub-class. This method will typically use the various getXXX() accessor methods to get information about the entity requesting authentication. It must then acquire a username and password either by interacting with the user or through some other non-interactive means. The credentials are then returned as a PasswordAuthentication return value.

    An instance of this concrete sub-class is then registered with the system by calling setDefault(Authenticator). When authentication is required, the system will invoke one of the requestPasswordAuthentication() methods which in turn will call the getPasswordAuthentication() method of the registered object.

    All methods that request authentication have a default implementation that fails.

    Since:
    1.2
    See Also:
    setDefault(java.net.Authenticator), getPasswordAuthentication()
    • Constructor Detail

      • Authenticator

        public Authenticator()
    • Method Detail

      • setDefault

        public static void setDefault(Authenticator a)
        Sets the authenticator that will be used by the networking code when a proxy or an HTTP server asks for authentication.

        First, if there is a security manager, its checkPermission method is called with a NetPermission("setDefaultAuthenticator") permission. This may result in a java.lang.SecurityException.

        Parameters:
        a - The authenticator to be set. If a is null then any previously set authenticator is removed.
        Throws:
        SecurityException - if a security manager exists and its checkPermission method doesn't allow setting the default authenticator.
        See Also:
        SecurityManager.checkPermission(java.security.Permission), NetPermission
      • requestPasswordAuthentication

        public static PasswordAuthentication requestPasswordAuthentication(InetAddress addr,
                                                           int port,
                                                           String protocol,
                                                           String prompt,
                                                           String scheme)
        Ask the authenticator that has been registered with the system for a password.

        First, if there is a security manager, its checkPermission method is called with a NetPermission("requestPasswordAuthentication") permission. This may result in a java.lang.SecurityException.

        Parameters:
        addr - The InetAddress of the site requesting authorization, or null if not known.
        port - the port for the requested connection
        protocol - The protocol that's requesting the connection (getRequestingProtocol())
        prompt - A prompt string for the user
        scheme - The authentication scheme
        Returns:
        The username/password, or null if one can't be gotten.
        Throws:
        SecurityException - if a security manager exists and its checkPermission method doesn't allow the password authentication request.
        See Also:
        SecurityManager.checkPermission(java.security.Permission), NetPermission
      • requestPasswordAuthentication

        public static PasswordAuthentication requestPasswordAuthentication(String host,
                                                           InetAddress addr,
                                                           int port,
                                                           String protocol,
                                                           String prompt,
                                                           String scheme)
        Ask the authenticator that has been registered with the system for a password. This is the preferred method for requesting a password because the hostname can be provided in cases where the InetAddress is not available.

        First, if there is a security manager, its checkPermission method is called with a NetPermission("requestPasswordAuthentication") permission. This may result in a java.lang.SecurityException.

        Parameters:
        host - The hostname of the site requesting authentication.
        addr - The InetAddress of the site requesting authentication, or null if not known.
        port - the port for the requested connection.
        protocol - The protocol that's requesting the connection (getRequestingProtocol())
        prompt - A prompt string for the user which identifies the authentication realm.
        scheme - The authentication scheme
        Returns:
        The username/password, or null if one can't be gotten.
        Throws:
        SecurityException - if a security manager exists and its checkPermission method doesn't allow the password authentication request.
        Since:
        1.4
        See Also:
        SecurityManager.checkPermission(java.security.Permission), NetPermission
      • requestPasswordAuthentication

        public static PasswordAuthentication requestPasswordAuthentication(String host,
                                                           InetAddress addr,
                                                           int port,
                                                           String protocol,
                                                           String prompt,
                                                           String scheme,
                                                           URL url,
                                                           Authenticator.RequestorType reqType)
        Ask the authenticator that has been registered with the system for a password.

        First, if there is a security manager, its checkPermission method is called with a NetPermission("requestPasswordAuthentication") permission. This may result in a java.lang.SecurityException.

        Parameters:
        host - The hostname of the site requesting authentication.
        addr - The InetAddress of the site requesting authorization, or null if not known.
        port - the port for the requested connection
        protocol - The protocol that's requesting the connection (getRequestingProtocol())
        prompt - A prompt string for the user
        scheme - The authentication scheme
        url - The requesting URL that caused the authentication
        reqType - The type (server or proxy) of the entity requesting authentication.
        Returns:
        The username/password, or null if one can't be gotten.
        Throws:
        SecurityException - if a security manager exists and its checkPermission method doesn't allow the password authentication request.
        Since:
        1.5
        See Also:
        SecurityManager.checkPermission(java.security.Permission), NetPermission
      • getRequestingHost

        protected final String getRequestingHost()
        Gets the hostname of the site or proxy requesting authentication, or null if not available.
        Returns:
        the hostname of the connection requiring authentication, or null if it's not available.
        Since:
        1.4
      • getRequestingSite

        protected final InetAddress getRequestingSite()
        Gets the InetAddress of the site requesting authorization, or null if not available.
        Returns:
        the InetAddress of the site requesting authorization, or null if it's not available.
      • getRequestingPort

        protected final int getRequestingPort()
        Gets the port number for the requested connection.
        Returns:
        an int indicating 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 URL, but in a future JDK it could be, for example, "SOCKS" for a password-protected SOCKS5 firewall.
        Returns:
        the protcol, optionally followed by "/version", where version is a version number.
        See Also:
        URL.getProtocol()
      • getRequestingPrompt

        protected final String getRequestingPrompt()
        Gets the prompt string given by the requestor.
        Returns:
        the prompt string given by the requestor (realm for http requests)
      • getRequestingScheme

        protected final String getRequestingScheme()
        Gets the scheme of the requestor (the HTTP scheme for an HTTP firewall, for example).
        Returns:
        the scheme of the requestor
      • getPasswordAuthentication

        protected PasswordAuthentication getPasswordAuthentication()
        Called when password authorization is needed. Subclasses should override the default implementation, which returns null.
        Returns:
        The PasswordAuthentication collected from the user, or null if none is provided.
      • getRequestingURL

        protected URL getRequestingURL()
        Returns the URL that resulted in this request for authentication.
        Returns:
        the requesting URL
        Since:
        1.5
      • getRequestorType

        protected Authenticator.RequestorType getRequestorType()
        Returns whether the requestor is a Proxy or a Server.
        Returns:
        the authentication type of the requestor
        Since:
        1.5

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-java/net/authenticator.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut