Authentication method in java

Authentication method in java

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.

Nested Class Summary

Constructor Summary

Method Summary

Sets the authenticator that will be used by the networking code when a proxy or an HTTP server asks for authentication.

Methods declared in class java.lang.Object

Constructor Detail

Authenticator

Method Detail

setDefault

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.

Читайте также:  Html провести горизонтальную черту

getDefault

Gets the default authenticator. 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. Then the default authenticator, if set, is returned. Otherwise, null is returned.

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.

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.

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.

requestPasswordAuthentication

public static PasswordAuthentication requestPasswordAuthentication​(Authenticator authenticator, String host, InetAddress addr, int port, String protocol, String prompt, String scheme, URL url, Authenticator.RequestorType reqType)

Ask the given authenticator for a password. If the given authenticator is null, the authenticator, if any, that has been registered with the system using setDefault is used. 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.

Читайте также:  Питон for с шагом

requestPasswordAuthenticationInstance

public PasswordAuthentication requestPasswordAuthenticationInstance​(String host, InetAddress addr, int port, String protocol, String prompt, String scheme, URL url, Authenticator.RequestorType reqType)

getRequestingHost

getRequestingSite

getRequestingPort

protected final int getRequestingPort()

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.

getRequestingPrompt

getRequestingScheme

getPasswordAuthentication

protected PasswordAuthentication getPasswordAuthentication()

Called when password authorization is needed. Subclasses should override the default implementation, which returns null.

getRequestingURL

getRequestorType

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

Источник

Authentication method in java

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.

Nested Class Summary

Constructor Summary

Method Summary

Sets the authenticator that will be used by the networking code when a proxy or an HTTP server asks for authentication.

Methods inherited from class java.lang.Object

Constructor Detail

Authenticator

Method Detail

setDefault

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.

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.

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.

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.

getRequestingHost

getRequestingSite

getRequestingPort

protected final int getRequestingPort()

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.

getRequestingPrompt

getRequestingScheme

getPasswordAuthentication

protected PasswordAuthentication getPasswordAuthentication()

Called when password authorization is needed. Subclasses should override the default implementation, which returns null.

getRequestingURL

getRequestorType

Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2023, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.

Источник

Оцените статью