Class OpenKeyException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
cloud.opencode.base.crypto.exception.OpenKeyException
All Implemented Interfaces:
Serializable

public class OpenKeyException extends RuntimeException
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 Details

    • OpenKeyException

      public OpenKeyException(String message)
      Constructs a new OpenKeyException with the specified message. 使用指定消息构造新的密钥异常
      Parameters:
      message - the detail message
    • OpenKeyException

      public OpenKeyException(String message, Throwable cause)
      Constructs a new OpenKeyException with the specified message and cause. 使用指定消息和原因构造新的密钥异常
      Parameters:
      message - the detail message
      cause - the cause
    • OpenKeyException

      public OpenKeyException(String keyType, String message)
      Constructs a new OpenKeyException with key type and message. 使用密钥类型和消息构造新的密钥异常
      Parameters:
      keyType - the type of key involved
      message - the detail message
    • OpenKeyException

      public OpenKeyException(String keyType, String message, Throwable cause)
      Constructs a new OpenKeyException with key type, message and cause. 使用密钥类型、消息和原因构造新的密钥异常
      Parameters:
      keyType - the type of key involved
      message - the detail message
      cause - the cause
  • Method Details

    • keyType

      public String keyType()
      Returns the key type associated with this exception. 返回与此异常关联的密钥类型
      Returns:
      the key type, or null if not specified
    • generationFailed

      public static OpenKeyException generationFailed(String keyType, Throwable cause)
      Creates an exception for key generation failures. 创建密钥生成失败时的异常
      Parameters:
      keyType - the type of key that failed to generate
      cause - the underlying cause
      Returns:
      a new OpenKeyException
    • parseFailed

      public static OpenKeyException parseFailed(String keyType, Throwable cause)
      Creates an exception for key parsing failures. 创建密钥解析失败时的异常
      Parameters:
      keyType - the type of key that failed to parse
      cause - the underlying cause
      Returns:
      a new OpenKeyException
    • insufficientStrength

      public static OpenKeyException insufficientStrength(String keyType, int minBits, int actualBits)
      Creates an exception for insufficient key strength. 创建密钥强度不足时的异常
      Parameters:
      keyType - the type of key
      minBits - the minimum required key size in bits
      actualBits - the actual key size in bits
      Returns:
      a new OpenKeyException
    • invalidFormat

      public static OpenKeyException invalidFormat(String keyType, String format)
      Creates an exception for invalid key format. 创建密钥格式无效时的异常
      Parameters:
      keyType - the type of key
      format - the invalid format
      Returns:
      a new OpenKeyException
    • typeMismatch

      public static OpenKeyException typeMismatch(String expected, String actual)
      Creates an exception for key type mismatch. 创建密钥类型不匹配时的异常
      Parameters:
      expected - the expected key type
      actual - the actual key type
      Returns:
      a new OpenKeyException
    • keyNotSet

      public static OpenKeyException keyNotSet(String operation)
      Creates an exception for when a required key is not set. 创建必需密钥未设置时的异常
      Parameters:
      operation - the operation requiring the key
      Returns:
      a new OpenKeyException