FileDocCategorySizeDatePackage
KeyFactory.javaAPI DocphoneME MR2 API (J2ME)2983Wed May 02 18:00:38 BST 2007java.security

KeyFactory

public class KeyFactory extends Object
Key factories are used to convert key specifications (transparent representations of the underlying key material) into keys (opaque cryptographic keys of type Key).
version
1.28, 05/07/02
see
Key
see
PublicKey
see
java.security.spec.KeySpec
see
java.security.spec.X509EncodedKeySpec
since
1.2

Fields Summary
Constructors Summary
KeyFactory()
Creates a KeyFactory object.

Methods Summary
public final java.security.PublicKeygeneratePublic(java.security.spec.KeySpec keySpec)
Generates a public key object from the provided key specification (key material).

param
keySpec the specification (key material) of the public key.
return
the public key.
exception
InvalidKeySpecException if the given key specification is inappropriate for this key factory to produce a public key.

        return new RSAPublicKey(keySpec);
    
public static java.security.KeyFactorygetInstance(java.lang.String algorithm)
Generates a KeyFactory object that implements the specified algorithm.

param
algorithm the name of the requested key algorithm. See Appendix A in the Java Cryptography Architecture API Specification & Reference for information about standard algorithm names.
return
a KeyFactory object for the specified algorithm.
exception
NoSuchAlgorithmException if the requested algorithm is not available


        if (algorithm.toUpperCase().equals("RSA")) {
            return new KeyFactory();
        }
        throw new NoSuchAlgorithmException();