| java.lang.Object sun.security.x509.X509Key
All known Subclasses: sun.security.provider.DSAPublicKey,
X509Key | public class X509Key implements PublicKey(Code) | | Holds an X.509 key, for example a public key found in an X.509
certificate. Includes a description of the algorithm to be used
with the key; these keys normally are used as
"SubjectPublicKeyInfo".
While this class can represent any kind of X.509 key, it may be
desirable to provide subclasses which understand how to parse keying
data. For example, RSA public keys have two members, one for the
public modulus and one for the prime exponent. If such a class is
provided, it is used when parsing X.509 keys. If one is not provided,
the key still parses correctly.
version: 1.81, 02/02/00 author: David Brownell |
Constructor Summary | |
public | X509Key() Default constructor. |
encodedKey | protected byte[] encodedKey(Code) | | |
X509Key | public X509Key()(Code) | | Default constructor. The key constructed must have its key
and algorithm initialized before it may be used, for example
by using decode .
|
decode | public void decode(InputStream in) throws InvalidKeyException(Code) | | Initialize an X509Key object from an input stream. The data on that
input stream must be encoded using DER, obeying the X.509
SubjectPublicKeyInfo format. That is, the data is a
sequence consisting of an algorithm ID and a bit string which holds
the key. (That bit string is often used to encapsulate another DER
encoded sequence.)
Subclasses should not normally redefine this method; they should
instead provide a parseKeyBits method to parse any
fields inside the key member.
The exception to this rule is that since private keys need not
be encoded using the X.509 SubjectPublicKeyInfo format,
private keys may override this method, encode , and
of course getFormat .
Parameters: in - an input stream with a DER-encoded X.509SubjectPublicKeyInfo value exception: InvalidKeyException - on parsing errors. |
getAlgorithm | public String getAlgorithm()(Code) | | Returns the algorithm to be used with this key.
|
getAlgorithmId | public AlgorithmId getAlgorithmId()(Code) | | Returns the algorithm ID to be used with this key.
|
getEncoded | public byte[] getEncoded()(Code) | | Returns the DER-encoded form of the key as a byte array.
|
getFormat | public String getFormat()(Code) | | Returns the format for this key: "X.509"
|
getKey | protected BitArray getKey()(Code) | | Gets the key. The key may or may not be byte aligned.
a BitArray containing the key. |
hashCode | public int hashCode()(Code) | | Calculates a hash code value for the object. Objects
which are equal will also have the same hashcode.
|
parse | public static PublicKey parse(DerValue in) throws IOException(Code) | | Construct X.509 subject public key from a DER value. If
the runtime environment is configured with a specific class for
this kind of key, a subclass is returned. Otherwise, a generic
X509Key object is returned.
This mechanism gurantees that keys (and algorithms) may be
freely manipulated and transferred, without risk of losing
information. Also, when a key (or algorithm) needs some special
handling, that specific need can be accomodated.
Parameters: in - the DER-encoded SubjectPublicKeyInfo value exception: IOException - on data format errors |
parseKeyBits | protected void parseKeyBits() throws IOException, InvalidKeyException(Code) | | Parse the key bits. This may be redefined by subclasses to take
advantage of structure within the key. For example, RSA public
keys encapsulate two unsigned integers (modulus and exponent) as
DER values within the key bits; Diffie-Hellman and
DSS/DSA keys encapsulate a single unsigned integer.
This function is called when creating X.509 SubjectPublicKeyInfo
values using the X509Key member functions, such as parse
and decode .
exception: IOException - on parsing errors. exception: InvalidKeyException - on invalid key encodings. |
setKey | protected void setKey(BitArray key)(Code) | | Sets the key in the BitArray form.
|
|
|