Enum Class JwtAlgorithm
- All Implemented Interfaces:
Serializable, Comparable<JwtAlgorithm>, Constable
JWT Algorithm - Supported algorithms for JWT signing
JWT 算法 - 支持的 JWT 签名算法
Features | 主要功能:
- HMAC (HS256/384/512) algorithm definitions - HMAC(HS256/384/512)算法定义
- RSA (RS256/384/512, PS256/384/512) algorithm definitions - RSA(RS256/384/512、PS256/384/512)算法定义
- ECDSA (ES256/384/512) and EdDSA algorithm definitions - ECDSA(ES256/384/512)和 EdDSA 算法定义
Usage Examples | 使用示例:
JwtAlgorithm alg = JwtAlgorithm.HS256;
String jcaName = alg.jcaName();
boolean symmetric = alg.isSymmetric();
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Null-safe: Partial - 空值安全: 部分
Performance | 性能特性:
- Time complexity: O(1) - 时间复杂度: O(1)
- Space complexity: O(1) - 空间复杂度: O(1)
- Since:
- JDK 25, opencode-base-crypto V1.2.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Enum
Enum.EnumDesc<E> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionEdDSA with Ed25519ECDSA with P-256 and SHA-256ECDSA with P-384 and SHA-384ECDSA with P-521 and SHA-512HMAC with SHA-256HMAC with SHA-384HMAC with SHA-512RSA-PSS with SHA-256RSA-PSS with SHA-384RSA-PSS with SHA-512RSA PKCS#1 with SHA-256RSA PKCS#1 with SHA-384RSA PKCS#1 with SHA-512 -
Method Summary
Modifier and TypeMethodDescriptionReturns the JWT algorithm name (e.g., "HS256", "RS256").static JwtAlgorithmParses algorithm from string name.booleanChecks if this is an asymmetric algorithm.booleanChecks if this is a symmetric algorithm.jcaName()Returns the JCA algorithm name.type()Returns the algorithm type ("symmetric" or "asymmetric").static JwtAlgorithmReturns the enum constant of this class with the specified name.static JwtAlgorithm[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
HS256
HMAC with SHA-256 -
HS384
HMAC with SHA-384 -
HS512
HMAC with SHA-512 -
RS256
RSA PKCS#1 with SHA-256 -
RS384
RSA PKCS#1 with SHA-384 -
RS512
RSA PKCS#1 with SHA-512 -
PS256
RSA-PSS with SHA-256 -
PS384
RSA-PSS with SHA-384 -
PS512
RSA-PSS with SHA-512 -
ES256
ECDSA with P-256 and SHA-256 -
ES384
ECDSA with P-384 and SHA-384 -
ES512
ECDSA with P-521 and SHA-512 -
EdDSA
EdDSA with Ed25519
-
-
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
-
algorithmName
Returns the JWT algorithm name (e.g., "HS256", "RS256"). 返回 JWT 算法名称(例如:"HS256"、"RS256")。- Returns:
- the algorithm name
-
jcaName
Returns the JCA algorithm name. 返回 JCA 算法名称。- Returns:
- the JCA algorithm name
-
type
Returns the algorithm type ("symmetric" or "asymmetric"). 返回算法类型("symmetric" 或 "asymmetric")。- Returns:
- the algorithm type
-
isSymmetric
public boolean isSymmetric()Checks if this is a symmetric algorithm. 检查是否为对称算法。- Returns:
- true if symmetric
-
isAsymmetric
public boolean isAsymmetric()Checks if this is an asymmetric algorithm. 检查是否为非对称算法。- Returns:
- true if asymmetric
-
fromName
Parses algorithm from string name. 从字符串名称解析算法。- Parameters:
name- the algorithm name- Returns:
- the algorithm
- Throws:
IllegalArgumentException- if algorithm is not supported
-