All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.security.PrivateKey

java.lang.Object
   |
   +----java.security.Key
           |
           +----java.security.PrivateKey

public class PrivateKey
extends Key

A private key. The recommended format is PKCS#8, as defined in RSA Laboratory's PKCS#8 technical note.

See Also:
Key, KeyParams, PublicKey, Certificate, initSign

Constructor Index

 o PrivateKey()
Constructs an uninitialized private key for serialization.
 o PrivateKey(byte[])
Constructs a generic private key encoded using the PKCS#8 format.
 o PrivateKey(byte[], String)
Constructs a private key encoded using a known format.
 o PrivateKey(byte[], String, String)
Constructs a private key, for a known algorithm, encoded using a known encoding format.

Method Index

 o getClassName(String, String)
Given an algorithm name and the name of an encoding format, returns the name of a PrivateKey class using the specified format and capable of handling keys for that algorithm.
 o getEncoded()
Returns the encoded private key.

Constructors

 o PrivateKey
  protected PrivateKey()
Constructs an uninitialized private key for serialization.

 o PrivateKey
  public PrivateKey(byte encodedKey[])
Constructs a generic private key encoded using the PKCS#8 format.

Parameters:
encodedKey - the key, encoded using the PKCS#8 format.
 o PrivateKey
  public PrivateKey(byte encodedKey[],
                    String format)
Constructs a private key encoded using a known format.

Parameters:
encodedKey - the key, encoded using format.
format - the format used to encode the key.
 o PrivateKey
  public PrivateKey(byte encodedKey[],
                    String format,
                    String algorithm)
Constructs a private key, for a known algorithm, encoded using a known encoding format.

Parameters:
encodedKey - the key, encoded using format.
format - the format used to encode the key.
algorithm - the name of the algorithm for this key.

Methods

 o getClassName
  protected static String getClassName(String algName,
                                       String format)
Given an algorithm name and the name of an encoding format, returns the name of a PrivateKey class using the specified format and capable of handling keys for that algorithm. The algorithm name may be an alias or a standard name. See algorithm names for information about standard algorithm names. Note that the class may not necessarily be accessible to a given caller.

Parameters:
algName - the algorithm name corresponding to the class name requested.
format - the requested encoding format.
 o getEncoded
  protected final byte[] getEncoded() throws InvalidKeyException
Returns the encoded private key.

Returns:
the encoded private key.
Throws: InvalidKeyException
if the private key cannot be encoded, for example if the original encoding was invalid, or if the key was not properly initialized.
Overrides:
getEncoded in class Key

All Packages  Class Hierarchy  This Package  Previous  Next  Index