Class OpenKeyException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.crypto.exception.OpenKeyException
- All Implemented Interfaces:
Serializable
Exception for key-related operations - Runtime exception for key generation, parsing and validation failures
密钥相关异常 - 密钥生成、解析和验证失败时的运行时异常
Features | 主要功能:
- Key type context in error messages - 错误消息中包含密钥类型上下文
- Covers key generation, parsing, and validation failures - 涵盖密钥生成、解析和验证失败
Usage Examples | 使用示例:
throw new OpenKeyException("RSA", "Invalid key size");
throw new OpenKeyException("Key parsing failed", cause);
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Null-safe: Partial - 空值安全: 部分
- Since:
- JDK 25, opencode-base-crypto V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionOpenKeyException(String message) Constructs a new OpenKeyException with the specified message.OpenKeyException(String keyType, String message) Constructs a new OpenKeyException with key type and message.OpenKeyException(String keyType, String message, Throwable cause) Constructs a new OpenKeyException with key type, message and cause.OpenKeyException(String message, Throwable cause) Constructs a new OpenKeyException with the specified message and cause. -
Method Summary
Modifier and TypeMethodDescriptionstatic OpenKeyExceptiongenerationFailed(String keyType, Throwable cause) Creates an exception for key generation failures.static OpenKeyExceptioninsufficientStrength(String keyType, int minBits, int actualBits) Creates an exception for insufficient key strength.static OpenKeyExceptioninvalidFormat(String keyType, String format) Creates an exception for invalid key format.static OpenKeyExceptionCreates an exception for when a required key is not set.keyType()Returns the key type associated with this exception.static OpenKeyExceptionparseFailed(String keyType, Throwable cause) Creates an exception for key parsing failures.static OpenKeyExceptiontypeMismatch(String expected, String actual) Creates an exception for key type mismatch.Methods inherited from class Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
OpenKeyException
Constructs a new OpenKeyException with the specified message. 使用指定消息构造新的密钥异常- Parameters:
message- the detail message
-
OpenKeyException
-
OpenKeyException
-
OpenKeyException
-
-
Method Details
-
keyType
Returns the key type associated with this exception. 返回与此异常关联的密钥类型- Returns:
- the key type, or null if not specified
-
generationFailed
Creates an exception for key generation failures. 创建密钥生成失败时的异常- Parameters:
keyType- the type of key that failed to generatecause- the underlying cause- Returns:
- a new OpenKeyException
-
parseFailed
Creates an exception for key parsing failures. 创建密钥解析失败时的异常- Parameters:
keyType- the type of key that failed to parsecause- the underlying cause- Returns:
- a new OpenKeyException
-
insufficientStrength
Creates an exception for insufficient key strength. 创建密钥强度不足时的异常- Parameters:
keyType- the type of keyminBits- the minimum required key size in bitsactualBits- the actual key size in bits- Returns:
- a new OpenKeyException
-
invalidFormat
Creates an exception for invalid key format. 创建密钥格式无效时的异常- Parameters:
keyType- the type of keyformat- the invalid format- Returns:
- a new OpenKeyException
-
typeMismatch
Creates an exception for key type mismatch. 创建密钥类型不匹配时的异常- Parameters:
expected- the expected key typeactual- the actual key type- Returns:
- a new OpenKeyException
-
keyNotSet
Creates an exception for when a required key is not set. 创建必需密钥未设置时的异常- Parameters:
operation- the operation requiring the key- Returns:
- a new OpenKeyException
-