public class AdvancedMultiPskStore extends Object implements AdvancedPskStore, Destroyable
AdvancedPskStore implementation supporting multiple peers.
If you don't need to initiate handshake/connection, you could just add
identity/key with setKey(String, byte[]) or
setKey(PskPublicInformation, byte[]). If you need to initiate
connection, you should add known peers with
addKnownPeer(InetSocketAddress, String, byte[]) or
addKnownPeer(InetSocketAddress, PskPublicInformation, byte[]).
If non-compliant encoded identities are used, please provide
PskPublicInformation.PskPublicInformation(String, byte[]) identities
with the non-compliant encoded bytes and the intended string.
To be used only for testing and evaluation. You are supposed to store your key in a secure way: keeping them in-memory is not a good idea.
| Constructor and Description |
|---|
AdvancedMultiPskStore() |
| Modifier and Type | Method and Description |
|---|---|
void |
addKnownPeer(InetSocketAddress peerAddress,
PskPublicInformation identity,
byte[] key)
Adds a shared key for a peer.
|
void |
addKnownPeer(InetSocketAddress peerAddress,
String identity,
byte[] key)
Adds a shared key for a peer.
|
void |
addKnownPeer(InetSocketAddress peerAddress,
String virtualHost,
PskPublicInformation identity,
byte[] key)
Adds a shared key for a virtual host on a peer.
|
void |
addKnownPeer(InetSocketAddress peerAddress,
String virtualHost,
String identity,
byte[] key)
Adds a shared key for a virtual host on a peer.
|
void |
destroy() |
PskPublicInformation |
getIdentity(InetSocketAddress peerAddress,
ServerNames virtualHost)
Gets the identity to use for a PSK based handshake with a given
peer.
|
boolean |
hasEcdhePskSupported()
Check, if ECDHE PSK cipher suites are supported.
|
boolean |
isDestroyed() |
void |
removeKey(PskPublicInformation identity)
Removes a key value for a given identity.
|
void |
removeKey(PskPublicInformation identity,
ServerName virtualHost)
Removes a key for an identity scoped to a virtual host.
|
void |
removeKey(PskPublicInformation identity,
String virtualHost)
Removes a key for an identity scoped to a virtual host.
|
void |
removeKey(String identity)
Removes a key value for a given identity.
|
void |
removeKey(String identity,
ServerName virtualHost)
Removes a key for an identity scoped to a virtual host.
|
void |
removeKey(String identity,
String virtualHost)
Removes a key for an identity scoped to a virtual host.
|
PskSecretResult |
requestPskSecretResult(ConnectionId cid,
ServerNames serverNames,
PskPublicInformation identity,
String hmacAlgorithm,
SecretKey otherSecret,
byte[] seed)
Request psk secret result.
|
void |
setKey(PskPublicInformation identity,
byte[] key)
Sets a key value for a given identity.
|
void |
setKey(PskPublicInformation identity,
byte[] key,
ServerName virtualHost)
Sets a key for an identity scoped to a virtual host.
|
void |
setKey(PskPublicInformation identity,
byte[] key,
String virtualHost)
Sets a key for an identity scoped to a virtual host.
|
void |
setKey(String identity,
byte[] key)
Sets a key value for a given identity.
|
void |
setKey(String identity,
byte[] key,
ServerName virtualHost)
Sets a key for an identity scoped to a virtual host.
|
void |
setKey(String identity,
byte[] key,
String virtualHost)
Sets a key for an identity scoped to a virtual host.
|
void |
setResultHandler(PskSecretResultHandler resultHandler)
Set the handler for asynchronous master secret results.
|
public boolean hasEcdhePskSupported()
AdvancedPskStorehasEcdhePskSupported in interface AdvancedPskStoretrue, if ECDHE PSK cipher suites are supported,
false, if not.public PskSecretResult requestPskSecretResult(ConnectionId cid, ServerNames serverNames, PskPublicInformation identity, String hmacAlgorithm, SecretKey otherSecret, byte[] seed)
AdvancedPskStorenull and process the request
asynchronously. The PskSecretResult must contain the CID, the
normalized identity and master secret or PSK secret key, if available. If
the result is not returned, it is passed asynchronously to the result
handler, provided during DTLSConnector initialization by
AdvancedPskStore.setResultHandler(PskSecretResultHandler).requestPskSecretResult in interface AdvancedPskStorecid - connection id for stateless asynchronous implementations.serverNames - server names. Maybe null, if SNI is not enabled
or not used by the client.identity - psk identity. Maybe normalized, if identity is available
in the store.hmacAlgorithm - HMAC algorithm name for PRF.otherSecret - other secret from ECDHE, or null. Must be
cloned for asynchronous use. See
RFC
5489, other secretseed - seed for PRF.null, if result is provided
asynchronous.public PskPublicInformation getIdentity(InetSocketAddress peerAddress, ServerNames virtualHost)
AdvancedPskStoreA DTLS client uses this method to determine the identity to include in its CLIENT_KEY_EXCHANGE message during a PSK based DTLS handshake with the peer.
getIdentity in interface AdvancedPskStorepeerAddress - The IP address and port of the peer to perform the
handshake with.virtualHost - The virtual host at the peer to connect to. If
null, the identity will be looked up in the
global scope.null if no peer with the given
address and virtual host is registered.public void setResultHandler(PskSecretResultHandler resultHandler)
AdvancedPskStoreDTLSConnector. Synchronous
implementations may just ignore this using an empty implementation.
Note: the type of the handler will change to HandshakeResultHandler with 3.0.setResultHandler in interface AdvancedPskStoreresultHandler - handler for asynchronous master secret results. This
handler MUST NOT be called from the thread calling
AdvancedPskStore.requestPskSecretResult(ConnectionId, ServerNames, PskPublicInformation, String, SecretKey, byte[]),
instead just return the result there.public void destroy()
throws DestroyFailedException
destroy in interface DestroyableDestroyFailedExceptionpublic boolean isDestroyed()
isDestroyed in interface Destroyablepublic void setKey(String identity, byte[] key)
If the key already exists, it will be replaced.
identity - the identity associated with the keykey - the key used to authenticate the identitysetKey(PskPublicInformation, byte[], ServerName)public void setKey(PskPublicInformation identity, byte[] key)
If the key already exists, it will be replaced.
identity - the identity associated with the keykey - the key used to authenticate the identitysetKey(PskPublicInformation, byte[], ServerName)public void setKey(String identity, byte[] key, String virtualHost)
If the key already exists, it will be replaced.
identity - The identity to set the key for.key - The key to set for the identity.virtualHost - The virtual host to associate the identity and key
with.setKey(PskPublicInformation, byte[], ServerName)public void setKey(PskPublicInformation identity, byte[] key, String virtualHost)
If the key already exists, it will be replaced.
identity - The identity to set the key for.key - The key to set for the identity.virtualHost - The virtual host to associate the identity and key
with.setKey(PskPublicInformation, byte[], ServerName)public void setKey(String identity, byte[] key, ServerName virtualHost)
If the key already exists, it will be replaced.
identity - The identity to set the key for.key - The key to set for the identity.virtualHost - The virtual host to associate the identity and key
with.setKey(PskPublicInformation, byte[], ServerName)public void setKey(PskPublicInformation identity, byte[] key, ServerName virtualHost)
If the key already exists, it will be replaced.
identity - The identity to set the key for.key - The key to set for the identity.virtualHost - The virtual host to associate the identity and key
with.setKey(String, byte[], ServerName)public void addKnownPeer(InetSocketAddress peerAddress, String identity, byte[] key)
If the key already exists, it will be replaced.
peerAddress - the IP address and port to use the key foridentity - the PSK identitykey - the shared keyNullPointerException - if any of the parameters are null.addKnownPeer(InetSocketAddress, PskPublicInformation, byte[])public void addKnownPeer(InetSocketAddress peerAddress, PskPublicInformation identity, byte[] key)
If the key already exists, it will be replaced.
peerAddress - the IP address and port to use the key foridentity - the PSK identitykey - the shared keyNullPointerException - if any of the parameters are null.addKnownPeer(InetSocketAddress, String, byte[])public void addKnownPeer(InetSocketAddress peerAddress, String virtualHost, String identity, byte[] key)
If the key already exists, it will be replaced. serverNames
peerAddress - the IP address and port to use the key forvirtualHost - the virtual host to use the key foridentity - the PSK identitykey - the shared keyNullPointerException - if any of the parameters are null.addKnownPeer(InetSocketAddress, String, PskPublicInformation,
byte[])public void addKnownPeer(InetSocketAddress peerAddress, String virtualHost, PskPublicInformation identity, byte[] key)
If the key already exists, it will be replaced. serverNames
peerAddress - the IP address and port to use the key forvirtualHost - the virtual host to use the key foridentity - the PSK identitykey - the shared keyNullPointerException - if any of the parameters are null.addKnownPeer(InetSocketAddress, String, String, byte[])public void removeKey(String identity)
identity - The identity to remove the key for.removeKey(PskPublicInformation, ServerName)public void removeKey(PskPublicInformation identity)
identity - The identity to remove the key for.removeKey(PskPublicInformation, ServerName)public void removeKey(String identity, String virtualHost)
identity - The identity to remove the key for.virtualHost - The virtual host to associate the identity and key
with.removeKey(PskPublicInformation, ServerName)public void removeKey(PskPublicInformation identity, String virtualHost)
identity - The identity to remove the key for.virtualHost - The virtual host to associate the identity and key
with.removeKey(PskPublicInformation, ServerName)public void removeKey(String identity, ServerName virtualHost)
identity - The identity to remove the key for.virtualHost - The virtual host to associate the identity with.removeKey(PskPublicInformation, ServerName)public void removeKey(PskPublicInformation identity, ServerName virtualHost)
identity - The identity to remove the key for.virtualHost - The virtual host to associate the identity with.Copyright © 2023 Eclipse Foundation. All rights reserved.