|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object iaik.security.ssl.Utils
public class Utils
Some basic utility methods.
Field Summary | |
---|---|
static java.lang.String |
PROPERTYNAME_HTTPS_NON_PROXY_HOSTS
Constant string "https.nonProxyHosts". |
static java.lang.String |
PROPERTYNAME_HTTPS_PROXY_HOST
Constant string "https.proxyHost". |
static java.lang.String |
PROPERTYNAME_HTTPS_PROXY_PASSWORD
Constant string "https.proxyPassword". |
static java.lang.String |
PROPERTYNAME_HTTPS_PROXY_PORT
Constant string "https.proxyPort". |
static java.lang.String |
PROPERTYNAME_HTTPS_PROXY_USER
Constant string "https.proxyUser". |
Method Summary | |
---|---|
static byte[] |
base64Encode(byte[] in)
Encodes a binary byte array into Base64. |
static java.lang.String |
certTypeToString(int certType)
Return a string description of a certificate type. |
static boolean |
equalsBlock(byte[] a,
byte[] b)
Check two blocks for equality. |
static boolean |
equalsBlock(byte[] a,
int aOff,
byte[] b,
int bOff,
int len)
Check two blocks for equality. |
static java.security.KeyPair |
generateKeyPair(java.security.KeyPairGenerator kpg)
Generate a keypair in a way compatible with both JDK 1.1 and JDK 1.2. |
static java.io.BufferedReader |
getASCIIReader(java.io.InputStream in)
Get a reader that returns data from the stream assuming ASCII encoding is used. |
static java.io.PrintWriter |
getASCIIWriter(java.io.OutputStream out)
Get a writer that writes data to the stream in ASCII encoding is used. |
static java.io.PrintWriter |
getASCIIWriter(java.io.OutputStream out,
boolean autoflush)
Get a writer that writes data to the stream in ASCII encoding is used. |
static int |
getCertificateType(java.security.cert.X509Certificate cert)
Get the type of a certificate. |
static int |
getCertificateType(java.security.cert.X509Certificate[] certChain)
Get the type of a certificate. |
static int |
getCertificateTypeWithoutKeyUsage(java.security.cert.X509Certificate cert)
Get the type of a certificate. |
static int |
getCertificateTypeWithoutKeyUsage(java.security.cert.X509Certificate[] certChain)
Get the type of a certificate. |
static java.lang.String |
getVersionString(int version)
Returns a String representation of the SSL version number. |
static SSLSocket |
proxyConnect(java.net.InetAddress address,
int port,
SSLContext context)
Connects to the specified host via HTTPS proxy (if set via properties). |
static SSLSocket |
proxyConnect(java.net.InetAddress address,
int port,
SSLContext context,
java.net.InetAddress proxyAddress,
int proxyPort)
Connects to the specified host via HTTPS proxy. |
static SSLSocket |
proxyConnect(java.lang.String host,
int port,
SSLContext context)
Connects to the specified host via HTTPS proxy (if set via properties). |
static SSLSocket |
proxyConnect(java.lang.String host,
int port,
SSLContext context,
java.net.InetAddress proxyAddress,
int proxyPort)
Connects to the specified host via HTTPS proxy. |
static SSLSocket |
proxyConnect(java.lang.String host,
int port,
SSLContext context,
java.net.Socket proxySocket)
Connects to the specified host via HTTPS proxy. |
static SSLSocket |
proxyConnect(java.lang.String host,
int port,
SSLContext context,
java.net.Socket proxySocket,
java.lang.String authenticationMechanism,
java.lang.String authenticationMessage,
int timeout)
Connects to the specified host via HTTPS proxy. |
static java.lang.String |
toString(byte[] b)
Returns a hexadecimal representation of the contents of the given byte array. |
static java.lang.String |
toString(int a)
|
static java.lang.String |
versionToName(int version)
Gets a the protocol version name of the given version number. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PROPERTYNAME_HTTPS_PROXY_HOST
public static final java.lang.String PROPERTYNAME_HTTPS_PROXY_PORT
public static final java.lang.String PROPERTYNAME_HTTPS_PROXY_USER
public static final java.lang.String PROPERTYNAME_HTTPS_PROXY_PASSWORD
public static final java.lang.String PROPERTYNAME_HTTPS_NON_PROXY_HOSTS
Method Detail |
---|
public static boolean equalsBlock(byte[] a, int aOff, byte[] b, int bOff, int len)
a
- the first byte array to be comparedaOff
- the offset indicating the start position of the sub-block of a
b
- the second byte array to be comparedbOff
- the offset indicating the start position of the sub-block of b
len
- the number of bytes to be compared
true
, if the two sub-blocks are equal, false
otherwisepublic static boolean equalsBlock(byte[] a, byte[] b)
a
- the first byte array to be comparedb
- the second byte array to be compared
true
, if the two blocks are equal, false
otherwisepublic static java.lang.String toString(byte[] b)
b
- the byte array for which to get a hexadecimal representation
public static java.lang.String toString(int a)
public static java.lang.String versionToName(int version)
version
- the version number as integer
java.lang.IllegalArgumentException
- if the given protocol is not supportedpublic static SSLSocket proxyConnect(java.net.InetAddress address, int port, SSLContext context) throws java.io.IOException
address
- the target host addressport
- the target portcontext
- the SSLContext for configuring the SSLSocket
java.io.IOException
- if an error occurs while trying to connectpublic static SSLSocket proxyConnect(java.lang.String host, int port, SSLContext context) throws java.io.IOException
host
- the target hostport
- the target portcontext
- the SSLContext for configuring the SSLSocket
java.io.IOException
- if an error occurs while trying to connectpublic static SSLSocket proxyConnect(java.net.InetAddress address, int port, SSLContext context, java.net.InetAddress proxyAddress, int proxyPort) throws java.io.IOException
address
- the address target hostport
- the target portcontext
- the SSLContext for configuring the SSLSocketproxyAddress
- the address of the proxyproxyPort
- the port of the proxy
IOExcaption
- if an error occurs while trying to connect
java.io.IOException
public static SSLSocket proxyConnect(java.lang.String host, int port, SSLContext context, java.net.InetAddress proxyAddress, int proxyPort) throws java.io.IOException
host
- the target hostport
- the target portcontext
- the SSLContext for configuring the SSLSocketproxyAddress
- the address of the proxyproxyPort
- the port of the proxy
IOExcaption
- if an error occurs while trying to connect
java.io.IOException
public static SSLSocket proxyConnect(java.lang.String host, int port, SSLContext context, java.net.Socket proxySocket) throws java.io.IOException
host
- the target hostport
- the target portcontext
- the SSLContext for configuring the SSLSocketproxySocket
- the socket for talking with the proxy
java.io.IOException
- if an error occurs while trying to connectpublic static SSLSocket proxyConnect(java.lang.String host, int port, SSLContext context, java.net.Socket proxySocket, java.lang.String authenticationMechanism, java.lang.String authenticationMessage, int timeout) throws java.io.IOException
host
- the target hostport
- the target portcontext
- the SSLContext for configuring the SSLSocketproxySocket
- the socket for talking with the proxyauthenticationMechanism
- the authentication mechanism (e.g. "Basic..."); must
not be set by the application (i.e. can be null)authenticationMessage
- the authentication string specifying authentication method
(e.g. "Basic" and base64 encoded proxy username and password;
maybe null in which case proxy username and password have to
be set via system properties "https.proxyUser"
and "https.proxyPassword"
timeout
- the timeout for the proxy response (default: 30 seconds)
java.io.IOException
- if an error occurs while trying to connectpublic static int getCertificateType(java.security.cert.X509Certificate cert)
cert
- the certificate for which to get the cert type
public static int getCertificateType(java.security.cert.X509Certificate[] certChain)
certChain
- the certificate chain for which to get the cert type
(for the certificate at index 0)
public static int getCertificateTypeWithoutKeyUsage(java.security.cert.X509Certificate cert)
cert
- the certificate for which to get the cert type
public static int getCertificateTypeWithoutKeyUsage(java.security.cert.X509Certificate[] certChain)
certChain
- the certificate chain for which to get the cert type
(for the certificate at index 0)
public static java.lang.String certTypeToString(int certType)
certType
- the certificate type for which to get a string description
public static java.io.BufferedReader getASCIIReader(java.io.InputStream in)
public static java.io.PrintWriter getASCIIWriter(java.io.OutputStream out)
public static java.io.PrintWriter getASCIIWriter(java.io.OutputStream out, boolean autoflush)
public static java.lang.String getVersionString(int version)
version
- the SSL version number
public static java.security.KeyPair generateKeyPair(java.security.KeyPairGenerator kpg)
public static byte[] base64Encode(byte[] in) throws java.io.IOException
Base64 is the encoding format used by Multipurpose Internet Mail Extension (Mime) for transmitting non-text material over text-only communications channels. Base64 is based on a 65-character subset of US-ASCII, enabling 6 bits to be represented per printable character (see RFC 1521).
in
- the binary data to be Base64 encoded
java.io.IOException
|
This Javadoc may contain text parts from text parts from IETF Internet Standard specifications (see copyright note). | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |