Package org.forgerock.json.jose.jws
Enum JwsAlgorithm
- java.lang.Object
-
- java.lang.Enum<JwsAlgorithm>
-
- org.forgerock.json.jose.jws.JwsAlgorithm
-
- All Implemented Interfaces:
Serializable
,Comparable<JwsAlgorithm>
,Algorithm
public enum JwsAlgorithm extends Enum<JwsAlgorithm> implements Algorithm
An Enum of the possible signing algorithms that can be used to sign a JWT.- Since:
- 2.0.0
- See Also:
- JWS Algorithms
-
-
Enum Constant Summary
Enum Constants Enum Constant Description EDDSA
Edwards Curve DSA (EdDSA), as defined in RFC 8037.ES256
ECDSA using SHA-256 hash algorithm.ES384
ECDSA using SHA-384 hash algorithm.ES512
ECDSA using SHA-512 hash algorithm.HS256
HMAC using SHA-256 hash algorithm.HS384
HMAC using SHA-384 hash algorithm.HS512
HMAC using SHA-512 hash algorithm.NONE
Deprecated.This algorithm is inherently insecure and should not be used.PS256
RSA-PSS with SHA-256 hash algorithm.PS384
RSA-PSS with SHA-384 hash algorithm.PS512
RSA-PSS with SHA-512 hash algorithm.RS256
RSA using SHA-256 hash algorithm.RS384
RSA using SHA-384 hash algorithm.RS512
RSA using SHA-512 hash algorithm.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
getAlgorithm()
Gets the actual name of the algorithm that is understood by Java cryptographic operations.JwsAlgorithmType
getAlgorithmType()
Gets the JwsAlgorithmType of the JwsAlgorithm.String
getEllipticCurveName()
Return the standard name of the elliptic curve definition.String
getJwaAlgorithmName()
Gets the name of the algorithm as defined in the JWA standard.static JwsAlgorithm
getJwsAlgorithm(String algorithm)
Deprecated.Replaced byparseCryptographicAlgorithm(String)
String
getMdAlgorithm()
Returns the Java-friendly name of the message digest algorithm implementation.AlgorithmParameterSpec
getParameterSpec()
Gets any parameter spec associated with this algorithm.boolean
isSymmetric()
Indicates whether the algorithm is a symmetric (secret key) algorithm like HMAC or a public key algorithm.static JwsAlgorithm
parseAlgorithm(String algorithm)
Parses the given algorithm string to find the matching JwsAlgorithm enum constant.static JwsAlgorithm
parseCryptographicAlgorithm(String algorithm)
Parses the given algorithm string to find the matching Java Cryptographic algorithm name.String
toString()
Turns the JwsAlgorithm constant into a JSON value string.static JwsAlgorithm
valueOf(String name)
Returns the enum constant of this type with the specified name.static JwsAlgorithm[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
NONE
@Deprecated public static final JwsAlgorithm NONE
Deprecated.This algorithm is inherently insecure and should not be used.No digital signature or MAC value included.
-
HS256
public static final JwsAlgorithm HS256
HMAC using SHA-256 hash algorithm.
-
HS384
public static final JwsAlgorithm HS384
HMAC using SHA-384 hash algorithm.
-
HS512
public static final JwsAlgorithm HS512
HMAC using SHA-512 hash algorithm.
-
RS256
public static final JwsAlgorithm RS256
RSA using SHA-256 hash algorithm.
-
RS384
public static final JwsAlgorithm RS384
RSA using SHA-384 hash algorithm.
-
RS512
public static final JwsAlgorithm RS512
RSA using SHA-512 hash algorithm.
-
ES256
public static final JwsAlgorithm ES256
ECDSA using SHA-256 hash algorithm.
-
ES384
public static final JwsAlgorithm ES384
ECDSA using SHA-384 hash algorithm.
-
ES512
public static final JwsAlgorithm ES512
ECDSA using SHA-512 hash algorithm.
-
PS256
public static final JwsAlgorithm PS256
RSA-PSS with SHA-256 hash algorithm.
-
PS384
public static final JwsAlgorithm PS384
RSA-PSS with SHA-384 hash algorithm.
-
PS512
public static final JwsAlgorithm PS512
RSA-PSS with SHA-512 hash algorithm.
-
EDDSA
public static final JwsAlgorithm EDDSA
Edwards Curve DSA (EdDSA), as defined in RFC 8037.
-
-
Method Detail
-
values
public static JwsAlgorithm[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (JwsAlgorithm c : JwsAlgorithm.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static JwsAlgorithm valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
getAlgorithm
public String getAlgorithm()
Description copied from interface:Algorithm
Gets the actual name of the algorithm that is understood by Java cryptographic operations.- Specified by:
getAlgorithm
in interfaceAlgorithm
- Returns:
- The name of the algorithm.
-
getJwaAlgorithmName
public String getJwaAlgorithmName()
Description copied from interface:Algorithm
Gets the name of the algorithm as defined in the JWA standard.- Specified by:
getJwaAlgorithmName
in interfaceAlgorithm
- Returns:
- The name of the algorithm.
-
getMdAlgorithm
public String getMdAlgorithm()
Returns the Java-friendly name of the message digest algorithm implementation.- Returns:
- the Java-friendly name of the message digest algorithm implementation.
- See Also:
- Standard Names
-
getEllipticCurveName
public String getEllipticCurveName()
Return the standard name of the elliptic curve definition. Only applicable for ECDSA algorithms.- Returns:
- the curve name or null if not applicable.
-
getAlgorithmType
public JwsAlgorithmType getAlgorithmType()
Gets the JwsAlgorithmType of the JwsAlgorithm.- Returns:
- The JwsAlgorithmType.
-
getJwsAlgorithm
@Deprecated public static JwsAlgorithm getJwsAlgorithm(String algorithm)
Deprecated.Replaced byparseCryptographicAlgorithm(String)
- Parameters:
algorithm
- The Java Cryptographic string algorithm name.- Returns:
- The matching JwsAlgorithm.
-
getParameterSpec
public AlgorithmParameterSpec getParameterSpec()
Gets any parameter spec associated with this algorithm. Can be null if no parameters.- Returns:
- the parameters required by this algorithm.
-
parseCryptographicAlgorithm
public static JwsAlgorithm parseCryptographicAlgorithm(String algorithm)
Parses the given algorithm string to find the matching Java Cryptographic algorithm name.If the given algorithm name does not match the algorithm name of any of the constants, then an IllegalArgumentException will be thrown.
- Parameters:
algorithm
- The Java Cryptographic string algorithm name.- Returns:
- The matching JwsAlgorithm.
-
parseAlgorithm
public static JwsAlgorithm parseAlgorithm(String algorithm)
Parses the given algorithm string to find the matching JwsAlgorithm enum constant.- Parameters:
algorithm
- The signing algorithm.- Returns:
- The JwsAlgorithm enum. If algorithm is null, it returns the algorithm "none".
-
isSymmetric
public boolean isSymmetric()
Indicates whether the algorithm is a symmetric (secret key) algorithm like HMAC or a public key algorithm.- Specified by:
isSymmetric
in interfaceAlgorithm
- Returns:
true
if the algorithm uses a shared secret key for signing and verification orfalse
if it uses distinct private and public keys for these operations.
-
toString
public String toString()
Turns the JwsAlgorithm constant into a JSON value string.- Overrides:
toString
in classEnum<JwsAlgorithm>
- Returns:
-
-