public final class DTLSSession extends Object implements Destroyable
| Modifier and Type | Field and Description |
|---|---|
static int |
DTLS_HEADER_LENGTH
The payload length of all headers around a DTLS handshake message payload.
|
static int |
HEADER_LENGTH
Deprecated.
use
DTLS_HEADER_LENGTH and RecordLayer.getMaxDatagramSize(boolean) instead. |
| Constructor and Description |
|---|
DTLSSession(InetSocketAddress peerAddress)
Creates a session using default values for all fields.
|
DTLSSession(InetSocketAddress peerAddress,
long initialSequenceNo)
Creates a new session initialized with a given sequence number.
|
DTLSSession(InetSocketAddress peerAddress,
long initialSequenceNo,
long creationTime)
Creates a new session initialized with a given sequence number.
|
DTLSSession(SessionId id,
InetSocketAddress peerAddress,
SessionTicket ticket,
long initialSequenceNo)
Creates a new session based on a given set of crypto params of another session
that is to be resumed.
|
| Modifier and Type | Method and Description |
|---|---|
void |
destroy() |
CipherSuite |
getCipherSuite()
Gets the cipher and MAC algorithm to be used for this session.
|
org.eclipse.californium.elements.DtlsEndpointContext |
getConnectionReadContext() |
org.eclipse.californium.elements.DtlsEndpointContext |
getConnectionWriteContext() |
long |
getCreationTime()
System time of session creation in milliseconds.
|
int |
getEffectiveFragmentLimit()
Gets effective fragment limit.
|
String |
getHostName()
Gets the (virtual) host name for the server that this session
has been established for.
|
String |
getLastHandshakeTime()
System time tag of last handshake.
|
int |
getMaxCiphertextExpansion()
Get maximum expansion of cipher suite.
|
int |
getMaxFragmentLength()
Gets the maximum amount of unencrypted payload data that can be sent to this session's
peer in a single DTLS record created under this session's current write state.
|
HandshakeParameter |
getParameter()
Return the handshake parameter, if set available.
|
InetSocketAddress |
getPeer()
Gets the IP address and socket of this session's peer.
|
Principal |
getPeerIdentity()
Gets the authenticated peer's identity.
|
ConnectionId |
getReadConnectionId()
Get connection id for inbound records.
|
int |
getReadEpoch()
Gets this session's current read epoch.
|
String |
getReadStateCipher()
Gets the name of the current read state's cipher suite.
|
Integer |
getRecordSizeLimit()
Gets the negotiated record size limit
|
InetSocketAddress |
getRouter()
Get router address.
|
long |
getSequenceNumber()
Gets the smallest unused sequence number for outbound records
for the current epoch.
|
long |
getSequenceNumber(int epoch)
Gets the smallest unused sequence number for outbound records
for a given epoch.
|
ServerNames |
getServerNames()
Gets the server names for the server that this session
has been established for.
|
SessionId |
getSessionIdentifier()
Gets this session's identifier.
|
SessionTicket |
getSessionTicket()
Get a session ticket representing this session's current
connection state.
|
SignatureAndHashAlgorithm |
getSignatureAndHashAlgorithm()
Gets the negotiated signature and hash algorithm to be used to sign the
server key exchange message.
|
Mac |
getThreadLocalClusterReadMac() |
Mac |
getThreadLocalClusterWriteMac() |
ConnectionId |
getWriteConnectionId()
Get connection id for outbound records.
|
int |
getWriteEpoch()
Gets this session's current write epoch.
|
String |
getWriteStateCipher()
Gets the name of the current write state's cipher suite.
|
boolean |
isDestroyed() |
boolean |
isMarkedAsClosed()
Session is marked as close.
|
boolean |
isRecordProcessable(long epoch,
long sequenceNo,
boolean useWindowOnly)
Deprecated.
use
isRecordProcessable(long, long, int) instead |
boolean |
isRecordProcessable(long epoch,
long sequenceNo,
int useExtendedWindow)
Checks whether a given record can be processed within the context of this
session.
|
boolean |
isSniSupported()
Checks whether the peer (the server) supports
the Server Name Indication extension.
|
void |
markCloseNotiy(int epoch,
long sequenceNo)
Mark as closed.
|
boolean |
markRecordAsRead(long epoch,
long sequenceNo)
Marks a record as having been received so that it can be detected as a
duplicate if it is received again, e.g.
|
void |
setHostName(String hostname)
Set the (virtual) host name for the server that this session has been
established for.
|
void |
setParameterAvailable()
Set parameter available.
|
void |
setPeer(InetSocketAddress peer) |
void |
setRouter(InetSocketAddress router)
Set router address.
|
void |
setServerNames(ServerNames serverNames)
Set the server names for the server that this session has been
established for.
|
public static final int DTLS_HEADER_LENGTH
@Deprecated public static final int HEADER_LENGTH
public DTLSSession(InetSocketAddress peerAddress)
peerAddress - the remote addresspublic DTLSSession(SessionId id, InetSocketAddress peerAddress, SessionTicket ticket, long initialSequenceNo)
The newly created session will have its pending state initialized with the given crypto params so that it can be used during the abbreviated handshake used to resume the session.
id - The identifier of the session to be resumed.peerAddress - The IP address and port of the client that wants to resume the session.ticket - The crypto params to use for the abbreviated handshakeinitialSequenceNo - The initial record sequence number to start from
in epoch 0. When starting a new handshake with a client that
has successfully exchanged a cookie with the server, the
sequence number to use in the SERVER_HELLO record MUST be the same as
the one from the successfully validated CLIENT_HELLO record
(see
section 4.2.1 of RFC 6347 (DTLS 1.2) for details)public DTLSSession(InetSocketAddress peerAddress, long initialSequenceNo)
peerAddress - the IP address and port of the peer this session is established withinitialSequenceNo - the initial record sequence number to start from
in epoch 0. When starting a new handshake with a client that
has successfully exchanged a cookie with the server, the
sequence number to use in the SERVER_HELLO record MUST be the same as
the one from the successfully validated CLIENT_HELLO record
(see
section 4.2.1 of RFC 6347 (DTLS 1.2) for details)public DTLSSession(InetSocketAddress peerAddress, long initialSequenceNo, long creationTime)
peerAddress - the IP address and port of the peer this session is established withinitialSequenceNo - the initial record sequence number to start from
in epoch 0. When starting a new handshake with a client that
has successfully exchanged a cookie with the server, the
sequence number to use in the SERVER_HELLO record MUST be the same as
the one from the successfully validated CLIENT_HELLO record
(see
section 4.2.1 of RFC 6347 (DTLS 1.2) for details)creationTime - creation time of session. Maybe from previous session on resumption.public void destroy()
throws DestroyFailedException
destroy in interface DestroyableDestroyFailedExceptionpublic boolean isDestroyed()
isDestroyed in interface Destroyablepublic SessionId getSessionIdentifier()
null if this session does not have an identifier (yet).public ConnectionId getWriteConnectionId()
null, if connection
id is not used by other peerpublic ConnectionId getReadConnectionId()
null, if connection
id is not used for other peerpublic Mac getThreadLocalClusterWriteMac()
public Mac getThreadLocalClusterReadMac()
public long getCreationTime()
System.currentTimeMillis()public String getLastHandshakeTime()
public String getHostName()
null if this session has not
been established for a virtual host.getServerNames()public void setHostName(String hostname)
Sets the setServerNames(ServerNames) accordingly.
hostname - the virtual host name at the peer (may be null).public ServerNames getServerNames()
null, if not used.getHostName()public void setServerNames(ServerNames serverNames)
Sets the setHostName(String) accordingly.
serverNames - the server names (may be null).public boolean isSniSupported()
true if the server has included
an empty SNI extension in its SERVER_HELLO
message during handshake.public org.eclipse.californium.elements.DtlsEndpointContext getConnectionWriteContext()
public org.eclipse.californium.elements.DtlsEndpointContext getConnectionReadContext()
public CipherSuite getCipherSuite()
The value returned is part of the pending connection state which
has been negotiated with the peer. This means that it is not in effect
until the pending state becomes the current state using
one of the setReadState(DTLSConnectionState)
or setWriteState(DTLSConnectionState) methods.
public int getWriteEpoch()
public int getReadEpoch()
public long getSequenceNumber()
IllegalStateException - if the maximum sequence number for the
epoch has been reached (2^48 - 1)public long getSequenceNumber(int epoch)
epoch - the epoch for which to get the sequence numberIllegalStateException - if the maximum sequence number for the
epoch has been reached (2^48 - 1)public String getReadStateCipher()
public String getWriteStateCipher()
public void setParameterAvailable()
getParameter() to return the
handshake parameter.public HandshakeParameter getParameter()
null, if
setParameterAvailable() wasn't called before.public int getMaxCiphertextExpansion()
CipherSuite.getMaxCiphertextExpansion()public int getMaxFragmentLength()
The value of this property serves as an upper boundary for the DTLSPlaintext.length field defined in DTLS 1.2 spec, Section 4.3.1. This means that an application can assume that any message containing at most as many bytes as indicated by this method, will be delivered to the peer in a single unfragmented IP datagram.
public Integer getRecordSizeLimit()
null, if not negotiatedpublic int getEffectiveFragmentLimit()
recordSizeLimit, if received, or
maxFragmentLength.public SignatureAndHashAlgorithm getSignatureAndHashAlgorithm()
public InetSocketAddress getPeer()
public void setPeer(InetSocketAddress peer)
public InetSocketAddress getRouter()
null, if no router is used.public void setRouter(InetSocketAddress router)
router - router addresspublic Principal getPeerIdentity()
null if the peer has not been
authenticated@Deprecated public boolean isRecordProcessable(long epoch, long sequenceNo, boolean useWindowOnly)
isRecordProcessable(long, long, int) insteadepoch - the record's epochsequenceNo - the record's sequence numberuseWindowOnly - true use only message window for filter. For
message too old for the message window true is
returned.true if the record satisfies the conditions abovepublic boolean isRecordProcessable(long epoch,
long sequenceNo,
int useExtendedWindow)
epoch - the record's epochsequenceNo - the record's sequence numberuseExtendedWindow - this value will be subtracted from to lower
receive window boundary. A value of -1 will set that
calculated value to 0. Messages between lower receive
window boundary and that calculated value will pass the
filter, for other messages the filter is applied.true if the record satisfies the conditions abovepublic boolean markRecordAsRead(long epoch,
long sequenceNo)
getReadEpoch().epoch - the record's epochsequenceNo - the record's sequence numbertrue, if the epoch/sequenceNo is newer than the current
newest. false, if not.public boolean isMarkedAsClosed()
true, if marked as closed, false, otherwise.public void markCloseNotiy(int epoch,
long sequenceNo)
epoch - epoch of close notifysequenceNo - sequence number of close notifyisMarkedAsClosed()public SessionTicket getSessionTicket()
null, if the session id is empty and
doesn't support resumption.IllegalStateException - if this session does not have its current
connection state set yet.Copyright © 2023 Eclipse Foundation. All rights reserved.