Methods Summary |
---|
public java.net.Socket | acceptSocket(java.net.ServerSocket socket)
SSLSocket asock = null;
try {
asock = (SSLSocket)socket.accept();
asock.setNeedClientAuth(clientAuth);
} catch (SSLException e){
throw new SocketException("SSL handshake error" + e.toString());
}
return asock;
|
public java.net.ServerSocket | createSocket(int port)
if (!initialized) init();
ServerSocket socket = sslProxy.createServerSocket(port);
initServerSocket(socket);
return socket;
|
public java.net.ServerSocket | createSocket(int port, int backlog)
if (!initialized) init();
ServerSocket socket = sslProxy.createServerSocket(port, backlog);
initServerSocket(socket);
return socket;
|
public java.net.ServerSocket | createSocket(int port, int backlog, java.net.InetAddress ifAddress)
if (!initialized) init();
ServerSocket socket = sslProxy.createServerSocket(port, backlog,
ifAddress);
initServerSocket(socket);
return socket;
|
protected java.lang.String[] | getEnabledCiphers(java.lang.String requestedCiphers, java.lang.String[] supportedCiphers)
String[] enabledCiphers = null;
if (requestedCiphers != null) {
Vector vec = null;
String cipher = requestedCiphers;
int index = requestedCiphers.indexOf(',");
if (index != -1) {
int fromIndex = 0;
while (index != -1) {
cipher = requestedCiphers.substring(fromIndex, index).trim();
if (cipher.length() > 0) {
/*
* Check to see if the requested cipher is among the
* supported ciphers, i.e., may be enabled
*/
for (int i=0; supportedCiphers != null
&& i<supportedCiphers.length; i++) {
if (supportedCiphers[i].equals(cipher)) {
if (vec == null) {
vec = new Vector();
}
vec.addElement(cipher);
break;
}
}
}
fromIndex = index+1;
index = requestedCiphers.indexOf(',", fromIndex);
} // while
cipher = requestedCiphers.substring(fromIndex);
}
if (cipher != null) {
cipher = cipher.trim();
if (cipher.length() > 0) {
/*
* Check to see if the requested cipher is among the
* supported ciphers, i.e., may be enabled
*/
for (int i=0; supportedCiphers != null
&& i<supportedCiphers.length; i++) {
if (supportedCiphers[i].equals(cipher)) {
if (vec == null) {
vec = new Vector();
}
vec.addElement(cipher);
break;
}
}
}
}
if (vec != null) {
enabledCiphers = new String[vec.size()];
vec.copyInto(enabledCiphers);
}
}
return enabledCiphers;
|
protected abstract java.lang.String[] | getEnabledProtocols(javax.net.ssl.SSLServerSocket socket, java.lang.String requestedProtocols)
|
protected java.security.KeyStore | getKeystore(java.lang.String pass)
String keystoreFile = (String)attributes.get("keystore");
if (log.isDebugEnabled()) {
log.debug("Keystore file= " + keystoreFile);
}
String keystoreType = (String)attributes.get("keystoreType");
if (log.isDebugEnabled()) {
log.debug("Keystore type= " + keystoreType);
}
return getStore(keystoreType, keystoreFile, pass);
|
protected java.lang.String | getKeystorePassword()
String keyPass = (String)attributes.get("keypass");
if (keyPass == null) {
keyPass = defaultKeyPass;
}
String keystorePass = (String)attributes.get("keystorePass");
if (keystorePass == null) {
keystorePass = keyPass;
}
return keystorePass;
|
private java.security.KeyStore | getStore(java.lang.String type, java.lang.String path, java.lang.String pass)
KeyStore ks = null;
InputStream istream = null;
try {
ks = KeyStore.getInstance(type);
File keyStoreFile = new File(path);
if (!keyStoreFile.isAbsolute()) {
keyStoreFile = new File(System.getProperty("catalina.base"),
path);
}
istream = new FileInputStream(keyStoreFile);
ks.load(istream, pass.toCharArray());
istream.close();
istream = null;
} catch (FileNotFoundException fnfe) {
throw fnfe;
} catch (IOException ioe) {
throw ioe;
} catch(Exception ex) {
ex.printStackTrace();
throw new IOException("Exception trying to load keystore " +
path + ": " + ex.getMessage() );
} finally {
if (istream != null) {
try {
istream.close();
} catch (IOException ioe) {
// Do nothing
}
}
}
return ks;
|
protected java.security.KeyStore | getTrustStore()
String truststore = (String)attributes.get("truststore");
if (log.isDebugEnabled()) {
log.debug("Truststore file= " + truststore);
}
String truststoreType = (String)attributes.get("truststoreType");
if (log.isDebugEnabled()) {
log.debug("Truststore type= " + truststoreType);
}
String truststorePassword = System.getProperty(
"javax.net.ssl.trustStorePassword");
if (truststorePassword == null) {
truststorePassword = getKeystorePassword();
}
return getStore(truststoreType, truststore, truststorePassword);
|
public void | handshake(java.net.Socket sock)
((SSLSocket)sock).startHandshake();
|
public abstract void | init()Reads the keystore and initializes the SSL socket factory.
Place holder method to initialize the KeyStore, etc.
|
private void | initServerSocket(java.net.ServerSocket ssocket)Configures the given SSL server socket with the requested cipher suites,
protocol versions, and need for client authentication
SSLServerSocket socket = (SSLServerSocket) ssocket;
if (attributes.get("ciphers") != null) {
socket.setEnabledCipherSuites(enabledCiphers);
}
String requestedProtocols = (String) attributes.get("protocols");
setEnabledProtocols(socket, getEnabledProtocols(socket,
requestedProtocols));
// we don't know if client auth is needed -
// after parsing the request we may re-handshake
socket.setNeedClientAuth(clientAuth);
|
protected abstract void | setEnabledProtocols(javax.net.ssl.SSLServerSocket socket, java.lang.String[] protocols)Set the SSL protocol variants to be enabled.
|