Java Doc for Authenticator.java in  » 6.0-JDK-Core » net » java » net » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » net » java.net 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   java.net.Authenticator

Authenticator
abstract public class Authenticator (Code)
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 Authenticator.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 Authenticator.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.
See Also:   java.net.Authenticator.setDefault(java.net.Authenticator)
See Also:   java.net.Authenticator.getPasswordAuthentication
author:
   Bill Foote
version:
   1.39, 05/05/07
since:
   1.2


Inner Class :public enum RequestorType



Method Summary
protected  PasswordAuthenticationgetPasswordAuthentication()
     Called when password authorization is needed.
final protected  StringgetRequestingHost()
     Gets the hostname of the site or proxy requesting authentication, or null if not available.
final protected  intgetRequestingPort()
     Gets the port number for the requested connection.
final protected  StringgetRequestingPrompt()
     Gets the prompt string given by the requestor.
final protected  StringgetRequestingProtocol()
     Give the protocol that's requesting the connection.
final protected  StringgetRequestingScheme()
     Gets the scheme of the requestor (the HTTP scheme for an HTTP firewall, for example).
final protected  InetAddressgetRequestingSite()
     Gets the InetAddress of the site requesting authorization, or null if not available.
protected  URLgetRequestingURL()
     Returns the URL that resulted in this request for authentication.
protected  RequestorTypegetRequestorType()
     Returns whether the requestor is a Proxy or a Server.
public static  PasswordAuthenticationrequestPasswordAuthentication(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.

public static  PasswordAuthenticationrequestPasswordAuthentication(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.
public static  PasswordAuthenticationrequestPasswordAuthentication(String host, InetAddress addr, int port, String protocol, String prompt, String scheme, URL url, 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.

public static synchronized  voidsetDefault(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.




Method Detail
getPasswordAuthentication
protected PasswordAuthentication getPasswordAuthentication()(Code)
Called when password authorization is needed. Subclasses should override the default implementation, which returns null. The PasswordAuthentication collected from theuser, or null if none is provided.



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



getRequestingPort
final protected int getRequestingPort()(Code)
Gets the port number for the requested connection. an int indicating the port for the requested connection.



getRequestingPrompt
final protected String getRequestingPrompt()(Code)
Gets the prompt string given by the requestor. the prompt string given by the requestor (realm forhttp requests)



getRequestingProtocol
final protected String getRequestingProtocol()(Code)
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. the protcol, optionally followed by "/version", whereversion is a version number.
See Also:   java.net.URL.getProtocol



getRequestingScheme
final protected String getRequestingScheme()(Code)
Gets the scheme of the requestor (the HTTP scheme for an HTTP firewall, for example). the scheme of the requestor



getRequestingSite
final protected InetAddress getRequestingSite()(Code)
Gets the InetAddress of the site requesting authorization, or null if not available. the InetAddress of the site requesting authorization, or nullif it's not available.



getRequestingURL
protected URL getRequestingURL()(Code)
Returns the URL that resulted in this request for authentication.
since:
   1.5 the requesting URL



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



requestPasswordAuthentication
public static PasswordAuthentication requestPasswordAuthentication(InetAddress addr, int port, String protocol, String prompt, String scheme)(Code)
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.
Parameters:
  port - the port for the requested connection
Parameters:
  protocol - The protocol that's requesting the connection(java.net.Authenticator.getRequestingProtocol)
Parameters:
  prompt - A prompt string for the user
Parameters:
  scheme - The authentication scheme 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
See Also:   java.net.NetPermission




requestPasswordAuthentication
public static PasswordAuthentication requestPasswordAuthentication(String host, InetAddress addr, int port, String protocol, String prompt, String scheme)(Code)
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.
Parameters:
  addr - The InetAddress of the site requesting authentication,or null if not known.
Parameters:
  port - the port for the requested connection.
Parameters:
  protocol - The protocol that's requesting the connection(java.net.Authenticator.getRequestingProtocol)
Parameters:
  prompt - A prompt string for the user which identifies the authentication realm.
Parameters:
  scheme - The authentication scheme 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
See Also:   java.net.NetPermission
since:
   1.4




requestPasswordAuthentication
public static PasswordAuthentication requestPasswordAuthentication(String host, InetAddress addr, int port, String protocol, String prompt, String scheme, URL url, RequestorType reqType)(Code)
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.
Parameters:
  addr - The InetAddress of the site requesting authorization,or null if not known.
Parameters:
  port - the port for the requested connection
Parameters:
  protocol - The protocol that's requesting the connection(java.net.Authenticator.getRequestingProtocol)
Parameters:
  prompt - A prompt string for the user
Parameters:
  scheme - The authentication scheme
Parameters:
  url - The requesting URL that caused the authentication
Parameters:
  reqType - The type (server or proxy) of the entity requestingauthentication. 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
See Also:   java.net.NetPermission
since:
   1.5




setDefault
public static synchronized void setDefault(Authenticator a)(Code)
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 thenany 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
See Also:   java.net.NetPermission




Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.