Class MutablePrimitiveRegistry


  • public final class MutablePrimitiveRegistry
    extends java.lang.Object
    A Mutable version of the PrimitiveRegistry.

    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 Detail

      • 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 in getPrimitive(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