Top Description Inners Fields Constructors Methods
org.mortbay.jetty.security

public Class SslSocketConnector

extends SocketConnector
Class Inheritance
Imports
java.io.ByteArrayInputStream, .File, .IOException, .InputStream, java.net.InetAddress, .ServerSocket, .Socket, .SocketAddress, java.security.KeyStore, .SecureRandom, .Security, java.security.cert.X509Certificate, java.util.ArrayList, .Arrays, .Iterator, .List, javax.net.ssl.HandshakeCompletedEvent, .HandshakeCompletedListener, .KeyManager, .KeyManagerFactory, .SSLContext, .SSLException, .SSLPeerUnverifiedException, .SSLServerSocket, .SSLServerSocketFactory, .SSLSession, .SSLSocket, .TrustManager, .TrustManagerFactory, org.mortbay.io.EndPoint, org.mortbay.io.bio.SocketEndPoint, org.mortbay.jetty.HttpSchemes, .Request, org.mortbay.jetty.bio.SocketConnector, org.mortbay.log.Log, org.mortbay.resource.Resource

JSSE Socket Listener. This specialization of HttpListener is an abstract listener that can be used as the basis for a specific JSSE listener. This is heavily based on the work from Court Demas, which in turn is based on the work from Forge Research.
Authors
Greg Wilkins ([email protected]), Court Demas ([email protected]), Forge Research Pty Ltd ACN 003 491 576, Jan Hlavat�

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
SslSocketConnector.CachedInfo

Simple bundle of information that is cached in the SSLSession.

public class

Field Summary

Modifier and TypeField and Description
private boolean
private String[]
_excludeCipherSuites

Default value for the cipher Suites.

private int
private transient Password
private String
_keystore

Default value for the keystore location path.

private String
private boolean
_needClientAuth

Set to true if we require client certificate authentication.

private transient Password
private String
private String
private String
private String
private String
private transient Password
private String
private String
private boolean
_wantClientAuth

Set to true if we would like client certificate authentication.

pack-priv static final String
CACHED_INFO_ATTR

The name of the SSLSession attribute that will contain any cached information.

public static final String
DEFAULT_KEYSTORE

Default value for the keystore location path.

public static final String
KEYPASSWORD_PROPERTY

String name of key password property.

public static final String
PASSWORD_PROPERTY

String name of keystore password property.

Inherited from org.mortbay.jetty.bio.SocketConnector:
_connections_serverSocket

Constructor Summary

AccessConstructor and Description
public
SslSocketConnector()

Constructor.

Method Summary

Modifier and TypeMethod and Description
public void
protected void
protected SSLServerSocketFactory
public void
customize(EndPoint
The Socket the request arrived on. This should be a SocketEndPoint wrapping a SSLSocket.
endpoint
,
Request
HttpRequest to be customised.
request
)

Overrides org.mortbay.jetty.bio.SocketConnector.customize.

Implements org.mortbay.jetty.Connector.customize.

Allow the Listener a chance to customise the request.
private static X509Certificate[]

Returns:

the chain of java.security.cert.X509Certificates used to negotiate the SSL connection.
Will be null if the chain is missing or empty.
getCertChain
(SSLSession
the javax.net.ssl.SSLSession to use as the source of the cert chain.
sslSession
)

Return the chain of X509 certificates used to negotiate the SSL Session.

public String[]
public int
public String
public String
public boolean
public String
public String
public String
public String
public String
public String
public String
public boolean
public boolean

Returns:

True if SSL re-negotiation is allowed (default false)
isAllowRenegotiate
()

public boolean
isConfidential(Request
A request
request
)

Overrides org.mortbay.jetty.AbstractConnector.isConfidential.

Implements org.mortbay.jetty.Connector.isConfidential.

By default, we're confidential, given we speak SSL.
public boolean
isIntegral(Request
A request
request
)

Overrides org.mortbay.jetty.AbstractConnector.isIntegral.

Implements org.mortbay.jetty.Connector.isIntegral.

By default, we're integral, given we speak SSL.
protected ServerSocket

Returns:

A new socket object bound to the supplied address with all other settings as per the current configuration of this connector.
newServerSocket
(String
The address that this server should listen on
host
,
int port, int backlog)

Overrides org.mortbay.jetty.bio.SocketConnector.newServerSocket.

public void
setAllowRenegotiate(boolean
true if re-negotiation is allowed (default false)
allowRenegotiate
)

Set if SSL re-negotiation is allowed.

public void
public void
setHandshakeTimeout(int
a non-zero value will be used to set so_timeout during ssl handshakes. A zero value means the maxIdleTime is used instead.
msec
)

Set the time in milliseconds for so_timeout during ssl handshaking

public void
public void
setKeystore(String
The resource path to the keystore, or null for built in keystores.
keystore
)

public void
setKeystoreType(String keystoreType)

public void
setNeedClientAuth(boolean
true iff we require client certificate authentication.
needClientAuth
)

Set the value of the needClientAuth property

public void
setPassword(String password)

public void
setProtocol(String protocol)

public void
setProvider(String _provider)

public void
public void
public void
public void
public void
setTruststore(String truststore)

public void
setTruststoreType(String truststoreType)

public void
setWantClientAuth(boolean
true iff we want client certificate authentication.
wantClientAuth
)

Set the value of the _wantClientAuth property.

Inherited from org.mortbay.jetty.bio.SocketConnector:
closedoStartdoStopgetConnectiongetLocalPortnewBuffernewHttpConnectionopen

Field Detail

_allowRenegotiateback to summary
private boolean _allowRenegotiate
_excludeCipherSuitesback to summary
private String[] _excludeCipherSuites

Default value for the cipher Suites.

_handshakeTimeoutback to summary
private int _handshakeTimeout
_keyPasswordback to summary
private transient Password _keyPassword
_keystoreback to summary
private String _keystore

Default value for the keystore location path.

_keystoreTypeback to summary
private String _keystoreType
_needClientAuthback to summary
private boolean _needClientAuth

Set to true if we require client certificate authentication.

_passwordback to summary
private transient Password _password
_protocolback to summary
private String _protocol
_providerback to summary
private String _provider
_secureRandomAlgorithmback to summary
private String _secureRandomAlgorithm
_sslKeyManagerFactoryAlgorithmback to summary
private String _sslKeyManagerFactoryAlgorithm
_sslTrustManagerFactoryAlgorithmback to summary
private String _sslTrustManagerFactoryAlgorithm
_trustPasswordback to summary
private transient Password _trustPassword
_truststoreback to summary
private String _truststore
_truststoreTypeback to summary
private String _truststoreType
_wantClientAuthback to summary
private boolean _wantClientAuth

Set to true if we would like client certificate authentication.

CACHED_INFO_ATTRback to summary
pack-priv static final String CACHED_INFO_ATTR

The name of the SSLSession attribute that will contain any cached information.

DEFAULT_KEYSTOREback to summary
public static final String DEFAULT_KEYSTORE

Default value for the keystore location path.

KEYPASSWORD_PROPERTYback to summary
public static final String KEYPASSWORD_PROPERTY

String name of key password property.

PASSWORD_PROPERTYback to summary
public static final String PASSWORD_PROPERTY

String name of keystore password property.

Constructor Detail

SslSocketConnectorback to summary
public SslSocketConnector()

Constructor.

Method Detail

acceptback to summary
public void accept(int acceptorID) throws IOException, InterruptedException

Overrides org.mortbay.jetty.bio.SocketConnector.accept.

configureback to summary
protected void configure(Socket socket) throws IOException

Overrides org.mortbay.jetty.AbstractConnector.configure.

createFactoryback to summary
protected SSLServerSocketFactory createFactory() throws Exception
customizeback to summary
public void customize(EndPoint endpoint, Request request) throws IOException

Overrides org.mortbay.jetty.bio.SocketConnector.customize.

Implements org.mortbay.jetty.Connector.customize.

Allow the Listener a chance to customise the request. before the server does its stuff.
This allows the required attributes to be set for SSL requests.
The requirements of the Servlet specs are:

  • an attribute named "javax.servlet.request.cipher_suite" of type String.
  • an attribute named "javax.servlet.request.key_size" of type Integer.
  • an attribute named "javax.servlet.request.X509Certificate" of type java.security.cert.X509Certificate[]. This is an array of objects of type X509Certificate, the order of this array is defined as being in ascending order of trust. The first certificate in the chain is the one set by the client, the next is the one used to authenticate the first, and so on.
Parameters
endpoint:EndPoint

The Socket the request arrived on. This should be a SocketEndPoint wrapping a SSLSocket.

request:Request

HttpRequest to be customised.

getCertChainback to summary
private static X509Certificate[] getCertChain(SSLSession sslSession)

Return the chain of X509 certificates used to negotiate the SSL Session.

Note

in order to do this we must convert a javax.security.cert.X509Certificate[], as used by JSSE to a java.security.cert.X509Certificate[],as required by the Servlet specs.

Parameters
sslSession:SSLSession

the javax.net.ssl.SSLSession to use as the source of the cert chain.

Returns:X509Certificate[]

the chain of java.security.cert.X509Certificates used to negotiate the SSL connection.
Will be null if the chain is missing or empty.

getExcludeCipherSuitesback to summary
public String[] getExcludeCipherSuites()
getHandshakeTimeoutback to summary
public int getHandshakeTimeout()
getKeystoreback to summary
public String getKeystore()
getKeystoreTypeback to summary
public String getKeystoreType()
getNeedClientAuthback to summary
public boolean getNeedClientAuth()
getProtocolback to summary
public String getProtocol()
getProviderback to summary
public String getProvider()
getSecureRandomAlgorithmback to summary
public String getSecureRandomAlgorithm()
getSslKeyManagerFactoryAlgorithmback to summary
public String getSslKeyManagerFactoryAlgorithm()
getSslTrustManagerFactoryAlgorithmback to summary
public String getSslTrustManagerFactoryAlgorithm()
getTruststoreback to summary
public String getTruststore()
getTruststoreTypeback to summary
public String getTruststoreType()
getWantClientAuthback to summary
public boolean getWantClientAuth()
isAllowRenegotiateback to summary
public boolean isAllowRenegotiate()
Returns:boolean

True if SSL re-negotiation is allowed (default false)

isConfidentialback to summary
public boolean isConfidential(Request request)

Overrides org.mortbay.jetty.AbstractConnector.isConfidential.

Implements org.mortbay.jetty.Connector.isConfidential.

By default, we're confidential, given we speak SSL. But, if we've been told about an confidential port, and said port is not our port, then we're not. This allows separation of listeners providing INTEGRAL versus CONFIDENTIAL constraints, such as one SSL listener configured to require client certs providing CONFIDENTIAL, whereas another SSL listener not requiring client certs providing mere INTEGRAL constraints.

Parameters
request:Request

Doc from org.mortbay.jetty.Connector.isConfidential.

A request

Returns:boolean

Doc from org.mortbay.jetty.Connector.isConfidential.

true if the request is confidential. This normally means the https schema has been used.

isIntegralback to summary
public boolean isIntegral(Request request)

Overrides org.mortbay.jetty.AbstractConnector.isIntegral.

Implements org.mortbay.jetty.Connector.isIntegral.

By default, we're integral, given we speak SSL. But, if we've been told about an integral port, and said port is not our port, then we're not. This allows separation of listeners providing INTEGRAL versus CONFIDENTIAL constraints, such as one SSL listener configured to require client certs providing CONFIDENTIAL, whereas another SSL listener not requiring client certs providing mere INTEGRAL constraints.

Parameters
request:Request

Doc from org.mortbay.jetty.Connector.isIntegral.

A request

Returns:boolean

Doc from org.mortbay.jetty.Connector.isIntegral.

true if the request is integral. This normally means the https schema has been used.

newServerSocketback to summary
protected ServerSocket newServerSocket(String host, int port, int backlog) throws IOException

Overrides org.mortbay.jetty.bio.SocketConnector.newServerSocket.

Parameters
host:String

The address that this server should listen on

backlog:int

See ServerSocket#bind(java.net.SocketAddress, int)

Returns:ServerSocket

A new socket object bound to the supplied address with all other settings as per the current configuration of this connector.

See Also
setWantClientAuth, setNeedClientAuth, setCipherSuites
setAllowRenegotiateback to summary
public void setAllowRenegotiate(boolean allowRenegotiate)

Set if SSL re-negotiation is allowed. CVE-2009-3555 discovered a vulnerability in SSL/TLS with re-negotiation. If your JVM does not have CVE-2009-3555 fixed, then re-negotiation should not be allowed.

Parameters
allowRenegotiate:boolean

true if re-negotiation is allowed (default false)

setExcludeCipherSuitesback to summary
public void setExcludeCipherSuites(String[] cipherSuites)
Author
Tony Jiang
setHandshakeTimeoutback to summary
public void setHandshakeTimeout(int msec)

Set the time in milliseconds for so_timeout during ssl handshaking

Parameters
msec:int

a non-zero value will be used to set so_timeout during ssl handshakes. A zero value means the maxIdleTime is used instead.

setKeyPasswordback to summary
public void setKeyPassword(String password)
setKeystoreback to summary
public void setKeystore(String keystore)
Parameters
keystore:String

The resource path to the keystore, or null for built in keystores.

setKeystoreTypeback to summary
public void setKeystoreType(String keystoreType)
setNeedClientAuthback to summary
public void setNeedClientAuth(boolean needClientAuth)

Set the value of the needClientAuth property

Parameters
needClientAuth:boolean

true iff we require client certificate authentication.

setPasswordback to summary
public void setPassword(String password)
setProtocolback to summary
public void setProtocol(String protocol)
setProviderback to summary
public void setProvider(String _provider)
setSecureRandomAlgorithmback to summary
public void setSecureRandomAlgorithm(String algorithm)
setSslKeyManagerFactoryAlgorithmback to summary
public void setSslKeyManagerFactoryAlgorithm(String algorithm)
setSslTrustManagerFactoryAlgorithmback to summary
public void setSslTrustManagerFactoryAlgorithm(String algorithm)
setTrustPasswordback to summary
public void setTrustPassword(String password)
setTruststoreback to summary
public void setTruststore(String truststore)
setTruststoreTypeback to summary
public void setTruststoreType(String truststoreType)
setWantClientAuthback to summary
public void setWantClientAuth(boolean wantClientAuth)

Set the value of the _wantClientAuth property. This property is used when opening server sockets.

Parameters
wantClientAuth:boolean

true iff we want client certificate authentication.

See Also
SSLServerSocket#setWantClientAuth
org.mortbay.jetty.security back to summary

private Class SslSocketConnector.CachedInfo

extends Object
Class Inheritance

Simple bundle of information that is cached in the SSLSession. Stores the effective keySize and the client certificate chain.

Field Summary

Modifier and TypeField and Description
private X509Certificate[]
private Integer

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv X509Certificate[]
pack-priv Integer
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_certsback to summary
private X509Certificate[] _certs
_keySizeback to summary
private Integer _keySize

Constructor Detail

CachedInfoback to summary
pack-priv CachedInfo(Integer keySize, X509Certificate[] certs)

Method Detail

getCertsback to summary
pack-priv X509Certificate[] getCerts()
getKeySizeback to summary
pack-priv Integer getKeySize()
org.mortbay.jetty.security back to summary

public Class SslSocketConnector.SslConnection

extends Connection
Class Inheritance

Field Summary

Inherited from org.mortbay.jetty.bio.SocketConnector.Connection:
_socket

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
shutdownOutput()

Overrides org.mortbay.io.bio.SocketEndPoint.shutdownOutput.

Implements org.mortbay.io.EndPoint.shutdownOutput.

Shutdown any backing output stream associated with the endpoint
Inherited from org.mortbay.jetty.bio.SocketConnector.Connection:
dispatchfill

Constructor Detail

SslConnectionback to summary
public SslConnection(Socket socket) throws IOException

Method Detail

runback to summary
public void run()

Overrides org.mortbay.jetty.bio.SocketConnector.Connection.run.

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

shutdownOutputback to summary
public void shutdownOutput() throws IOException

Overrides org.mortbay.io.bio.SocketEndPoint.shutdownOutput.

Implements org.mortbay.io.EndPoint.shutdownOutput.

Doc from org.mortbay.io.EndPoint.shutdownOutput.

Shutdown any backing output stream associated with the endpoint