de.flexiprovider.core.rsa
Class RSAKeyFactory

java.lang.Object
  |
  +--java.security.KeyFactorySpi
        |
        +--de.flexiprovider.api.keys.KeyFactory
              |
              +--de.flexiprovider.core.rsa.interfaces.RSAKeyFactory
                    |
                    +--de.flexiprovider.core.rsa.RSAKeyFactory

public class RSAKeyFactory
extends RSAKeyFactory

This class is able to transform RSA-keys and RSA-key specs into a form that can be used with the FlexiProvider.

Author:
Thomas Wahrenbruch

Field Summary
static java.lang.String OID
          The OID of RSA.
 
Constructor Summary
RSAKeyFactory()
           
 
Method Summary
 PrivateKey generatePrivate(KeySpec keySpec)
          Converts, if possible, a key specification into a RSAPrivCrtKey or a RSAPrivKey.
 PublicKey generatePublic(KeySpec keySpec)
          Converts, if possible, a key specification into a RSAPubKey.
 KeySpec getKeySpec(Key key, java.lang.Class keySpec)
          Converts a given key into a key specification, if possible.
 Key translateKey(Key key)
          Translates a key into a form known by the FlexiProvider.
 
Methods inherited from class de.flexiprovider.core.rsa.interfaces.RSAKeyFactory
engineGeneratePrivate, engineGeneratePublic
 
Methods inherited from class de.flexiprovider.api.keys.KeyFactory
engineGetKeySpec, engineTranslateKey
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OID

public static final java.lang.String OID
The OID of RSA.
Constructor Detail

RSAKeyFactory

public RSAKeyFactory()
Method Detail

generatePublic

public PublicKey generatePublic(KeySpec keySpec)
                         throws InvalidKeySpecException
Converts, if possible, a key specification into a RSAPubKey. Currently the following key specifications are supported: RSAPublicKeySpec, X509EncodedKeySpec.
Overrides:
generatePublic in class KeyFactory
Parameters:
keySpec - the key specification
Returns:
the public RSA key
Throws:
InvalidKeySpecException - if the KeySpec is not supported.
See Also:
RSAPublicKey

generatePrivate

public PrivateKey generatePrivate(KeySpec keySpec)
                           throws InvalidKeySpecException
Converts, if possible, a key specification into a RSAPrivCrtKey or a RSAPrivKey. Currently the following key specifications are supported: RSAPrivateCrtKeySpec, RSAPrivateKeySpec, PKCS8EncodedKeySpec.
Overrides:
generatePrivate in class KeyFactory
Parameters:
keySpec - the key specification
Returns:
the private RSA key
Throws:
InvalidKeySpecException - if the KeySpec is not supported.
See Also:
RSAPrivateCrtKey, RSAPrivateKey

getKeySpec

public KeySpec getKeySpec(Key key,
                          java.lang.Class keySpec)
                   throws InvalidKeySpecException
Converts a given key into a key specification, if possible. Currently the following specifications are supported:
Overrides:
getKeySpec in class KeyFactory
Parameters:
key - the key
keySpec - the key specification
Returns:
key specification of the RSA key
Throws:
InvalidKeySpecException - if the specification is not supported.

translateKey

public Key translateKey(Key key)
                 throws InvalidKeyException
Translates a key into a form known by the FlexiProvider. Currently the following "source" keys are supported: RSAPrivateCrtKey, RSAPrivateKey, RSAPublicKey.
Overrides:
translateKey in class KeyFactory
Parameters:
key - the key
Returns:
a key of a known key type
Throws:
InvalidKeyException - if the key is not supported.