Package io.netty.handler.ssl
Class ReferenceCountedOpenSslEngine.DefaultOpenSslSession
- java.lang.Object
-
- io.netty.handler.ssl.ReferenceCountedOpenSslEngine.DefaultOpenSslSession
-
- All Implemented Interfaces:
OpenSslInternalSession,OpenSslSession,javax.net.ssl.SSLSession
- Enclosing class:
- ReferenceCountedOpenSslEngine
private final class ReferenceCountedOpenSslEngine.DefaultOpenSslSession extends java.lang.Object implements OpenSslInternalSession
-
-
Field Summary
Fields Modifier and Type Field Description private intapplicationBufferSizeprivate java.lang.Stringcipherprivate longcreationTimeprivate OpenSslSessionIdidprivate java.util.Map<java.lang.String,java.lang.Object>keyValueStorageprivate longlastAccessedprivate java.security.cert.Certificate[]localCertificateChainprivate java.security.cert.Certificate[]peerCertsprivate java.lang.Stringprotocolprivate OpenSslSessionContextsessionContextprivate booleanvalidprivate javax.security.cert.X509Certificate[]x509PeerCerts
-
Constructor Summary
Constructors Constructor Description DefaultOpenSslSession(OpenSslSessionContext sessionContext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)intgetApplicationBufferSize()java.lang.StringgetCipherSuite()longgetCreationTime()byte[]getId()longgetLastAccessedTime()java.security.cert.Certificate[]getLocalCertificates()java.security.PrincipalgetLocalPrincipal()intgetPacketBufferSize()javax.security.cert.X509Certificate[]getPeerCertificateChain()java.security.cert.Certificate[]getPeerCertificates()java.lang.StringgetPeerHost()intgetPeerPort()java.security.PrincipalgetPeerPrincipal()java.lang.StringgetProtocol()OpenSslSessionContextgetSessionContext()java.lang.ObjectgetValue(java.lang.String name)java.lang.String[]getValueNames()voidhandshakeFinished(byte[] id, java.lang.String cipher, java.lang.String protocol, byte[] peerCertificate, byte[][] peerCertificateChain, long creationTime, long timeout)Finish the handshake and so init everything in theOpenSslInternalSessionthat should be accessible by the user.inthashCode()booleanhasPeerCertificates()Returns true if the peer has provided certificates during the handshake.private voidinitCerts(byte[][] chain, int startPos)voidinvalidate()booleanisValid()java.util.Map<java.lang.String,java.lang.Object>keyValueStorage()Return the underlyingMapthat is used by the following methods:SSLSession.putValue(String, Object)SSLSession.removeValue(String)SSLSession.getValue(String)SSLSession.getValueNames()TheMapmust be thread-safe!private javax.net.ssl.SSLSessionBindingEventnewSSLSessionBindingEvent(java.lang.String name)private voidnotifyUnbound(java.lang.Object value, java.lang.String name)voidprepareHandshake()Called on a handshake session before being exposed to aTrustManager.voidputValue(java.lang.String name, java.lang.Object value)voidremoveValue(java.lang.String name)OpenSslSessionIdsessionId()Return theOpenSslSessionIdthat can be used to identify this session.voidsetLastAccessedTime(long time)Set the last access time which will be returned bySSLSession.getLastAccessedTime().voidsetLocalCertificate(java.security.cert.Certificate[] localCertificate)Set the local certificate chain that is used.voidsetSessionDetails(long creationTime, long lastAccessedTime, OpenSslSessionId sessionId, java.util.Map<java.lang.String,java.lang.Object> keyValueStorage)Set the details for the session which might come from a cache.java.lang.StringtoString()voidtryExpandApplicationBufferSize(int packetLengthDataOnly)Expand (or increase) the value returned bySSLSession.getApplicationBufferSize()if necessary.
-
-
-
Field Detail
-
sessionContext
private final OpenSslSessionContext sessionContext
-
x509PeerCerts
private javax.security.cert.X509Certificate[] x509PeerCerts
-
peerCerts
private java.security.cert.Certificate[] peerCerts
-
valid
private boolean valid
-
protocol
private java.lang.String protocol
-
cipher
private java.lang.String cipher
-
id
private OpenSslSessionId id
-
creationTime
private long creationTime
-
lastAccessed
private long lastAccessed
-
applicationBufferSize
private volatile int applicationBufferSize
-
localCertificateChain
private volatile java.security.cert.Certificate[] localCertificateChain
-
keyValueStorage
private volatile java.util.Map<java.lang.String,java.lang.Object> keyValueStorage
-
-
Constructor Detail
-
DefaultOpenSslSession
DefaultOpenSslSession(OpenSslSessionContext sessionContext)
-
-
Method Detail
-
newSSLSessionBindingEvent
private javax.net.ssl.SSLSessionBindingEvent newSSLSessionBindingEvent(java.lang.String name)
-
prepareHandshake
public void prepareHandshake()
Description copied from interface:OpenSslInternalSessionCalled on a handshake session before being exposed to aTrustManager. Session data must be cleared by this call.- Specified by:
prepareHandshakein interfaceOpenSslInternalSession
-
setSessionDetails
public void setSessionDetails(long creationTime, long lastAccessedTime, OpenSslSessionId sessionId, java.util.Map<java.lang.String,java.lang.Object> keyValueStorage)Description copied from interface:OpenSslInternalSessionSet the details for the session which might come from a cache.- Specified by:
setSessionDetailsin interfaceOpenSslInternalSession- Parameters:
creationTime- the time at which the session was created.lastAccessedTime- the time at which the session was last accessed via the session infrastructure (cache).sessionId- theOpenSslSessionIdkeyValueStorage- the key value store. SeeOpenSslInternalSession.keyValueStorage().
-
keyValueStorage
public java.util.Map<java.lang.String,java.lang.Object> keyValueStorage()
Description copied from interface:OpenSslInternalSessionReturn the underlyingMapthat is used by the following methods:SSLSession.putValue(String, Object)SSLSession.removeValue(String)SSLSession.getValue(String)-
SSLSession.getValueNames()
Mapmust be thread-safe!- Specified by:
keyValueStoragein interfaceOpenSslInternalSession- Returns:
- storage
-
sessionId
public OpenSslSessionId sessionId()
Description copied from interface:OpenSslInternalSessionReturn theOpenSslSessionIdthat can be used to identify this session.- Specified by:
sessionIdin interfaceOpenSslInternalSession
-
setLocalCertificate
public void setLocalCertificate(java.security.cert.Certificate[] localCertificate)
Description copied from interface:OpenSslInternalSessionSet the local certificate chain that is used. It is not expected that this array will be changed at all and so its ok to not copy the array.- Specified by:
setLocalCertificatein interfaceOpenSslInternalSession
-
getId
public byte[] getId()
- Specified by:
getIdin interfacejavax.net.ssl.SSLSession
-
getSessionContext
public OpenSslSessionContext getSessionContext()
- Specified by:
getSessionContextin interfaceOpenSslSession- Specified by:
getSessionContextin interfacejavax.net.ssl.SSLSession
-
getCreationTime
public long getCreationTime()
- Specified by:
getCreationTimein interfacejavax.net.ssl.SSLSession
-
setLastAccessedTime
public void setLastAccessedTime(long time)
Description copied from interface:OpenSslInternalSessionSet the last access time which will be returned bySSLSession.getLastAccessedTime().- Specified by:
setLastAccessedTimein interfaceOpenSslInternalSession- Parameters:
time- the time
-
getLastAccessedTime
public long getLastAccessedTime()
- Specified by:
getLastAccessedTimein interfacejavax.net.ssl.SSLSession
-
invalidate
public void invalidate()
- Specified by:
invalidatein interfacejavax.net.ssl.SSLSession
-
isValid
public boolean isValid()
- Specified by:
isValidin interfacejavax.net.ssl.SSLSession
-
putValue
public void putValue(java.lang.String name, java.lang.Object value)- Specified by:
putValuein interfacejavax.net.ssl.SSLSession
-
getValue
public java.lang.Object getValue(java.lang.String name)
- Specified by:
getValuein interfacejavax.net.ssl.SSLSession
-
removeValue
public void removeValue(java.lang.String name)
- Specified by:
removeValuein interfacejavax.net.ssl.SSLSession
-
getValueNames
public java.lang.String[] getValueNames()
- Specified by:
getValueNamesin interfacejavax.net.ssl.SSLSession
-
notifyUnbound
private void notifyUnbound(java.lang.Object value, java.lang.String name)
-
handshakeFinished
public void handshakeFinished(byte[] id, java.lang.String cipher, java.lang.String protocol, byte[] peerCertificate, byte[][] peerCertificateChain, long creationTime, long timeout) throws javax.net.ssl.SSLExceptionFinish the handshake and so init everything in theOpenSslInternalSessionthat should be accessible by the user.- Specified by:
handshakeFinishedin interfaceOpenSslInternalSession- Throws:
javax.net.ssl.SSLException
-
initCerts
private void initCerts(byte[][] chain, int startPos)
-
getPeerCertificates
public java.security.cert.Certificate[] getPeerCertificates() throws javax.net.ssl.SSLPeerUnverifiedException- Specified by:
getPeerCertificatesin interfacejavax.net.ssl.SSLSession- Throws:
javax.net.ssl.SSLPeerUnverifiedException
-
hasPeerCertificates
public boolean hasPeerCertificates()
Description copied from interface:OpenSslSessionReturns true if the peer has provided certificates during the handshake.This method is similar to
SSLSession.getPeerCertificates()but it does not throw aSSLPeerUnverifiedExceptionif no certs are provided, making it more efficient to check if a mTLS connection is used.- Specified by:
hasPeerCertificatesin interfaceOpenSslSession- Returns:
- true if peer certificates are available.
-
getLocalCertificates
public java.security.cert.Certificate[] getLocalCertificates()
- Specified by:
getLocalCertificatesin interfacejavax.net.ssl.SSLSession
-
getPeerCertificateChain
public javax.security.cert.X509Certificate[] getPeerCertificateChain() throws javax.net.ssl.SSLPeerUnverifiedException- Specified by:
getPeerCertificateChainin interfacejavax.net.ssl.SSLSession- Throws:
javax.net.ssl.SSLPeerUnverifiedException
-
getPeerPrincipal
public java.security.Principal getPeerPrincipal() throws javax.net.ssl.SSLPeerUnverifiedException- Specified by:
getPeerPrincipalin interfacejavax.net.ssl.SSLSession- Throws:
javax.net.ssl.SSLPeerUnverifiedException
-
getLocalPrincipal
public java.security.Principal getLocalPrincipal()
- Specified by:
getLocalPrincipalin interfacejavax.net.ssl.SSLSession
-
getCipherSuite
public java.lang.String getCipherSuite()
- Specified by:
getCipherSuitein interfacejavax.net.ssl.SSLSession
-
getProtocol
public java.lang.String getProtocol()
- Specified by:
getProtocolin interfacejavax.net.ssl.SSLSession
-
getPeerHost
public java.lang.String getPeerHost()
- Specified by:
getPeerHostin interfacejavax.net.ssl.SSLSession
-
getPeerPort
public int getPeerPort()
- Specified by:
getPeerPortin interfacejavax.net.ssl.SSLSession
-
getPacketBufferSize
public int getPacketBufferSize()
- Specified by:
getPacketBufferSizein interfacejavax.net.ssl.SSLSession
-
getApplicationBufferSize
public int getApplicationBufferSize()
- Specified by:
getApplicationBufferSizein interfacejavax.net.ssl.SSLSession
-
tryExpandApplicationBufferSize
public void tryExpandApplicationBufferSize(int packetLengthDataOnly)
Description copied from interface:OpenSslInternalSessionExpand (or increase) the value returned bySSLSession.getApplicationBufferSize()if necessary.This is only called in a synchronized block, so no need to use atomic operations.
- Specified by:
tryExpandApplicationBufferSizein interfaceOpenSslInternalSession- Parameters:
packetLengthDataOnly- The packet size which exceeds the currentSSLSession.getApplicationBufferSize().
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
-