java.security

Interface Key

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 {@link KeyFactory}.

Since: 1.1

See Also: PublicKey PrivateKey KeyPair KeyPairGenerator KeyFactory KeySpec Identity Signer

UNKNOWN: updated to 1.4

Field Summary
longserialVersionUID
The version identifier used for serialization.
Method Summary
StringgetAlgorithm()
This method returns the name of the algorithm for this key.
byte[]getEncoded()
This method returns the encoded form of the key.
StringgetFormat()
This method returns the name of the encoding format for this key.

Field Detail

serialVersionUID

public long serialVersionUID
The version identifier used for serialization.

Method Detail

getAlgorithm

public 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

getEncoded

public 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

getFormat

public 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