Class SimplePrincipalSerializer<T extends Principal>

    • Field Detail

      • log

        @Nonnull
        private final org.slf4j.Logger log
        Class logger.
      • principalType

        @Nonnull
        private final Class<T extends Principal> principalType
        Principal type.
      • jsonPattern

        @Nonnull
        private final Pattern jsonPattern
        Pattern used to determine if input is supported.
    • Method Detail

      • supports

        public boolean supports​(@Nonnull
                                Principal principal)
        Whether the supplied principal can be serialized.
        Parameters:
        principal - to examine
        Returns:
        whether principal can be serialized
      • serialize

        @Nonnull
        @NotEmpty
        public String serialize​(@Nonnull
                                Principal principal)
                         throws IOException
        Serialize the supplied principal.
        Parameters:
        principal - to serialize
        Returns:
        serialized value
        Throws:
        IOException - if an error occurs during serialization
      • getName

        @Nonnull
        @NotEmpty
        protected String getName​(@Nonnull
                                 Principal principal)
                          throws IOException
        Return the appropriate value to serialize from the input object.
        Parameters:
        principal - input object
        Returns:
        the value to serialize.
        Throws:
        IOException - if an error occurs
      • supports

        public boolean supports​(@Nonnull @NotEmpty
                                String value)
        Whether the supplied value can be deserialized.
        Parameters:
        value - to examine
        Returns:
        whether value can be deserialized
      • deserialize

        @Nullable
        public T deserialize​(@Nonnull @NotEmpty
                             String value)
                      throws IOException
        Deserialize the supplied value.
        Parameters:
        value - to deserialize
        Returns:
        principal
        Throws:
        IOException - if an error occurs during deserialization
      • getName

        @Nullable
        protected String getName​(@Nullable
                                 String serializedName)
                          throws IOException
        Return the appropriate value to create the Principal around based on the serialized form.
        Parameters:
        serializedName - the value in the serialization.
        Returns:
        the transformed value
        Throws:
        IOException - if an error occurs