| 
 | JavaTM Platform Standard Ed. 6 | |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.crypto.SecretKeyFactory
public class SecretKeyFactory
此类表示秘密密钥的工厂。
 密钥工厂用来将密钥(类型 Key 的不透明加密密钥)转换为密钥规范(底层密钥材料的透明表示形式),反之亦然。秘密密钥工厂只对秘密(对称)密钥进行操作。
密钥工厂为双工模式,即其允许根据给定密钥规范(密钥材料)构建不透明密钥对象,或以适当格式获取密钥对象的底层密钥材料。
 应用程序开发人员应参阅其提供者文档,找出 generateSecret 和 getKeySpec 方法所支持的密钥规范。例如,"SunJCE" 提供者提供的 DES 秘密密钥工厂支持 DESKeySpec 作为 DES 密钥的透明表示形式,并且该提供者的 Triple DES 密钥的秘密密钥工厂支持 DESedeKeySpec 作为 Triple DES 密钥的透明表示形式。
SecretKey, 
DESKeySpec, 
DESedeKeySpec, 
PBEKeySpec| 构造方法摘要 | |
|---|---|
| protected  | SecretKeyFactory(SecretKeyFactorySpi keyFacSpi,
                 Provider provider,
                 String algorithm)创建一个 SecretKeyFactory 对象。 | 
| 方法摘要 | |
|---|---|
|  SecretKey | generateSecret(KeySpec keySpec)根据提供的密钥规范(密钥材料)生成 SecretKey对象。 | 
|  String | getAlgorithm()返回此 SecretKeyFactory对象的算法名称。 | 
| static SecretKeyFactory | getInstance(String algorithm)返回转换指定算法的秘密密钥的 SecretKeyFactory对象。 | 
| static SecretKeyFactory | getInstance(String algorithm,
            Provider provider)返回转换指定算法的秘密密钥的 SecretKeyFactory对象。 | 
| static SecretKeyFactory | getInstance(String algorithm,
            String provider)返回转换指定算法的秘密密钥的 SecretKeyFactory对象。 | 
|  KeySpec | getKeySpec(SecretKey key,
           Class keySpec)以请求的格式返回给定密钥对象的规范(密钥材料)。 | 
|  Provider | getProvider()返回此 SecretKeyFactory对象的提供者。 | 
|  SecretKey | translateKey(SecretKey key)将一个密钥对象(其提供者未知或可能不受信任)转换为此秘密密钥工厂的相应密钥对象。 | 
| 从类 java.lang.Object 继承的方法 | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| 构造方法详细信息 | 
|---|
protected SecretKeyFactory(SecretKeyFactorySpi keyFacSpi,
                           Provider provider,
                           String algorithm)
keyFacSpi - 委托provider - 提供者algorithm - 秘密密钥算法| 方法详细信息 | 
|---|
public static final SecretKeyFactory getInstance(String algorithm)
                                          throws NoSuchAlgorithmException
SecretKeyFactory 对象。
 此方法从首选 Provider 开始遍历已注册安全提供者列表。返回一个封装 SecretKeyFactorySpi 实现的新 SecretKeyFactory 对象,该实现取自支持指定算法的第一个 Provider。
 注意,可以通过 Security.getProviders() 方法获取已注册提供者列表。
algorithm - 所请求的秘密密钥算法的标准名称。有关标准算法名称的信息,请参阅 
 Java Cryptography Architecture Reference Guide 中的附录 A。
SecretKeyFactory 对象。
NullPointerException - 如果指定的算法为 null。
NoSuchAlgorithmException - 如果没有任何 Provider 支持指定算法的 SecretKeyFactorySpi 实现。Provider
public static final SecretKeyFactory getInstance(String algorithm,
                                                 String provider)
                                          throws NoSuchAlgorithmException,
                                                 NoSuchProviderException
SecretKeyFactory 对象。
 返回一个封装 SecretKeyFactorySpi 实现的新 SecretKeyFactory 对象,该实现取自指定的提供者。指定提供者必须在安全提供者列表中注册。
 注意,可以通过 Security.getProviders() 方法获取已注册提供者列表。
algorithm - 所请求的秘密密钥算法的标准名称。有关标准算法名称的信息,请参阅 
 Java Cryptography Architecture Reference Guide 中的附录 A。provider - 提供者的名称。
SecretKeyFactory 对象。
NoSuchAlgorithmException - 如果不能从指定提供者获得指定算法的 SecretKeyFactorySpi 实现。
NullPointerException - 如果指定的算法为 null。
NoSuchProviderException - 如果指定提供者未在安全提供者列表中注册。
IllegalArgumentException - 如果 provider 为 null 或空。Provider
public static final SecretKeyFactory getInstance(String algorithm,
                                                 Provider provider)
                                          throws NoSuchAlgorithmException
SecretKeyFactory 对象。
 返回一个封装 SecretKeyFactorySpi 实现的新 SecretKeyFactory 对象,该实现取自指定的 Provider 对象。注意,指定 Provider 对象无需在提供者列表中注册。
algorithm - 所请求的秘密密钥算法的标准名称。有关标准算法名称的信息,请参阅 
 Java Cryptography Architecture Reference Guide 中的附录 A。provider - 提供者。
SecretKeyFactory 对象。
NullPointerException - 如果指定的算法为 null。
NoSuchAlgorithmException - 如果不能从指定的 Provider 对象获得指定算法的 SecretKeyFactorySpi 实现。
IllegalArgumentException - 如果 provider 为 null。Providerpublic final Provider getProvider()
SecretKeyFactory 对象的提供者。
SecretKeyFactory 对象的提供者public final String getAlgorithm()
SecretKeyFactory 对象的算法名称。
此名称与在某个创建此 SecretKeyFactory 对象的 getInstance 调用中指定的名称相同。
SecretKeyFactory 对象的算法名称。
public final SecretKey generateSecret(KeySpec keySpec)
                               throws InvalidKeySpecException
SecretKey 对象。
keySpec - 秘密密钥的规范(密钥材料)
InvalidKeySpecException - 如果给定密钥规范不适合生成秘密密钥的秘密密钥工厂。
public final KeySpec getKeySpec(SecretKey key,
                                Class keySpec)
                         throws InvalidKeySpecException
key - 密钥keySpec - 所请求的格式,密钥材料将以此格式返回
InvalidKeySpecException - 如果所请求的密钥规范不适合给定的密钥(例如,与 key 和 keySpec 关联的算法不匹配,或者 key 在加密硬件设备上引用一个密钥而 keySpec 是基于软件的密钥规范),或者无法处理给定的密钥(例如,给定的密钥具有此秘密密钥工厂不支持的算法或格式)。
public final SecretKey translateKey(SecretKey key)
                             throws InvalidKeyException
key - 其提供者未知或不受信任的密钥
InvalidKeyException - 如果此秘密密钥工厂无法处理给定的密钥。| 
 | JavaTM Platform Standard Ed. 6 | |||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。