Class Algorithm

  • All Implemented Interfaces:
    java.io.Serializable
    Direct Known Subclasses:
    EncryptionMethod, JWEAlgorithm, JWSAlgorithm

    @Immutable
    public class Algorithm
    extends java.lang.Object
    implements java.io.Serializable
    The base class for algorithm names, with optional implementation requirement. This class is immutable.

    Includes constants for the following standard algorithm names:

    Version:
    2020-06-03
    Author:
    Vladimir Dzhuvinov
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Algorithm NONE
      No algorithm (unsecured JOSE object without signature / encryption).
    • Constructor Summary

      Constructors 
      Constructor Description
      Algorithm​(java.lang.String name)
      Creates a new JOSE algorithm name.
      Algorithm​(java.lang.String name, Requirement req)
      Creates a new JOSE algorithm name.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object object)
      Overrides Object.equals().
      java.lang.String getName()
      Gets the name of this algorithm.
      Requirement getRequirement()
      Gets the implementation requirement of this algorithm.
      int hashCode()
      Overrides Object.hashCode().
      static Algorithm parse​(java.lang.String s)
      Parses an optional algorithm.
      java.lang.String toJSONString()
      Returns the JSON string representation of this algorithm.
      java.lang.String toString()
      Returns the string representation of this algorithm.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • NONE

        public static final Algorithm NONE
        No algorithm (unsecured JOSE object without signature / encryption).
    • Constructor Detail

      • Algorithm

        public Algorithm​(java.lang.String name,
                         Requirement req)
        Creates a new JOSE algorithm name.
        Parameters:
        name - The algorithm name. Must not be null.
        req - The implementation requirement, null if not known.
      • Algorithm

        public Algorithm​(java.lang.String name)
        Creates a new JOSE algorithm name.
        Parameters:
        name - The algorithm name. Must not be null.
    • Method Detail

      • getName

        public final java.lang.String getName()
        Gets the name of this algorithm.
        Returns:
        The algorithm name.
      • getRequirement

        public final Requirement getRequirement()
        Gets the implementation requirement of this algorithm.
        Returns:
        The implementation requirement, null if not known.
      • hashCode

        public final int hashCode()
        Overrides Object.hashCode().
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        The object hash code.
      • equals

        public boolean equals​(java.lang.Object object)
        Overrides Object.equals().
        Overrides:
        equals in class java.lang.Object
        Parameters:
        object - The object to compare to.
        Returns:
        true if the objects have the same value, otherwise false.
      • toString

        public final java.lang.String toString()
        Returns the string representation of this algorithm.
        Overrides:
        toString in class java.lang.Object
        Returns:
        The string representation.
        See Also:
        getName()
      • toJSONString

        public final java.lang.String toJSONString()
        Returns the JSON string representation of this algorithm.
        Returns:
        The JSON string representation.
      • parse

        public static Algorithm parse​(java.lang.String s)
        Parses an optional algorithm.
        Parameters:
        s - The string to parse. May be null.
        Returns:
        The JOSE algorithm, null if not specified.