模块 java.base

类 KeyStore.PasswordProtection

java.lang.Object
java.security.KeyStore.PasswordProtection
所有已实现的接口:
KeyStore.ProtectionParameter , Destroyable
封闭类:
KeyStore

public static class KeyStore.PasswordProtection extends Object implements KeyStore.ProtectionParameter , Destroyable
ProtectionParameter 的基于密码的实现。
自从:
1.5
  • 构造方法详细信息

    • PasswordProtection

      public PasswordProtection(char[] password)
      创建密码参数。

      指定的 password 在存储到新的 PasswordProtection 对象之前被克隆。

      参数:
      password - 密码,可能是 null
    • PasswordProtection

      public PasswordProtection(char[] password, String  protectionAlgorithm, AlgorithmParameterSpec  protectionParameters)
      创建密码参数并指定在加密密钥库条目时要使用的保护算法和相关参数。

      指定的 password 在存储到新的 PasswordProtection 对象之前被克隆。

      参数:
      password - 密码,可能是 null
      protectionAlgorithm - 加密算法名称,例如 PBEWithHmacSHA256AndAES_256 。有关标准加密算法名称的信息,请参阅 Java 安全标准算法名称规范 中的密码部分。
      protectionParameters——加密算法参数说明,可能是null
      抛出:
      NullPointerException - 如果 protectionAlgorithmnull
      自从:
      1.8
  • 方法详情

    • getProtectionAlgorithm

      public String  getProtectionAlgorithm()
      获取保护算法的名称。如果未设置,则密钥库提供程序将使用其默认保护算法。
      返回:
      算法名称,如果未设置,则为 null
      自从:
      1.8
    • getProtectionParameters

      public AlgorithmParameterSpec  getProtectionParameters()
      获取为保护算法提供的参数。
      返回:
      算法参数规范,或 null ,如果未设置
      自从:
      1.8
    • getPassword

      public char[] getPassword()
      获取密码。

      请注意,此方法返回对密码的引用。如果创建了数组的克隆,调用者有责任在不再需要密码信息后将其清零。

      返回:
      密码,可能是null
      抛出:
      IllegalStateException - 如果密码已被清除(销毁)
      参见:
    • destroy

      public void destroy() throws DestroyFailedException
      清除密码。
      指定者:
      destroy 在接口 Destroyable
      抛出:
      DestroyFailedException - 如果此方法无法清除密码
    • isDestroyed

      public boolean isDestroyed()
      确定密码是否已被清除。
      指定者:
      isDestroyed 在接口 Destroyable
      返回:
      true 如果密码已被清除,false 否则