java.security
Interface Key

All Superinterfaces:
Serializable
All Known Subinterfaces:
DHPrivateKey, DHPublicKey, DSAPrivateKey, DSAPublicKey, PBEKey, PrivateKey, PublicKey, RSAMultiPrimePrivateCrtKey, RSAPrivateCrtKey, RSAPrivateKey, RSAPublicKey, SecretKey
All Known Implementing Classes:
KerberosKey, SecretKeySpec

public interface Key
extends Serializable

This interfaces models the base characteristics that all keys must have. These are: a key algorithm, an encoded form, and a format used to encode the key. Specific key types inherit from this interface. Note that since this interface extends Serializable, all keys may be serialized. Keys are generally obtained through key generators, including KeyFactory.

Since:
1.1
See Also:
PublicKey, PrivateKey, KeyPair, KeyPairGenerator, KeyFactory, KeySpec, Identity, Signer

Field Summary
static long serialVersionUID
          The version identifier used for serialization.
 
Method Summary
 String getAlgorithm()
          This method returns the name of the algorithm for this key.
 byte[] getEncoded()
          This method returns the encoded form of the key.
 String getFormat()
          This method returns the name of the encoding format for this key.
 

Field Detail

serialVersionUID

static final long serialVersionUID
The version identifier used for serialization.

See Also:
Constant Field Values
Method Detail

getAlgorithm

String getAlgorithm()
This method returns the name of the algorithm for this key. This is a String such as "RSA".

Returns:
the name of the algorithm in use

getFormat

String getFormat()
This method returns the name of the encoding format for this key. This is the name of the ASN.1 data format used for this key, such as "X.509" or "PKCS#8". This method returns null if this key does not have an encoding format.

Returns:
the name of the encoding format for this key, or null

getEncoded

byte[] getEncoded()
This method returns the encoded form of the key. If this key does not support encoding, this method returns null.

Returns:
the encoded form of the key, or null