@Alpha public class KeyManagerImpl<PrimitiveT,KeyProtoT extends com.google.protobuf.MessageLite> extends Object implements KeyManager<PrimitiveT>
KeyManager interface based on an KeyTypeManager.
Choosing PrimitiveT equal to Void is valid; in this case the
functions getPrimitive(com.google.protobuf.ByteString) will throw if invoked.
TODO(tholenst): Visibility restrict to package visibility once all key managers are migrated to KeyTypeManager's.
| Constructor and Description |
|---|
KeyManagerImpl(KeyTypeManager<KeyProtoT> keyTypeManager,
Class<PrimitiveT> primitiveClass) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
doesSupport(String typeUrl) |
String |
getKeyType() |
PrimitiveT |
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. |
PrimitiveT |
getPrimitive(com.google.protobuf.MessageLite key)
Constructs an instance of P for the key given in
key. |
Class<PrimitiveT> |
getPrimitiveClass()
Returns the primitive class object of the P.
|
int |
getVersion() |
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. |
com.google.crypto.tink.proto.KeyData |
newKeyData(com.google.protobuf.ByteString serializedKeyFormat)
Generates a new
KeyData according to specification in serializedkeyFormat. |
public KeyManagerImpl(KeyTypeManager<KeyProtoT> keyTypeManager, Class<PrimitiveT> primitiveClass)
public final PrimitiveT getPrimitive(com.google.protobuf.ByteString serializedKey) throws GeneralSecurityException
KeyManagerserializedKey, which must be a
serialized key protocol buffer handled by this manager.getPrimitive in interface KeyManager<PrimitiveT>GeneralSecurityException - if the key given in serializedKey is corrupted or not
supportedpublic final PrimitiveT getPrimitive(com.google.protobuf.MessageLite key) throws GeneralSecurityException
KeyManagerkey.getPrimitive in interface KeyManager<PrimitiveT>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.newKey in interface KeyManager<PrimitiveT>GeneralSecurityException - if the specified format is wrong or not supportedpublic final com.google.protobuf.MessageLite newKey(com.google.protobuf.MessageLite keyFormat)
throws GeneralSecurityException
KeyManagerkeyFormat.newKey in interface KeyManager<PrimitiveT>GeneralSecurityException - if the specified format is wrong or not supportedpublic final boolean doesSupport(String typeUrl)
doesSupport in interface KeyManager<PrimitiveT>typeUrl.public final String getKeyType()
getKeyType in interface KeyManager<PrimitiveT>public int getVersion()
getVersion in interface KeyManager<PrimitiveT>public final com.google.crypto.tink.proto.KeyData newKeyData(com.google.protobuf.ByteString serializedKeyFormat)
throws GeneralSecurityException
KeyManagerKeyData according to specification in serializedkeyFormat.
This should be used solely by KeysetManager.
newKeyData in interface KeyManager<PrimitiveT>GeneralSecurityException - if the specified format is wrong or not supportedpublic final Class<PrimitiveT> getPrimitiveClass()
KeyManagerreturn P.class;
when implementing a key manager for primitive {$code P}.getPrimitiveClass in interface KeyManager<PrimitiveT>P.class