org.openvpms.esci.service.client
Class DefaultServiceAuthenticators

java.lang.Object
  extended by java.net.Authenticator
      extended by org.openvpms.esci.service.client.DefaultServiceAuthenticators
All Implemented Interfaces:
ServiceAuthenticator, ServiceAuthenticators

public class DefaultServiceAuthenticators
extends Authenticator
implements ServiceAuthenticators

Default implementation of the ServiceAuthenticators interface.

This registers a singleton instance with Authenticator.setDefault(java.net.Authenticator).

Version:
$LastChangedDate: 2006-05-02 05:16:31Z $
Author:
OpenVPMS Team

Nested Class Summary
 
Nested classes/interfaces inherited from class java.net.Authenticator
Authenticator.RequestorType
 
Method Summary
 void addAuthenticator(String url, ServiceAuthenticator authenticator)
          Registers an authenticator for a url.
static DefaultServiceAuthenticators getInstance()
          Returns the singleton instance.
protected  PasswordAuthentication getPasswordAuthentication()
          Called when password authorization is needed.
 PasswordAuthentication getPasswordAuthentication(String host, InetAddress site, int port, String protocol, String prompt, String scheme, URL url, Authenticator.RequestorType requestorType)
           
 
Methods inherited from class java.net.Authenticator
getRequestingHost, getRequestingPort, getRequestingPrompt, getRequestingProtocol, getRequestingScheme, getRequestingSite, getRequestingURL, getRequestorType, requestPasswordAuthentication, requestPasswordAuthentication, requestPasswordAuthentication, setDefault
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DefaultServiceAuthenticators getInstance()
Returns the singleton instance.

Returns:
the singleton instance

addAuthenticator

public void addAuthenticator(String url,
                             ServiceAuthenticator authenticator)
Registers an authenticator for a url.

Any existing authenticator will be replaced.

The authenticator will be registered using a weak reference.

Specified by:
addAuthenticator in interface ServiceAuthenticators
Parameters:
url - the url to supply credentials for
authenticator - the authenticator

getPasswordAuthentication

protected PasswordAuthentication getPasswordAuthentication()
Called when password authorization is needed. Subclasses should override the default implementation, which returns null.

Overrides:
getPasswordAuthentication in class Authenticator
Returns:
The PasswordAuthentication collected from the user, or null if none is provided.

getPasswordAuthentication

public PasswordAuthentication getPasswordAuthentication(String host,
                                                        InetAddress site,
                                                        int port,
                                                        String protocol,
                                                        String prompt,
                                                        String scheme,
                                                        URL url,
                                                        Authenticator.RequestorType requestorType)
Specified by:
getPasswordAuthentication in interface ServiceAuthenticator
Parameters:
host - the host name of the site or proxy requesting authentication, or null if not available
site - the InetAddress of the site requesting authorization, or null if it's not available
port - the port number for the requested connection
protocol - 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.
prompt - the prompt string given by the requestor (realm for http requests)
scheme - the scheme of the requestor (the HTTP scheme for an HTTP firewall, for example).
url - the URL that resulted in this request for authentication.
requestorType - authentication type of the requestor
Returns:
the PasswordAuthentication for the url, or null if none is available


Copyright © 2010-2011 OpenVPMS. All Rights Reserved..