|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.security12.sun.security.x509.X509Key
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.
Field Summary | |
protected AlgorithmId |
algid
|
protected byte[] |
encodedKey
|
protected byte[] |
key
|
Constructor Summary | |
X509Key()
Default constructor. |
Method Summary | |
void |
decode(byte[] encodedKey)
|
void |
decode(InputStream in)
Initialize an X509Key object from an input stream. |
byte[] |
encode()
Returns the DER-encoded form of the key as a byte array. |
void |
encode(DerOutputStream out)
Encode SubjectPublicKeyInfo sequence on the DER output stream. |
boolean |
equals(Object object)
|
String |
getAlgorithm()
Returns the algorithm to be used with this key. |
AlgorithmId |
getAlgorithmId()
Returns the algorithm ID to be used with this key. |
byte[] |
getEncoded()
Returns the DER-encoded form of the key as a byte array. |
String |
getFormat()
Returns the format for this key: "X.509" |
int |
hashCode()
Calculates a hash code value for the object. |
static PublicKey |
parse(DerValue in)
Construct X.509 subject public key from a DER value. |
protected void |
parseKeyBits()
Parse the key bits. |
String |
toString()
|
Methods inherited from class java.lang.Object |
clone,
finalize,
getClass,
notify,
notifyAll,
wait,
wait,
wait |
Field Detail |
protected AlgorithmId algid
protected byte[] key
protected byte[] encodedKey
Constructor Detail |
public X509Key()
decode
.Method Detail |
public static PublicKey parse(DerValue in) throws IOException
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.
in
- the DER-encoded SubjectPublicKeyInfo valueprotected void parseKeyBits() throws IOException, InvalidKeyException
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
.
public String getAlgorithm()
public AlgorithmId getAlgorithmId()
public final void encode(DerOutputStream out) throws IOException
public byte[] getEncoded()
public String getFormat()
public byte[] encode() throws InvalidKeyException
public String toString()
public void decode(InputStream in) throws InvalidKeyException
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
.
in
- an input stream with a DER-encoded X.509
SubjectPublicKeyInfo valuepublic void decode(byte[] encodedKey) throws InvalidKeyException
public boolean equals(Object object)
public int hashCode()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |