Class GenericPrincipalSerializer

    • Field Detail

      • JSON_PATTERN

        @Nonnull
        private static final Pattern JSON_PATTERN
        Pattern used to determine if input is supported.
      • log

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

        @Nonnull
        @NonnullElements
        private final Set<Class<? extends Principal>> compatiblePrincipalTypes
        A cache of Principal types that support string-based construction.
    • Constructor Detail

      • GenericPrincipalSerializer

        public GenericPrincipalSerializer()
        Constructor.
    • Method Detail

      • setSymbolics

        public void setSymbolics​(@Nonnull @NonnullElements
                                 Map<String,​Integer> mappings)
        Sets mappings of string constants to symbolic constants.
        Parameters:
        mappings - string to symbolic mappings
      • 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
      • 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 Principal 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
      • desymbolize

        @Nullable
        protected String desymbolize​(@Nonnull
                                     javax.json.JsonValue field)
        Map a field value to a string, either directly or via the symbolic map.
        Parameters:
        field - the object field to examine
        Returns:
        the resulting string, or null if invalid