Package org.apache.harmony.security.asn1
Class ASN1Type
- java.lang.Object
-
- org.apache.harmony.security.asn1.ASN1Type
-
- All Implemented Interfaces:
ASN1Constants
- Direct Known Subclasses:
ASN1Any,ASN1Choice,ASN1Constructed,ASN1Implicit,ASN1Primitive,ASN1StringType
public abstract class ASN1Type extends Object implements ASN1Constants
This abstract class is the super class for all ASN.1 types- See Also:
- ASN.1
-
-
Field Summary
Fields Modifier and Type Field Description intconstrIdInteger representation of constructed identifier.intidInteger representation of primitive identifier.-
Fields inherited from interface org.apache.harmony.security.asn1.ASN1Constants
CLASS_APPLICATION, CLASS_CONTEXTSPECIFIC, CLASS_PRIVATE, CLASS_UNIVERSAL, PC_CONSTRUCTED, PC_PRIMITIVE, TAG_ANY, TAG_BITSTRING, TAG_BMPSTRING, TAG_BOOLEAN, TAG_C_BITSTRING, TAG_C_GENERALIZEDTIME, TAG_C_OCTETSTRING, TAG_C_SEQUENCE, TAG_C_SEQUENCEOF, TAG_C_SET, TAG_C_SETOF, TAG_C_UTCTIME, TAG_C_UTF8STRING, TAG_CHOICE, TAG_EMBEDDEDPDV, TAG_ENUM, TAG_EXTERNAL, TAG_GENERALIZEDTIME, TAG_GENERALSTRING, TAG_GRAPHICSTRING, TAG_IA5STRING, TAG_INSTANCEOF, TAG_INTEGER, TAG_ISO646STRING, TAG_NULL, TAG_NUMERICSTRING, TAG_OBJDESCRIPTOR, TAG_OCTETSTRING, TAG_OID, TAG_PRINTABLESTRING, TAG_REAL, TAG_RELATIVEOID, TAG_SEQUENCE, TAG_SEQUENCEOF, TAG_SET, TAG_SETOF, TAG_T61STRING, TAG_TELETEXSTRING, TAG_UNIVERSALSTRING, TAG_UTCTIME, TAG_UTF8STRING, TAG_VIDEOTEXSTRING, TAG_VISIBLESTRING
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract booleancheckTag(int identifier)Tests provided identifier.Objectdecode(byte[] encoded)Objectdecode(byte[] encoded, int offset, int encodingLen)Objectdecode(InputStream in)abstract Objectdecode(BerInputStream in)Decodes ASN.1 type.byte[]encode(Object object)abstract voidencodeASN(BerOutputStream out)Encodes ASN.1 type.abstract voidencodeContent(BerOutputStream out)protected ObjectgetDecodedObject(BerInputStream in)Creates decoded object.intgetEncodedLength(BerOutputStream out)abstract voidsetEncodingContent(BerOutputStream out)StringtoString()Returns a string containing a concise, human-readable description of this object.voidverify(byte[] encoded)voidverify(InputStream in)
-
-
-
Constructor Detail
-
ASN1Type
public ASN1Type(int tagNumber)
Constructs a primitive, universal ASN.1 type.- Parameters:
tagNumber- - ASN.1 tag number- Throws:
IllegalArgumentException- - if tagNumber is invalid
-
ASN1Type
public ASN1Type(int tagClass, int tagNumber)Constructs an ASN.1 type.- Parameters:
tagClass- - tag class. MUST be CLASS_UNIVERSAL, CLASS_APPLICATION, CLASS_CONTEXTSPECIFIC, CLASS_PRIVATEtagNumber- - ASN.1 tag number.- Throws:
IllegalArgumentException- - if tagClass or tagNumber is invalid
-
-
Method Detail
-
decode
public final Object decode(byte[] encoded) throws IOException
- Throws:
IOException
-
decode
public final Object decode(byte[] encoded, int offset, int encodingLen) throws IOException
- Throws:
IOException
-
decode
public final Object decode(InputStream in) throws IOException
- Throws:
IOException
-
verify
public final void verify(byte[] encoded) throws IOException- Throws:
IOException
-
verify
public final void verify(InputStream in) throws IOException
- Throws:
IOException
-
encode
public final byte[] encode(Object object)
-
decode
public abstract Object decode(BerInputStream in) throws IOException
Decodes ASN.1 type.- Throws:
IOException- if an I/O error occurs or the end of the stream is reached
-
checkTag
public abstract boolean checkTag(int identifier)
Tests provided identifier.- Parameters:
identifier- identifier to be verified- Returns:
- true if identifier is associated with this ASN.1 type
-
getDecodedObject
protected Object getDecodedObject(BerInputStream in) throws IOException
Creates decoded object. Derived classes should override this method to provide creation for a selected class of objects during decoding. The default implementation returns an object created by decoding stream.- Throws:
IOException
-
encodeASN
public abstract void encodeASN(BerOutputStream out)
Encodes ASN.1 type.
-
encodeContent
public abstract void encodeContent(BerOutputStream out)
-
setEncodingContent
public abstract void setEncodingContent(BerOutputStream out)
-
getEncodedLength
public int getEncodedLength(BerOutputStream out)
-
toString
public String toString()
Description copied from class:ObjectReturns a string containing a concise, human-readable description of this object. Subclasses are encouraged to override this method and provide an implementation that takes into account the object's type and data. The default implementation is equivalent to the following expression:getClass().getName() + '@' + Integer.toHexString(hashCode())
See Writing a useful
toStringmethod if you intend implementing your owntoStringmethod.
-
-