Package org.simpleframework.transport
Class NegotiationState
- java.lang.Object
-
- org.simpleframework.transport.NegotiationState
-
- All Implemented Interfaces:
Certificate
class NegotiationState extends java.lang.Object implements Certificate
TheNegotiationState
represents the certificate that is sent by a client during a secure HTTPS conversation. This may or may not contain an X509 certificate chain from the client. If it does not aCertificateChallenge
may be used to issue a renegotiation of the connection. One completion of the renegotiation the challenge executes a completion operation.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
NegotiationState.Challenge
TheChallenge
object is used to enable the server to challenge for the client X509 certificate if desired.private class
NegotiationState.Delegate
TheDelegate
is basically a settable runnable object.
-
Field Summary
Fields Modifier and Type Field Description private NegotiationState.Challenge
challenge
This is the challenge used to request the client certificate.private NegotiationState.Delegate
delegate
This is the runnable task that is executed on task completion.private java.util.concurrent.RunnableFuture<Certificate>
future
This is used to hold the completion task for the challenge.private Negotiation
negotiation
This is the handshake used to acquire the certificate details.private Socket
socket
This is the socket representing the underlying TCP connection.
-
Constructor Summary
Constructors Constructor Description NegotiationState(Negotiation negotiation, Socket socket)
Constructor for theNegotiationCertificate
object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javax.security.cert.X509Certificate[]
getChain()
This will return the X509 certificate chain, if any, that has been sent by the client.CertificateChallenge
getChallenge()
This returns a challenge for the certificate.java.util.concurrent.RunnableFuture<Certificate>
getFuture()
This returns the completion task associated with any challenge made for the client certificate.javax.net.ssl.SSLSession
getSession()
This is used to acquire the SSL session associated with the handshake.boolean
isChainPresent()
This is used to determine if the X509 certificate chain is present for the request.boolean
isChallenge()
This is used to determine if the state is in challenge mode.
-
-
-
Field Detail
-
future
private final java.util.concurrent.RunnableFuture<Certificate> future
This is used to hold the completion task for the challenge.
-
negotiation
private final Negotiation negotiation
This is the handshake used to acquire the certificate details.
-
challenge
private final NegotiationState.Challenge challenge
This is the challenge used to request the client certificate.
-
delegate
private final NegotiationState.Delegate delegate
This is the runnable task that is executed on task completion.
-
socket
private final Socket socket
This is the socket representing the underlying TCP connection.
-
-
Constructor Detail
-
NegotiationState
public NegotiationState(Negotiation negotiation, Socket socket)
Constructor for theNegotiationCertificate
object. This creates an object used to provide certificate details and a means to challenge for certificate details for the connected client if required.- Parameters:
negotiation
- the negotiation associated with thissocket
- the underlying TCP connection to the client
-
-
Method Detail
-
isChallenge
public boolean isChallenge()
This is used to determine if the state is in challenge mode. In challenge mode a challenge future will be executed on completion of the challenge. This will the completion task.- Returns:
- this returns true if the state is in challenge mode
-
getFuture
public java.util.concurrent.RunnableFuture<Certificate> getFuture()
This returns the completion task associated with any challenge made for the client certificate. If this returns null then no challenge has been made for the client certificate.- Returns:
- this returns the challenge completion task if any
-
getChallenge
public CertificateChallenge getChallenge() throws java.lang.Exception
This returns a challenge for the certificate. A challenge is issued by providing aRunnable
task which is to be executed when the challenge has completed. Typically this task should be used to drive completion of an HTTPS request.- Specified by:
getChallenge
in interfaceCertificate
- Returns:
- this returns a challenge for the client certificate
- Throws:
java.lang.Exception
-
getChain
public javax.security.cert.X509Certificate[] getChain() throws java.lang.Exception
This will return the X509 certificate chain, if any, that has been sent by the client. A certificate chain is typically only send when the server explicitly requests the certificate on the initial connection or when it is challenged for.- Specified by:
getChain
in interfaceCertificate
- Returns:
- this returns the clients X509 certificate chain
- Throws:
java.lang.Exception
-
getSession
public javax.net.ssl.SSLSession getSession() throws java.lang.Exception
This is used to acquire the SSL session associated with the handshake. The session makes all of the details associated with the handshake available, including the cipher suites used and the SSL context used to create the session.- Returns:
- the SSL session associated with the connection
- Throws:
java.lang.Exception
-
isChainPresent
public boolean isChainPresent()
This is used to determine if the X509 certificate chain is present for the request. If it is not present then a challenge can be used to request the certificate.- Specified by:
isChainPresent
in interfaceCertificate
- Returns:
- true if the certificate chain is present
-
-