Package org.conscrypt
Class DuckTypedPSKKeyManager
- java.lang.Object
-
- org.conscrypt.DuckTypedPSKKeyManager
-
- All Implemented Interfaces:
KeyManager,PSKKeyManager
public class DuckTypedPSKKeyManager extends Object implements PSKKeyManager
Reflection-basedPSKKeyManageradaptor for objects which expose all the methods of thePSKKeyManagerinterface but do not implement the interface.This is expected to be useful on platforms where there are multiple instances of the
PSKKeyManagerinterface.
-
-
Field Summary
-
Fields inherited from interface org.conscrypt.PSKKeyManager
MAX_IDENTITY_HINT_LENGTH_BYTES, MAX_IDENTITY_LENGTH_BYTES, MAX_KEY_LENGTH_BYTES
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringchooseClientKeyIdentity(String identityHint, Socket socket)Gets the PSK identity to report to the server to help agree on the PSK for the provided socket.StringchooseClientKeyIdentity(String identityHint, SSLEngine engine)Gets the PSK identity to report to the server to help agree on the PSK for the provided engine.StringchooseServerKeyIdentityHint(Socket socket)Gets the PSK identity hint to report to the client to help agree on the PSK for the provided socket.StringchooseServerKeyIdentityHint(SSLEngine engine)Gets the PSK identity hint to report to the client to help agree on the PSK for the provided engine.static DuckTypedPSKKeyManagergetInstance(Object obj)Gets an instance ofDuckTypedPSKKeyManagerwhich delegates all invocations of methods of thePSKKeyManagerinterface to the same methods of the provided object.SecretKeygetKey(String identityHint, String identity, Socket socket)Gets the PSK to use for the provided socket.SecretKeygetKey(String identityHint, String identity, SSLEngine engine)Gets the PSK to use for the provided engine.
-
-
-
Method Detail
-
getInstance
public static DuckTypedPSKKeyManager getInstance(Object obj) throws NoSuchMethodException
Gets an instance ofDuckTypedPSKKeyManagerwhich delegates all invocations of methods of thePSKKeyManagerinterface to the same methods of the provided object.- Throws:
NoSuchMethodException- ifobjdoes not implement a method of thePSKKeyManagerinterface.
-
chooseServerKeyIdentityHint
public String chooseServerKeyIdentityHint(Socket socket)
Description copied from interface:PSKKeyManagerGets the PSK identity hint to report to the client to help agree on the PSK for the provided socket.- Specified by:
chooseServerKeyIdentityHintin interfacePSKKeyManager- Returns:
- PSK identity hint to be provided to the client or
nullto provide no hint.
-
chooseServerKeyIdentityHint
public String chooseServerKeyIdentityHint(SSLEngine engine)
Description copied from interface:PSKKeyManagerGets the PSK identity hint to report to the client to help agree on the PSK for the provided engine.- Specified by:
chooseServerKeyIdentityHintin interfacePSKKeyManager- Returns:
- PSK identity hint to be provided to the client or
nullto provide no hint.
-
chooseClientKeyIdentity
public String chooseClientKeyIdentity(String identityHint, Socket socket)
Description copied from interface:PSKKeyManagerGets the PSK identity to report to the server to help agree on the PSK for the provided socket.- Specified by:
chooseClientKeyIdentityin interfacePSKKeyManager- Parameters:
identityHint- identity hint provided by the server ornullif none provided.- Returns:
- PSK identity to provide to the server.
nullis permitted but will be converted into an empty string.
-
chooseClientKeyIdentity
public String chooseClientKeyIdentity(String identityHint, SSLEngine engine)
Description copied from interface:PSKKeyManagerGets the PSK identity to report to the server to help agree on the PSK for the provided engine.- Specified by:
chooseClientKeyIdentityin interfacePSKKeyManager- Parameters:
identityHint- identity hint provided by the server ornullif none provided.- Returns:
- PSK identity to provide to the server.
nullis permitted but will be converted into an empty string.
-
getKey
public SecretKey getKey(String identityHint, String identity, Socket socket)
Description copied from interface:PSKKeyManagerGets the PSK to use for the provided socket.- Specified by:
getKeyin interfacePSKKeyManager- Parameters:
identityHint- identity hint provided by the server to help select the key ornullif none provided.identity- identity provided by the client to help select the key.- Returns:
- key or
nullto signal to peer that no suitable key is available and to abort the handshake.
-
getKey
public SecretKey getKey(String identityHint, String identity, SSLEngine engine)
Description copied from interface:PSKKeyManagerGets the PSK to use for the provided engine.- Specified by:
getKeyin interfacePSKKeyManager- Parameters:
identityHint- identity hint provided by the server to help select the key ornullif none provided.identity- identity provided by the client to help select the key.- Returns:
- key or
nullto signal to peer that no suitable key is available and to abort the handshake.
-
-