|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.net.Socket | +--javax.net.ssl.SSLSocket | +--de.tu_darmstadt.sp.ssl.SSLeaySocket
Class SSLeaySocket implements Sun's abstract SSLSocket
definition
using the SSLeay package. SSLeaySockets can be created either connected or
unconnected. connected means that there exists a connection on the
transport layer.
After creation (connected or unconnected) SSLeaySocket
objects have an own SSLeayHandle
object. The handle
will actually perform the SSL protocol for this object. The SSL protocol
can be initiated or restarted using the startHandshake
method.
For the startHandshake
method to succeed, a socket has to be
connected. Therefore, the initiation of transport layer connection
is mandatory before handshake start for unconnected sockets.
The handshake start is supposed to be performed in the factory which creates
a socket. If this is not the case, the connection will be initiated when
the communication starts, this is, by the first use of the getInputStream
or getOutputStream
methods.
SSLeaySocket require by default peer authentication and use the client mode.
Field Summary | |
protected SSLeaySessionContext |
context
|
protected SSLeayHandle |
handle
|
Constructor Summary | |
protected |
SSLeaySocket(java.net.InetAddress address,
int port,
java.net.InetAddress clientAddr,
int clientPort,
SSLeaySessionContext ctx)
Returns a socket connected to a ServerSocket on the named host, at the given port. |
|
SSLeaySocket(java.net.InetAddress address,
int port,
SSLeaySessionContext ctx)
Constructs a TCP connection to a server at a specified address and port.This (usually) acts as the SSL client, but SSL policy is usually controlled by the corresponding factory. |
|
SSLeaySocket(SSLeaySessionContext ctx)
Create an unconnected socket using the client mode. |
|
SSLeaySocket(java.lang.String host,
int port,
java.net.InetAddress clientAddr,
int clientPort,
SSLeaySessionContext ctx)
Constructs an SSL connection to a named host at a specified port, binding the client side of the connection a given address and port. |
|
SSLeaySocket(java.lang.String host,
int port,
SSLeaySessionContext ctx)
Constructs a TCP connection to a named host at a specified port. |
Method Summary | |
void |
addHandshakeCompletedListener(HandshakeCompletedListener listener)
|
void |
close()
Close the SSL connection and this socket . |
java.lang.String[] |
getEnabledCipherSuites()
Returns the names of the SSL cipher suites which are currently enabled for use on this connection. |
boolean |
getEnableSessionCreation()
Returns true if new SSL sessions may be established by this socket. |
java.io.InputStream |
getInputStream()
Returns an input stream for this socket. |
boolean |
getNeedClientAuth()
Returns true if the socket will require client authentication. |
java.io.OutputStream |
getOutputStream()
Returns an output stream for this socket. |
java.lang.String |
getPeerName()
Return peer Distinguished name. |
SSLSession |
getSession()
Returns the the SSL Session in use by this connection. |
java.lang.String[] |
getSupportedCipherSuites()
Returns the names of the cipher suites which could be enabled for use on an SSL connection. |
boolean |
getUseClientMode()
Returns true if the socket is set to use client
mode in its first handshake. |
void |
removeHandshakeCompletedListener(HandshakeCompletedListener listener)
Removes a previously registered handshake completion listener. |
void |
setEnabledCipherSuites(java.lang.String[] ciphers)
Controls which particular cipher suites are enabled for use on this connection. |
void |
setEnableSessionCreation(boolean flag)
Controls whether new SSL sessions may be established by this socket. |
void |
setNeedClientAuth(boolean flag)
Configures the socket to require client authentication. |
void |
setUseClientMode(boolean mode)
Configures the socket to use client (or server) mode in its first handshake. |
void |
startHandshake()
Starts an SSL handshake on this connection. |
java.lang.String |
toString()
Return all information about this SSL socket in string Format: |
Methods inherited from class java.net.Socket |
getInetAddress,
getLocalAddress,
getLocalPort,
getPort,
getReceiveBufferSize,
getSendBufferSize,
getSoLinger,
getSoTimeout,
getTcpNoDelay,
setReceiveBufferSize,
setSendBufferSize,
setSocketImplFactory,
setSoLinger,
setSoTimeout,
setTcpNoDelay |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected SSLeayHandle handle
protected SSLeaySessionContext context
Constructor Detail |
public SSLeaySocket(SSLeaySessionContext ctx)
ctx
parameter is null
, the socket cannot
be used for communication. A SSLeaySocket
created with
a null
ctx parameter can be used to specify the prototype
socket a factory should produce.ctx
- the SSLeaySessionContext
for the session(s)
used by this connection. A null
value yields a prototype
socket, unable to communicate.SSLeayHandle
could be createdpublic SSLeaySocket(java.lang.String host, int port, SSLeaySessionContext ctx) throws java.net.UnknownHostException, java.io.IOException
host
- the host name.port
- the port number.ctx
- the SSLeaySessionContext
for the session(s)
used by this connection.SSLeayHandle
could be createdctx
is null
public SSLeaySocket(java.net.InetAddress address, int port, SSLeaySessionContext ctx) throws java.io.IOException
address
- the IP address.port
- the port number.ctx
- the SSLeaySessionContext
for the session(s)
used by this connection.SSLeayHandle
could be createdctx
is null
public SSLeaySocket(java.lang.String host, int port, java.net.InetAddress clientAddr, int clientPort, SSLeaySessionContext ctx) throws java.io.IOException
host
- the name of the remote hostport
- the remote portclientAddr
- the local address the socket is bound toclientPort
- the local port the socket is bound toctx
- the SSLeaySessionContext
for the session(s)
used by this connection.SSLeayHandle
could be createdctx
is null
protected SSLeaySocket(java.net.InetAddress address, int port, java.net.InetAddress clientAddr, int clientPort, SSLeaySessionContext ctx) throws java.io.IOException
address
- the remote addressport
- the remote portclientAddr
- the local address the socket is bound toclientPort
- the local port the socket is bound toctx
- the SSLeaySessionContext
for the session(s)
used by this connection.SSLeayHandle
could be created.ctx
is null
Method Detail |
public SSLSession getSession()
public void close() throws java.io.IOException
public java.io.InputStream getInputStream() throws java.io.IOException
startHandshake
will be performed.public java.io.OutputStream getOutputStream() throws java.io.IOException
startHandshake
will be performed.public void setUseClientMode(boolean mode)
SSLSocket()
constructor.mode
- if true
connect -- client mode, else accept connectionpublic boolean getUseClientMode()
true
if the socket is set to use client
mode in its first handshake.true
if the socket should start its first handshake in "client" modepublic void startHandshake() throws java.io.IOException, SSLException
useClientMode
mode. For further calls
to this method the behavior is not specified.
(for the moment)public boolean getNeedClientAuth()
true
if the socket will require client authenticationpublic void setNeedClientAuth(boolean flag)
flag
- if true
authenticate peer during handshakepublic void addHandshakeCompletedListener(HandshakeCompletedListener listener)
public void removeHandshakeCompletedListener(HandshakeCompletedListener listener)
listener
- the listener to be removedpublic java.lang.String[] getSupportedCipherSuites()
String
array representing the suported cipherspublic java.lang.String[] getEnabledCipherSuites()
String
array representing the suported cipherspublic void setEnabledCipherSuites(java.lang.String[] ciphers) throws java.lang.IllegalArgumentException
ciphers
- the cipher list to be enabled. If null
, use
the default cipherspublic java.lang.String getPeerName() throws SSLException
SSLException
.public void setEnableSessionCreation(boolean flag)
flag
- if true
,new SSL sessions may be
established by this socketpublic boolean getEnableSessionCreation()
true
if new SSL sessions may be established by this socket.
Not implemented yet.true
if new SSL sessions may be established by this socket.public java.lang.String toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |