Class SerializationRegistry


  • public final class SerializationRegistry
    extends java.lang.Object
    Allows registering KeySerializer, KeyParser, ParametersSerializer, and ParametersParser objects, and parsing/serializing keys and key formats with such objects.
    • Method Detail

      • hasParserForKey

        public boolean hasParserForKey​(ProtoKeySerialization serializedKey)
        Returns true if a parser for this serializedKey has been registered.
      • parseKey

        public Key parseKey​(ProtoKeySerialization serializedKey,
                            @Nullable
                            SecretKeyAccess access)
                     throws java.security.GeneralSecurityException
        Parses the given serialization into a Key.

        This will look up a previously registered parser for the passed in SerializationT class, and the used object identifier (as indicated by serializedKey.getObjectIdentifier()), and then parse the object with this parsers.

        Throws:
        java.security.GeneralSecurityException
      • hasSerializerForKey

        public <KeyT extends Key> boolean hasSerializerForKey​(KeyT key,
                                                              java.lang.Class<?> serializationClass)
        Returns true if a parser for this serializedKey has been registered.
      • serializeKey

        public <KeyT extends Key> ProtoKeySerialization serializeKey​(KeyT key,
                                                                     @Nullable
                                                                     SecretKeyAccess access)
                                                              throws java.security.GeneralSecurityException
        Serializes a given Key into a "SerializationT" object.

        This will look up a previously registered serializer for the requested SerializationT class and the passed in key type, and then call serializeKey on the result.

        Throws:
        java.security.GeneralSecurityException
      • hasParserForParameters

        public boolean hasParserForParameters​(ProtoParametersSerialization serializedParameters)
        Returns true if a parser for this serializedKey has been registered.
      • parseParameters

        public Parameters parseParameters​(ProtoParametersSerialization serializedParameters)
                                   throws java.security.GeneralSecurityException
        Parses the given serialization into a Parameters.

        This will look up a previously registered parser for the passed in SerializationT class, and the used object identifier (as indicated by serializedKey.getObjectIdentifier()), and then parse the object with this parsers.

        Throws:
        java.security.GeneralSecurityException
      • hasSerializerForParameters

        public <ParametersT extends Parameters> boolean hasSerializerForParameters​(ParametersT parameters,
                                                                                   java.lang.Class<?> serializationClass)
        Returns true if a parser for this serializedKey has been registered.
      • serializeParameters

        public <ParametersT extends Parameters> ProtoParametersSerialization serializeParameters​(ParametersT parameters)
                                                                                          throws java.security.GeneralSecurityException
        Serializes a given Parameters object into a "SerializationT" object.

        This will look up a previously registered serializer for the requested SerializationT class and the passed in key type, and then call serializeKey on the result.

        Throws:
        java.security.GeneralSecurityException