public final class DSAKeyFactory
extends java.security.KeyFactorySpi
To convert, for instance, DER encoded PKCS#8 private key material (e.g. pkcs8_key_spec
instantiated from PKCS8EncodedKeySpec) into DSAPrivateKey representation, use this KeyFactory
for DSA keys:
KeyFactory dsa_key_fac = KeyFactory.getInstance("DSA");
DSAPrivateKey dsa_priv_key = (DSAPrivateKey)dsa_key_fac.generatePrivate(pkcs8_key_spec);
DSAPrivateKey,
DSAPublicKey| Constructor and Description |
|---|
DSAKeyFactory()
Default constructor for creating a DSAKeyFactory.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.security.PrivateKey |
engineGeneratePrivate(java.security.spec.KeySpec keySpec)
Converts the given key specification to a PrivateKey.
|
protected java.security.PublicKey |
engineGeneratePublic(java.security.spec.KeySpec keySpec)
Converts the given key specification to a PublicKey.
|
protected java.security.spec.KeySpec |
engineGetKeySpec(java.security.Key key,
java.lang.Class classSpec)
Converts the given key into the requested key specification (key material).
|
protected java.security.Key |
engineTranslateKey(java.security.Key key)
Translates the given key object of some unknown or untrusted provider into a
key object supported by this DSA key factory.
|
public DSAKeyFactory()
KeyFactory.getInstance("DSA"); for instantiating
a DSAKeyFactory.protected java.security.PrivateKey engineGeneratePrivate(java.security.spec.KeySpec keySpec)
throws java.security.spec.InvalidKeySpecException
engineGeneratePrivate in class java.security.KeyFactorySpikeySpec - the key specification as DSAPrivateKeySpec or PKCS8EncodedKeySpecjava.security.spec.InvalidKeySpecException - if the given key material is not
a DSAPrivateKeySpec or PKCS8EncodedKeySpecprotected java.security.PublicKey engineGeneratePublic(java.security.spec.KeySpec keySpec)
throws java.security.spec.InvalidKeySpecException
engineGeneratePublic in class java.security.KeyFactorySpikeySpec - the key specification as DSAPublicKeySpec or X509EncodedKeySpecjava.security.spec.InvalidKeySpecException - if the given key material is not
a DSAPublicKeySpec or X509EncodedKeySpecprotected java.security.spec.KeySpec engineGetKeySpec(java.security.Key key,
java.lang.Class classSpec)
throws java.security.spec.InvalidKeySpecException
classSpec. Each attempt
to get key material of a type not matching to a given DSA key will raise an exception.engineGetKeySpec in class java.security.KeyFactorySpikey - the key to be converted, which either may be a DSAPublicKey or a DSAPrivateKey.classSpec - the key specification type into which the key shall be converted, which may be
a DSAPublicKeySpec or a X509EncodedKeySpec if the given key is a DSAPublicKey, or
a DSAPrivateKeySpec or a PKCS8EncodedKeySpec if the given key is a DSAPrivateKeyjava.security.spec.InvalidKeySpecException - if the given key cannot be converted into the
requested key specification object by this key factoryprotected java.security.Key engineTranslateKey(java.security.Key key)
throws java.security.InvalidKeyException
DSAPublicKey or DSAPrivateKey.engineTranslateKey in class java.security.KeyFactorySpikey - the key of some unknown or untrusted providerjava.security.InvalidKeyException - if the given key cannot be translated by this key factory