java.lang.Object
java.security.KeyStore.PasswordProtection
- 所有已实现的接口:
-
KeyStore.ProtectionParameter,Destroyable
- 封装类:
-
KeyStore
public static class KeyStore.PasswordProtection extends Object implements KeyStore.ProtectionParameter, Destroyable
基于密码的
ProtectionParameter实现。
- 自 JDK 版本:
- 1.5
-
Constructor Summary
ConstructorsConstructorDescriptionPasswordProtection(char[] password) 创建一个密码参数。PasswordProtection(char[] password, String protectionAlgorithm, AlgorithmParameterSpec protectionParameters) 创建一个密码参数,并指定在加密密钥库条目时要使用的保护算法和相关参数。 -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()清除密码。char[]获取密码。获取保护算法的名称。获取为保护算法提供的参数。boolean确定密码是否已被清除。
-
Constructor Details
-
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安全标准算法名称规范中的Cipher部分。 -
protectionParameters- 加密算法参数规范,可以为null - 抛出:
-
NullPointerException- 如果protectionAlgorithm为null - 自 JDK 版本:
- 1.8
-
-
Method Details
-
getProtectionAlgorithm
获取保护算法的名称。如果未设置任何算法,则密钥库提供程序将使用其默认的保护算法。- 返回:
-
算法名称,如果未设置则为
null - 自 JDK 版本:
- 1.8
-
getProtectionParameters
获取为保护算法提供的参数。- 返回:
-
算法参数规范,如果未设置则为
null - 自 JDK 版本:
- 1.8
-
getPassword
public char[] getPassword()获取密码。请注意,此方法返回密码的引用。如果创建了数组的克隆,则调用者有责任在不再需要密码信息后将其清零。
- 返回:
-
密码,可以为
null - 抛出:
-
IllegalStateException- 如果密码已被清除(销毁) - 参见:
-
destroy
清除密码。- 指定者:
-
destroy在接口Destroyable中 - 抛出:
-
DestroyFailedException- 如果无法清除密码
-
isDestroyed
public boolean isDestroyed()确定密码是否已被清除。- 指定者:
-
isDestroyed在接口Destroyable中 - 返回:
-
如果密码已被清除则返回
true,否则返回false
-