Class MutablePrimitiveRegistry
- java.lang.Object
-
- com.google.crypto.tink.internal.MutablePrimitiveRegistry
-
public final class MutablePrimitiveRegistry extends java.lang.ObjectA Mutable version of thePrimitiveRegistry.This class probably shouldn't exist; it would be better if we had only the PrimitiveRegistry. However, at the moment, we need this, since a call to e.g.
AesCmacKeyManager.register()
should register such an object into a global, mutable registry.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <KeyT extends Key,PrimitiveT>
PrimitiveTgetPrimitive(KeyT key, java.lang.Class<PrimitiveT> primitiveClass)Creates a primitive from a given key.static MutablePrimitiveRegistryglobalInstance()<KeyT extends Key,PrimitiveT>
voidregisterPrimitiveConstructor(PrimitiveConstructor<KeyT,PrimitiveT> constructor)Registers a key primitive constructor for later use ingetPrimitive(KeyT, java.lang.Class<PrimitiveT>).<InputPrimitiveT,WrapperPrimitiveT>
voidregisterPrimitiveWrapper(PrimitiveWrapper<InputPrimitiveT,WrapperPrimitiveT> wrapper)static voidresetGlobalInstanceTestOnly()<WrapperPrimitiveT>
WrapperPrimitiveTwrap(KeysetHandleInterface keysetHandle, MonitoringAnnotations annotations, java.lang.Class<WrapperPrimitiveT> wrapperClassObject)
-
-
-
Method Detail
-
globalInstance
public static MutablePrimitiveRegistry globalInstance()
-
resetGlobalInstanceTestOnly
public static void resetGlobalInstanceTestOnly()
-
registerPrimitiveConstructor
public <KeyT extends Key,PrimitiveT> void registerPrimitiveConstructor(PrimitiveConstructor<KeyT,PrimitiveT> constructor) throws java.security.GeneralSecurityException
Registers a key primitive constructor for later use ingetPrimitive(KeyT, java.lang.Class<PrimitiveT>).This registers a primitive constructor which can later be used to create a primitive by calling
getPrimitive(KeyT, java.lang.Class<PrimitiveT>). If a constructor for the pair(KeyT, PrimitiveT)has already been registered and is the same, then the call is ignored; otherwise, an exception is thrown.- Throws:
java.security.GeneralSecurityException
-
registerPrimitiveWrapper
public <InputPrimitiveT,WrapperPrimitiveT> void registerPrimitiveWrapper(PrimitiveWrapper<InputPrimitiveT,WrapperPrimitiveT> wrapper) throws java.security.GeneralSecurityException
- Throws:
java.security.GeneralSecurityException
-
getPrimitive
public <KeyT extends Key,PrimitiveT> PrimitiveT getPrimitive(KeyT key, java.lang.Class<PrimitiveT> primitiveClass) throws java.security.GeneralSecurityException
Creates a primitive from a given key.This will look up a previously registered constructor for the given pair of
(KeyT, PrimitiveT), and, if successful, use the registered PrimitiveConstructor object to create the requested primitive. Throws if the required constructor has not been registered, or if the primitive construction threw.- Throws:
java.security.GeneralSecurityException
-
wrap
public <WrapperPrimitiveT> WrapperPrimitiveT wrap(KeysetHandleInterface keysetHandle, MonitoringAnnotations annotations, java.lang.Class<WrapperPrimitiveT> wrapperClassObject) throws java.security.GeneralSecurityException
- Throws:
java.security.GeneralSecurityException
-
-