java.lang.Object | |
↳ | 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.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
algid | |||||||||||
encodedKey | |||||||||||
key | This field is deprecated. Use the BitArray form which does not require keys to be byte aligned. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Default constructor.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Initialize an X509Key object from an input stream.
| |||||||||||
Returns the DER-encoded form of the key as a byte array.
| |||||||||||
Encode SubjectPublicKeyInfo sequence on the DER output stream.
| |||||||||||
Indicates whether some other object is "equal to" this one.
| |||||||||||
Returns the algorithm to be used with this key.
| |||||||||||
Returns the algorithm ID to be used with this key.
| |||||||||||
Returns the DER-encoded form of the key as a byte array.
| |||||||||||
Returns the format for this key: "X.509"
| |||||||||||
Calculates a hash code value for the object.
| |||||||||||
Construct X.509 subject public key from a DER value.
| |||||||||||
Returns a string representation of the object.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the key.
| |||||||||||
Parse the key bits.
| |||||||||||
Sets the key in the BitArray form.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
This field is deprecated.
Use the BitArray form which does not require keys to
be byte aligned.
The key bytes, without the algorithm information.
Default constructor. The key constructed must have its key
and algorithm initialized before it may be used, for example
by using decode
.
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
.
in | an input stream with a DER-encoded X.509 SubjectPublicKeyInfo value |
---|
InvalidKeyException | on parsing errors. |
---|
Returns the DER-encoded form of the key as a byte array.
InvalidKeyException | on encoding errors. |
---|
Encode SubjectPublicKeyInfo sequence on the DER output stream.
IOException | on encoding errors. |
---|
Indicates whether some other object is "equal to" this one.
The equals
method implements an equivalence relation
on non-null object references:
x
, x.equals(x)
should return
true
.
x
and y
, x.equals(y)
should return true
if and only if
y.equals(x)
returns true
.
x
, y
, and z
, if
x.equals(y)
returns true
and
y.equals(z)
returns true
, then
x.equals(z)
should return true
.
x
and y
, multiple invocations of
x.equals(y) consistently return true
or consistently return false
, provided no
information used in equals
comparisons on the
objects is modified.
x
,
x.equals(null)
should return false
.
The equals method for class Object
implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x
and
y
, this method returns true
if and only
if x
and y
refer to the same object
(x == y
has the value true
).
Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.
obj | the reference object with which to compare. |
---|
true
if this object is the same as the obj
argument; false
otherwise.Returns the algorithm to be used with this key.
Returns the DER-encoded form of the key as a byte array.
Returns the format for this key: "X.509"
Calculates a hash code value for the object. Objects which are equal will also have the same hashcode.
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.
in | the DER-encoded SubjectPublicKeyInfo value |
---|
IOException | on data format errors |
---|
Returns a string representation of the object. In general, the
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
Gets the key. The key may or may not be byte aligned.
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
.
IOException | on parsing errors. |
---|---|
InvalidKeyException | on invalid key encodings. |