diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2013-06-23 08:43:50 +0400 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2013-06-23 08:43:50 +0400 |
commit | 34656055887593414f3941edd38a8140e171b711 (patch) | |
tree | e241132e9e2798bab020cdf3c1f6ab3f02fa646d /core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java | |
parent | 09e97c465f70b592f962d7cbbe186948097202ef (diff) |
Add TlsClient.getResumableSession instead of new
TlsClientProtocol.connect argument
New SessionParameters class to manage session data
Resumed sessions added to context immediately
Javadoc
Diffstat (limited to 'core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java')
-rw-r--r-- | core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java b/core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java index de3ceb3b..2a2c311c 100644 --- a/core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java +++ b/core/src/main/java/org/bouncycastle/crypto/tls/TlsProtocol.java @@ -67,6 +67,7 @@ public abstract class TlsProtocol private byte[] expected_verify_data = null; protected TlsSession tlsSession = null; + protected SessionParameters sessionParameters = null; protected SecurityParameters securityParameters = null; protected short connection_state = CS_START; @@ -82,6 +83,11 @@ public abstract class TlsProtocol this.secureRandom = secureRandom; } + public TlsSession importSession(byte[] sessionID, SessionParameters sessionParameters) + { + return new TlsSessionImpl(sessionID, sessionParameters); + } + protected abstract AbstractTlsContext getContext(); protected abstract TlsPeer getPeer(); @@ -143,14 +149,11 @@ public abstract class TlsProtocol this.tlsOutputStream = new TlsOutputStream(this); } - if (tlsSession != null) + if (this.tlsSession != null && this.sessionParameters == null) { - if (tlsSession.getSecurityParameters() == null) - { - this.tlsSession = new TlsSessionImpl(tlsSession.getSessionID(), securityParameters); - } - - getContext().setSession(tlsSession); + this.sessionParameters = new SessionParameters(securityParameters); + this.tlsSession = new TlsSessionImpl(this.tlsSession.getSessionID(), this.sessionParameters); + getContext().setResumableSession(this.tlsSession); } getPeer().notifyHandshakeComplete(); @@ -592,10 +595,18 @@ public abstract class TlsProtocol protected void invalidateSession() { + if (this.sessionParameters != null) + { + this.sessionParameters.clear(); + this.sessionParameters = null; + } + if (this.tlsSession != null) { - this.tlsSession.close(); + this.tlsSession.invalidate(); this.tlsSession = null; + + getContext().setResumableSession(null); } } |