com.novell.java.security
Interface Key


public interface Key
extends java.io.Serializable

Defines the functionality shared by all key objects. It is the top-level interface for all keys. All keys have three characteristics:

Keys are usually obtained through key generators, certificates, or various Identity classes used to manage keys. Keys may also be obtained from key specifications (transparent representations of the underlying key material) through the use of a key factory.

See Also:
PublicKey, Identity

Method Summary
 java.lang.String getAlgorithm()
          Returns the standard algorithm name for this key.
 byte[] getEncoded()
          Returns the key in its primary encoding format, or NULL if this key does not support encoding.
 java.lang.String getFormat()
          Returns the name of the primary encoding format of this key, or NULL if this key does not support encoding.
 

Method Detail

getAlgorithm

public java.lang.String getAlgorithm()
Returns the standard algorithm name for this key. It will work with asymmetric operation algorithm, such as DSA or RSA, and with related algorithms, such as MD5 with RSA, SHA-1 with RSA, Raw DSA, and so forth). For example, DSA would indicate that this key is a DSA key. For information about standard algorithm names see Appendix A in Sun's Java Cryptography Architecture API Specification & Reference documentation.
Returns:
The name of the algorithm associated with this key.

getFormat

public java.lang.String getFormat()
Returns the name of the primary encoding format of this key, or NULL if this key does not support encoding. The primary encoding format is named in terms of the appropriate ASN.1 data format, if an ASN.1 specification for this key exists.

For example, the name of the ASN.1 data format for public keys is SubjectPublicKeyInfo, as defined by the X.509 standard; in this case, the returned format is X.509. Similarly, the name of the ASN.1 data format for private keys is PrivateKeyInfo, as defined by the PKCS #8 standard; in this case, the returned format is PKCS#8.

Returns:
The primary encoding format for this key, or NULL if this key does not support encoding.

getEncoded

public byte[] getEncoded()
Returns the key in its primary encoding format, or NULL if this key does not support encoding. The Encoded Form is an external encoded form for the key that is used when a standard representation of the key is needed outside the JVM, as when transmitting the key to some other party. The key is encoded according to a standard format, such as X.509 or PKCS#8.

Returns:
The encoded key as a byte array, or NULL if the key does not support encoding.