public class Auth extends Authenticator
This class sets and handles the Authenticator for HTTP and HTTPS connections in Java.
Authenticator.RequestorType
Constructor and Description |
---|
Auth(AuthCB callBack)
Creates the instance of the Authenticator.
|
Modifier and Type | Method and Description |
---|---|
void |
addCA(String text)
Adds a CA certificate as accepted for this session.
|
void |
addCertPW(String fileName,
String password)
Requests for a password for a client certificate file.
|
static byte[] |
decodeBase64(String s)
Decodes a byte array from Base64 format.
|
static String |
encodeBase64(byte[] a)
Encodes a byte array into Base64 format.
|
static String |
encodeBase64(String a)
Encodes a String in ISO-8859-1 character set into Base64 format.
|
static Auth |
getAuth()
Gets the single authenticator instance.
|
String[] |
getAuth(boolean usesSSL,
String serverName,
String scheme,
String realm)
Requests a password.
|
HashMap<String,String> |
getAuthHeaderTable(ArrayList<String> headers,
String proxyHost)
Gets a hashtable with token and value pairs from the authentication or
proxy authentication header field string.
|
String |
getAuthString(String method,
String protocol,
String host,
int port,
String file,
HashMap<String,String> serverAuth,
String proxyHost)
Requests the authentication header field required to
connect to the server in question.
|
String |
getAuthString(String method,
URLConnection uc,
String proxyHost)
Requests the authentication header field required to
connect to the server in question.
|
String |
getAuthString(String method,
URL url,
HashMap<String,String> serverAuth,
String proxyHost)
Requests the authentication header field required to
connect to the server in question.
|
String |
getAuthString(String method,
URL url,
String proxyHost)
Requests the authentication header field required to
based on a previous successful call for this server.
|
String |
getCertPW(String fileName)
Requests for a password for a client certificate file.
|
String[] |
getCurrentAuthString(String serverName,
String realm)
Gets the current authentication, if such exists.
|
static HashMap<String,String> |
getFieldValues(String line)
Gets a HashMap with token and value pairs from a header field string.
|
String |
getParams()
Creates the string that can be used to pass parameters between
a process that has already some definitions of UserID/passwords
or just passwords.
|
protected PasswordAuthentication |
getPasswordAuthentication()
Called when password authorization is needed.
|
void |
initParams(String params)
Initiates the table of previous UserID/password definitions for a
server (+ possible realm) or just a file name (for certificate
files) from another process.
|
boolean |
isAcceptedCA(String text)
Checks if a CA certificate is already accepted for this
session.
|
getRequestingHost, getRequestingPort, getRequestingPrompt, getRequestingProtocol, getRequestingScheme, getRequestingSite, getRequestingURL, getRequestorType, requestPasswordAuthentication, requestPasswordAuthentication, requestPasswordAuthentication, setDefault
public Auth(AuthCB callBack)
callBack
- the callBack interface implementor when
a request for userID/password is requested.public static Auth getAuth()
public static String encodeBase64(String a)
a
- an array containing the data bytes to be encoded.public static String encodeBase64(byte[] a)
a
- an array containing the data bytes to be encoded.public static byte[] decodeBase64(String s)
s
- a Base64 String to be decoded.IllegalArgumentException
- if the input is not valid Base64 encoded data.public static HashMap<String,String> getFieldValues(String line)
public String getCertPW(String fileName)
public void addCertPW(String fileName, String password)
public void addCA(String text)
public boolean isAcceptedCA(String text)
public void initParams(String params)
public String getParams()
The data is separated with '/' between each element and the element key/data is separated with '-'.
public String[] getAuth(boolean usesSSL, String serverName, String scheme, String realm)
The following parameters indicates how the process is handled:
server = protocol://serverName[:port], realm = null | realmString,
server = protocol://serverName[:port], realm = realmString,
public String getAuthString(String method, URL url, String proxyHost)
public String getAuthString(String method, URLConnection uc, String proxyHost)
public HashMap<String,String> getAuthHeaderTable(ArrayList<String> headers, String proxyHost)
public String getAuthString(String method, String protocol, String host, int port, String file, HashMap<String,String> serverAuth, String proxyHost)
public String[] getCurrentAuthString(String serverName, String realm)
serverName
- The server name.realm
- The authentication realm.public String getAuthString(String method, URL url, HashMap<String,String> serverAuth, String proxyHost)
protected PasswordAuthentication getPasswordAuthentication()
getPasswordAuthentication
in class Authenticator
Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.