Class LegacyKeyManagerImpl<P>
- java.lang.Object
-
- com.google.crypto.tink.internal.LegacyKeyManagerImpl<P>
-
- All Implemented Interfaces:
KeyManager<P>
public class LegacyKeyManagerImpl<P> extends java.lang.Object implements KeyManager<P>
A composed KeyManager implements a KeyManager by accessing the internal specific registries.Tink offers
Registry.getKeyManagerin 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.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <P> KeyManager<P>create(java.lang.String typeUrl, java.lang.Class<P> primitiveClass, com.google.crypto.tink.proto.KeyData.KeyMaterialType keyMaterialType, com.google.protobuf.Parser<? extends com.google.protobuf.MessageLite> protobufKeyParser)static <P> PrivateKeyManager<P>createPrivateKeyManager(java.lang.String typeUrl, java.lang.Class<P> primitiveClass, com.google.protobuf.Parser<? extends com.google.protobuf.MessageLite> protobufKeyParser)booleandoesSupport(java.lang.String typeUrl)Returns true iff this KeyManager supports key type identified bytypeUrl.java.lang.StringgetKeyType()Returns the type URL that identifies the key type of keys managed by this KeyManager.PgetPrimitive(com.google.protobuf.ByteString serializedKey)Constructs an instance of P for the key given inserializedKey, which must be a serialized key protocol buffer handled by this manager.PgetPrimitive(com.google.protobuf.MessageLite key)Constructs an instance of P for the key given inkey.java.lang.Class<P>getPrimitiveClass()Returns the primitive class object of the P.intgetVersion()Returns the version number of this KeyManager.com.google.protobuf.MessageLitenewKey(com.google.protobuf.ByteString serializedKeyFormat)Generates a new key according to specification inserializedKeyFormat, which must be a serialized key format protocol buffer handled by this manager.com.google.protobuf.MessageLitenewKey(com.google.protobuf.MessageLite keyFormat)Generates a new key according to specification inkeyFormat.com.google.crypto.tink.proto.KeyDatanewKeyData(com.google.protobuf.ByteString serializedKeyFormat)Generates a newKeyDataaccording to specification inserializedKeyFormat.
-
-
-
Method Detail
-
create
public static <P> KeyManager<P> create(java.lang.String typeUrl, java.lang.Class<P> primitiveClass, com.google.crypto.tink.proto.KeyData.KeyMaterialType keyMaterialType, com.google.protobuf.Parser<? extends com.google.protobuf.MessageLite> protobufKeyParser)
-
getPrimitive
public P getPrimitive(com.google.protobuf.ByteString serializedKey) throws java.security.GeneralSecurityException
Description copied from interface:KeyManagerConstructs an instance of P for the key given inserializedKey, which must be a serialized key protocol buffer handled by this manager.For primitives of type
Mac,Aead,PublicKeySign,PublicKeyVerify,DeterministicAead,HybridEncrypt, andHybridDecryptthis should be a primitive which ignores the output prefix and assumes "RAW".- Specified by:
getPrimitivein interfaceKeyManager<P>- Returns:
- the new constructed P
- Throws:
java.security.GeneralSecurityException- if the key given inserializedKeyis corrupted or not supported
-
getPrimitive
public final P getPrimitive(com.google.protobuf.MessageLite key) throws java.security.GeneralSecurityException
Description copied from interface:KeyManagerConstructs an instance of P for the key given inkey.For primitives of type
Mac,Aead,PublicKeySign,PublicKeyVerify,DeterministicAead,HybridEncrypt, andHybridDecryptthis 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.
- Specified by:
getPrimitivein interfaceKeyManager<P>- Returns:
- the new constructed P
- Throws:
java.security.GeneralSecurityException- if the key given inkeyis corrupted or not supported
-
newKey
public final com.google.protobuf.MessageLite newKey(com.google.protobuf.ByteString serializedKeyFormat) throws java.security.GeneralSecurityExceptionDescription copied from interface:KeyManagerGenerates a new key according to specification inserializedKeyFormat, 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.
- Specified by:
newKeyin interfaceKeyManager<P>- Returns:
- the new generated key
- Throws:
java.security.GeneralSecurityException- if the specified format is wrong or not supported
-
newKey
public final com.google.protobuf.MessageLite newKey(com.google.protobuf.MessageLite keyFormat) throws java.security.GeneralSecurityExceptionDescription copied from interface:KeyManagerGenerates a new key according to specification inkeyFormat.This method is only used by
Registry.newKeywhich is deprecated and not used by Tink anymore. This method does not need to be implemented.- Specified by:
newKeyin interfaceKeyManager<P>- Returns:
- the new generated key
- Throws:
java.security.GeneralSecurityException- if the specified format is wrong or not supported
-
doesSupport
public final boolean doesSupport(java.lang.String typeUrl)
Description copied from interface:KeyManagerReturns true iff this KeyManager supports key type identified bytypeUrl.This method is not used by Tink anymore. It does not need to be implemented.
- Specified by:
doesSupportin interfaceKeyManager<P>
-
getKeyType
public final java.lang.String getKeyType()
Description copied from interface:KeyManagerReturns the type URL that identifies the key type of keys managed by this KeyManager.- Specified by:
getKeyTypein interfaceKeyManager<P>
-
getVersion
public int getVersion()
Description copied from interface:KeyManagerReturns the version number of this KeyManager.This method is not used by Tink anymore. It does not need to be implemented.
- Specified by:
getVersionin interfaceKeyManager<P>
-
newKeyData
public final com.google.crypto.tink.proto.KeyData newKeyData(com.google.protobuf.ByteString serializedKeyFormat) throws java.security.GeneralSecurityExceptionDescription copied from interface:KeyManagerGenerates a newKeyDataaccording to specification inserializedKeyFormat.- Specified by:
newKeyDatain interfaceKeyManager<P>- Returns:
- the new generated key
- Throws:
java.security.GeneralSecurityException- if the specified format is wrong or not supported
-
getPrimitiveClass
public final java.lang.Class<P> getPrimitiveClass()
Description copied from interface:KeyManagerReturns the primitive class object of the P. Should be implemented asreturn P.class;when implementing a key manager for primitive {$code P}.- Specified by:
getPrimitiveClassin interfaceKeyManager<P>- Returns:
P.class
-
createPrivateKeyManager
public static <P> PrivateKeyManager<P> createPrivateKeyManager(java.lang.String typeUrl, java.lang.Class<P> primitiveClass, com.google.protobuf.Parser<? extends com.google.protobuf.MessageLite> protobufKeyParser)
-
-