Enum Class JwsAlgorithm
- All Implemented Interfaces:
Serializable, Comparable<JwsAlgorithm>, Constable
A JWS signature algorithm, named by its
alg header value (RFC 7515 section 4.1.1, RFC 7518 section 3.1,
RFC 8037 section 3.1 and RFC 9864).
Revetsec verifies RSASSA-PKCS1-v1_5 (RS*), RSASSA-PSS (PS*), ECDSA on P-256, P-384 and P-521
(ES*) and EdDSA over Ed25519, which RFC 9864 names Ed25519 and the older RFC 8037 names
EdDSA. EdDSA is accepted for Ed25519 keys only. The HMAC algorithms (HS*) can be named here,
but JwtValidator refuses them: it verifies only with public keys. There is no constant for none.
Wire values are compared exactly and case-sensitively, so rs256 and NONE name no algorithm here.
This enum is not switch-stable: a later release may add constants, so a switch over it needs a default
branch.
- Since:
- 1.0.0
- Author:
- Mark Allen
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionEdDSA over Ed25519, by its fully specified name (Ed25519, RFC 9864).EdDSA (EdDSA, RFC 8037 section 3.1), accepted for Ed25519 keys only.ECDSA on P-256 with SHA-256 (ES256, RFC 7518 section 3.4).ECDSA on P-384 with SHA-384 (ES384, RFC 7518 section 3.4).ECDSA on P-521 with SHA-512 (ES512, RFC 7518 section 3.4).HMAC with SHA-256 (HS256, RFC 7518 section 3.2).HMAC with SHA-384 (HS384, RFC 7518 section 3.2).HMAC with SHA-512 (HS512, RFC 7518 section 3.2).RSASSA-PSS with SHA-256, MGF1 with SHA-256 and a 32-byte salt (PS256, RFC 7518 section 3.5).RSASSA-PSS with SHA-384, MGF1 with SHA-384 and a 48-byte salt (PS384, RFC 7518 section 3.5).RSASSA-PSS with SHA-512, MGF1 with SHA-512 and a 64-byte salt (PS512, RFC 7518 section 3.5).RSASSA-PKCS1-v1_5 with SHA-256 (RS256, RFC 7518 section 3.3).RSASSA-PKCS1-v1_5 with SHA-384 (RS384, RFC 7518 section 3.3).RSASSA-PKCS1-v1_5 with SHA-512 (RS512, RFC 7518 section 3.3). -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull Optional<@NonNull JwsAlgorithm> findByWireValue(@NonNull String wireValue) Returns the algorithm named by analgvalue, compared exactly and case-sensitively.Returns this algorithm'salgvalue.static JwsAlgorithmReturns the enum constant of this class with the specified name.static JwsAlgorithm[]values()Returns an array containing the constants of this enum class, in the order they are declared.Methods inherited from class Enum
compareTo, describeConstable, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
-
Enum Constant Details
-
RS256
RSASSA-PKCS1-v1_5 with SHA-256 (RS256, RFC 7518 section 3.3). -
RS384
RSASSA-PKCS1-v1_5 with SHA-384 (RS384, RFC 7518 section 3.3). -
RS512
RSASSA-PKCS1-v1_5 with SHA-512 (RS512, RFC 7518 section 3.3). -
PS256
RSASSA-PSS with SHA-256, MGF1 with SHA-256 and a 32-byte salt (PS256, RFC 7518 section 3.5). -
PS384
RSASSA-PSS with SHA-384, MGF1 with SHA-384 and a 48-byte salt (PS384, RFC 7518 section 3.5). -
PS512
RSASSA-PSS with SHA-512, MGF1 with SHA-512 and a 64-byte salt (PS512, RFC 7518 section 3.5). -
ES256
ECDSA on P-256 with SHA-256 (ES256, RFC 7518 section 3.4). -
ES384
ECDSA on P-384 with SHA-384 (ES384, RFC 7518 section 3.4). -
ES512
ECDSA on P-521 with SHA-512 (ES512, RFC 7518 section 3.4). -
ED25519
EdDSA over Ed25519, by its fully specified name (Ed25519, RFC 9864). -
EDDSA
EdDSA (EdDSA, RFC 8037 section 3.1), accepted for Ed25519 keys only. RFC 9864 deprecates this name (section 4.1.2) in favor of fully specified ones,ED25519for Ed25519 keys (section 2.2). On an Ed25519 key both name the same operation, so a key whosealgis one of the two verifies tokens that name the other; that alias is Revetsec's, not the RFC's. -
HS256
HMAC with SHA-256 (HS256, RFC 7518 section 3.2).JwtValidatorrefuses it. -
HS384
HMAC with SHA-384 (HS384, RFC 7518 section 3.2).JwtValidatorrefuses it. -
HS512
HMAC with SHA-512 (HS512, RFC 7518 section 3.2).JwtValidatorrefuses it.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified nameNullPointerException- if the argument is null
-
findByWireValue
Returns the algorithm named by analgvalue, compared exactly and case-sensitively.- Parameters:
wireValue- thealgvalue, such asRS256orEd25519- Returns:
- the algorithm, or empty if
wireValuenames none of these algorithms - Throws:
NullPointerException- ifwireValueisnull- Since:
- 1.0.0
-
getWireValue
Returns this algorithm'salgvalue.- Returns:
- the
algvalue, such asRS256orEd25519 - Since:
- 1.0.0
-