public class LegacyKeyManagerImpl<P> extends Object implements KeyManager<P>
Tink offers Registry.getKeyManager in the public API. While this shouldn't be used by
users, we still want to be backwards compatible for users which use it.
In this class we use the global instances of the following classes to implement the KeyManager interface.
| Modifier and Type | Method and Description |
|---|---|
static <P> KeyManager<P> |
create(String typeUrl,
Class<P> primitiveClass,
KeyData.KeyMaterialType keyMaterialType,
com.google.protobuf.Parser<? extends com.google.protobuf.MessageLite> protobufKeyParser) |
static <P> PrivateKeyManager<P> |
createPrivateKeyManager(String typeUrl,
Class<P> primitiveClass,
com.google.protobuf.Parser<? extends com.google.protobuf.MessageLite> protobufKeyParser) |
boolean |
doesSupport(String typeUrl)
Returns true iff this KeyManager supports key type identified by
typeUrl. |
String |
getKeyType()
Returns the type URL that identifies the key type of keys managed by this KeyManager.
|
P |
getPrimitive(com.google.protobuf.ByteString serializedKey)
Constructs an instance of P for the key given in
serializedKey, which must be a
serialized key protocol buffer handled by this manager. |
P |
getPrimitive(com.google.protobuf.MessageLite key)
Constructs an instance of P for the key given in
key. |
Class<P> |
getPrimitiveClass()
Returns the primitive class object of the P.
|
int |
getVersion()
Returns the version number of this KeyManager.
|
com.google.protobuf.MessageLite |
newKey(com.google.protobuf.ByteString serializedKeyFormat)
Generates a new key according to specification in
serializedKeyFormat, which must be a
serialized key format protocol buffer handled by this manager. |
com.google.protobuf.MessageLite |
newKey(com.google.protobuf.MessageLite keyFormat)
Generates a new key according to specification in
keyFormat. |
KeyData |
newKeyData(com.google.protobuf.ByteString serializedKeyFormat)
Generates a new
KeyData according to specification in serializedKeyFormat. |
public static <P> KeyManager<P> create(String typeUrl, Class<P> primitiveClass, KeyData.KeyMaterialType keyMaterialType, com.google.protobuf.Parser<? extends com.google.protobuf.MessageLite> protobufKeyParser)
public P getPrimitive(com.google.protobuf.ByteString serializedKey) throws GeneralSecurityException
KeyManagerserializedKey, which must be a
serialized key protocol buffer handled by this manager.
For primitives of type Mac, Aead, PublicKeySign, PublicKeyVerify, DeterministicAead, HybridEncrypt, and HybridDecrypt
this should be a primitive which ignores the output prefix and assumes "RAW".
getPrimitive in interface KeyManager<P>GeneralSecurityException - if the key given in serializedKey is corrupted or not
supportedpublic final P getPrimitive(com.google.protobuf.MessageLite key) throws GeneralSecurityException
KeyManagerkey.
For primitives of type Mac, Aead, PublicKeySign, PublicKeyVerify, DeterministicAead, HybridEncrypt, and HybridDecrypt
this should be a primitive which ignores the output prefix and assumes "RAW".
This method is not used by Tink. It does not need to be implemented.
getPrimitive in interface KeyManager<P>GeneralSecurityException - if the key given in key is corrupted or not supportedpublic final com.google.protobuf.MessageLite newKey(com.google.protobuf.ByteString serializedKeyFormat)
throws GeneralSecurityException
KeyManagerserializedKeyFormat, which must be a
serialized key format protocol buffer handled by this manager.
This method is not used by Tink anymore. It does not need to be implemented.
newKey in interface KeyManager<P>GeneralSecurityException - if the specified format is wrong or not supportedpublic final com.google.protobuf.MessageLite newKey(com.google.protobuf.MessageLite keyFormat)
throws GeneralSecurityException
KeyManagerkeyFormat.
This method is only used by Registry.newKey which is deprecated and not used by Tink
anymore. This method does not need to be implemented.
newKey in interface KeyManager<P>GeneralSecurityException - if the specified format is wrong or not supportedpublic final boolean doesSupport(String typeUrl)
KeyManagertypeUrl.
This method is not used by Tink anymore. It does not need to be implemented.
doesSupport in interface KeyManager<P>public final String getKeyType()
KeyManagergetKeyType in interface KeyManager<P>public int getVersion()
KeyManagerThis method is not used by Tink anymore. It does not need to be implemented.
getVersion in interface KeyManager<P>public final KeyData newKeyData(com.google.protobuf.ByteString serializedKeyFormat) throws GeneralSecurityException
KeyManagerKeyData according to specification in serializedKeyFormat.newKeyData in interface KeyManager<P>GeneralSecurityException - if the specified format is wrong or not supportedpublic final Class<P> getPrimitiveClass()
KeyManagerreturn P.class;
when implementing a key manager for primitive {$code P}.getPrimitiveClass in interface KeyManager<P>P.classpublic static <P> PrivateKeyManager<P> createPrivateKeyManager(String typeUrl, Class<P> primitiveClass, com.google.protobuf.Parser<? extends com.google.protobuf.MessageLite> protobufKeyParser)