|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.util.AbstractCollection
|
+--java.util.AbstractList
|
+--java.util.ArrayList
|
+--codec.asn1.ASN1AbstractCollection
|
+--codec.asn1.ASN1Sequence
|
+--codec.x509.AlgorithmIdentifier
This class represents the ASN.1/DER value of the AlgorithmIdentifier defined in Annex D to Recommendation X.509. This structure is extensively used for instance in the PKCS standards of RSA Inc. The ASN.1 definition of this structure is as given below:
AlgorithmIdentifier ::= SEQUENCE{
algorithm OBJECT IDENTIFIER,
parameters ANY DEFINED BY algorithm OPTIONAL
}
For this class to work properly, providers need to define the following
algorithm aliases for the AlgorithmParameters implementations they provide:
The alias definitions are used by this class in order to find an
AlgorithmParameters implementation for the OID embedded in the X.509
AlgorithmIdentifier structure, and to create the OID for a given
AlgorithmParameters instances. This is done by means of the JCA
class, which operates on the engine and alias definitions of the installed
providers.
JCA, Serialized Form| Field Summary | |
protected ASN1ObjectIdentifier |
algorithm_
The OID of the algorithm. |
protected ASN1Opaque |
parameters_
The algorithm parameters of the algorithm specified by this algorithm identifier. |
| Fields inherited from class java.util.AbstractList |
modCount |
| Constructor Summary | |
AlgorithmIdentifier()
This method builds the tree of ASN.1 objects used for decoding this structure. |
|
AlgorithmIdentifier(ASN1ObjectIdentifier oid,
ASN1Type params)
Creates an instance with the given OID and parameters. |
|
AlgorithmIdentifier(ASN1ObjectIdentifier oid,
byte[] b)
Creates an instance with the given OID and opaque algorithm parameter representation. |
|
AlgorithmIdentifier(String algorithm)
Creates an instance initialized to the given algorithm. |
|
AlgorithmIdentifier(String alg,
AlgorithmParameters params)
Creates an instance that is initialized from the given AlgorithmParameters instance. |
|
| Method Summary | |
Object |
clone()
Returns a clone. |
static AlgorithmIdentifier |
createAlgorithmIdentifier(Key key)
Creates an AlgorithmIdentifier from the given
key. |
boolean |
equals(Object o)
This method returns true if the given object is an
instance of this class or a subclass thereof and the algorithm OID of the
given object equals this object's algorithm OID. |
String |
getAlgorithmName()
This method returns the JCE standard name of the algorithm specified in this AlgorithmIdentifier. |
ASN1ObjectIdentifier |
getAlgorithmOID()
This method returns the OID of the algorithm represented by this AlgorithmIdentifier. |
AlgorithmParameters |
getParameters()
This method locates a suitable AlgorithmParameters implementation if it is available from the JCE
compliant security providers that are installed locally.
|
int |
hashCode()
|
String |
toString()
Returns a string representation of this object. |
| Methods inherited from class codec.asn1.ASN1Sequence |
getTag |
| Methods inherited from class codec.asn1.ASN1AbstractCollection |
checkConstraints, decode, encode, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, writeExternal |
| Methods inherited from class java.util.ArrayList |
add, add, addAll, addAll, clear, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize |
| Methods inherited from class java.util.AbstractList |
iterator, listIterator, listIterator, subList |
| Methods inherited from class java.util.AbstractCollection |
containsAll, remove, removeAll, retainAll |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray |
| Methods inherited from interface java.util.List |
containsAll, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList |
| Field Detail |
protected ASN1Opaque parameters_
protected ASN1ObjectIdentifier algorithm_
| Constructor Detail |
public AlgorithmIdentifier()
public AlgorithmIdentifier(String algorithm)
throws NoSuchAlgorithmException
algorithm - The JCE standard algorithm name.NoSuchAlgorithmException - if the name cannot be resolved to an OID or the OID has a
bad syntax.NullPointerException - if algorithm is null.
public AlgorithmIdentifier(ASN1ObjectIdentifier oid,
byte[] b)
throws ASN1Exception
oid - The algorithm object identifier.b - The opaque DER encoding of the parameters for the
algorithm known under the given OID. If no parameters are
required then null might be passed. In that
case ASN.1 NULL is encoded.ASN1Exception - if the opaque representation does not contain a valid DER
header and contents octets.
public AlgorithmIdentifier(String alg,
AlgorithmParameters params)
throws InvalidAlgorithmParameterException
JCA#getOID.
alg - The name of the algorithm.params - The AlgorithmParameters.NullPointerException - if alg is null.InvalidAlgorithmParameterException - if the given parameters have a bad encoding, or the OID
of the algorithm cannot be determined.
public AlgorithmIdentifier(ASN1ObjectIdentifier oid,
ASN1Type params)
throws ASN1Exception
null then an ASN.1 NULL is encoded.oid - The OID to use.params - The ASN.1 type of which the parameters consist.InconsistentStateException - if an internal error occurs; this should never happen.ASN1Exception - if the given parameters cannot be encoded. This should
rarely happen.| Method Detail |
public static AlgorithmIdentifier createAlgorithmIdentifier(Key key)
throws CorruptedCodeException
AlgorithmIdentifier from the given
key. The key must be either a public key or a private key. No secret
(symmetric) keys are accepted.
The keys encoding must be either a a PrivateKeyInfo or a SubjectPublicKeyInfo.
key - The key from which the AlgorithmIdentifier shall be
extracted.IllegalArgumentException - if the given key is neither a PublicKey or a PrivateKey.CorruptedCodeException - if an exception was caught while decoding the key's
encoding.
public AlgorithmParameters getParameters()
throws NoSuchAlgorithmException,
InvalidAlgorithmParameterException
AlgorithmParameters implementation if it is available from the JCE
compliant security providers that are installed locally.
Such providers need to specify the following aliases for this to work:
This method may be called only if this instance is initialized properly either by specifying AlgorithmParameters in a constructor or by parsing a valid ASN.1/DER encoding.
null if none are
enclosed in this structure.NoSuchAlgorithmException - if no matching AlgorithmParameters engine is found.InvalidAlgorithmParameterException - if the parameters cannot be decoded properly.public ASN1ObjectIdentifier getAlgorithmOID()
public String getAlgorithmName()
This method calls JCA.getName() with the
string representation of this instance's
object identifier.
If you are retrieving the parameters anyway then
avoid calling this method and call
getAlgorithm on
the parameter instance instead.
public String toString()
toString in class ASN1AbstractCollectionpublic boolean equals(Object o)
true if the given object is an
instance of this class or a subclass thereof and the algorithm OID of the
given object equals this object's algorithm OID.equals in class AbstractListtrue if the given object equals this one.public int hashCode()
hashCode in class AbstractListpublic Object clone()
clone in class ArrayList
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||