| java.lang.Object sun.security.util.DerValue
DerValue | public class DerValue (Code) | | Represents a single DER-encoded value. DER encoding rules are a subset
of the "Basic" Encoding Rules (BER), but they only support a single way
("Definite" encoding) to encode any given value.
All DER-encoded data are triples {type, length, data}. This
class represents such tagged values as they have been read (or constructed),
and provides structured access to the encoded data.
At this time, this class supports only a subset of the types of DER
data encodings which are defined. That subset is sufficient for parsing
most X.509 certificates, and working with selected additional formats
(such as PKCS #10 certificate requests, and some kinds of PKCS #7 data).
A note with respect to T61/Teletex strings: From RFC 1617, section 4.1.3
and RFC 2459, section 4.1.2.4., we assume that this kind of string will
contain ISO-8859-1 characters only.
version: 1.60, 10/10/06 author: David Brownell author: Amit Kapoor author: Hemma Prafullchandra |
Field Summary | |
final public static byte | TAG_APPLICATION | final public static byte | TAG_CONTEXT | final public static byte | TAG_PRIVATE | final public static byte | TAG_UNIVERSAL | protected DerInputBuffer | buffer | public DerInputStream | data The DER-encoded data of the value. | public byte | tag The DER tag of the value; one of the tag_ constants. | final public static byte | tag_BMPString Tag value indicating an ASN.1 "BMPString" value. | final public static byte | tag_BitString Tag value indicating an ASN.1 "BIT STRING" value. | final public static byte | tag_Boolean Tag value indicating an ASN.1 "BOOLEAN" value. | final public static byte | tag_Enumerated | final public static byte | tag_GeneralString Tag value indicating an ASN.1 "GenerallString" value. | final public static byte | tag_GeneralizedTime Tag value indicating an ASN.1 "GeneralizedTime" value. | final public static byte | tag_IA5String | final public static byte | tag_Integer Tag value indicating an ASN.1 "INTEGER" value. | final public static byte | tag_Null Tag value indicating an ASN.1 "NULL" value. | final public static byte | tag_ObjectId Tag value indicating an ASN.1 "OBJECT IDENTIFIER" value. | final public static byte | tag_OctetString Tag value indicating an ASN.1 "OCTET STRING" value. | final public static byte | tag_PrintableString | final public static byte | tag_Sequence Tag value indicating an ASN.1
"SEQUENCE" (zero to N elements, order is significant). | final public static byte | tag_SequenceOf Tag value indicating an ASN.1
"SEQUENCE OF" (one to N elements, order is significant). | final public static byte | tag_Set Tag value indicating an ASN.1
"SET" (zero to N members, order does not matter). | final public static byte | tag_SetOf Tag value indicating an ASN.1
"SET OF" (one to N members, order does not matter). | final public static byte | tag_T61String | final public static byte | tag_UTF8String Tag value indicating an ASN.1 "UTF8String" value. | final public static byte | tag_UniversalString Tag value indicating an ASN.1 "UniversalString" value. | final public static byte | tag_UtcTime Tag value indicating an ASN.1 "UTCTime" value. |
Constructor Summary | |
public | DerValue(String value) | public | DerValue(byte stringTag, String value) | public | DerValue(byte tag, byte[] data) Creates a DerValue from a tag and some DER-encoded data. | | DerValue(DerInputBuffer in) | public | DerValue(byte[] buf) Get an ASN.1/DER encoded datum from a buffer. | public | DerValue(byte[] buf, int offset, int len) Get an ASN.1/DER encoded datum from part of a buffer. | public | DerValue(InputStream in) Get an ASN1/DER encoded datum from an input stream. |
Method Summary | |
public static byte | createTag(byte tagClass, boolean form, byte val) Create the tag of the attribute. | public void | encode(DerOutputStream out) Encode an ASN1/DER encoded datum onto a DER output stream. | public boolean | equals(Object other) Returns true iff the other object is a DER value which
is bitwise equal to this one. | public boolean | equals(DerValue other) Bitwise equality comparison. | public String | getAsString() Returns the name component as a Java string, regardless of its
encoding restrictions (ASCII, T61, Printable, IA5, BMP, UTF8). | public String | getBMPString() Returns the ASN.1 BMP (Unicode) STRING value as a Java string. | public BigInteger | getBigInteger() Returns an ASN.1 INTEGER value as a BigInteger. | public byte[] | getBitString() Returns an ASN.1 BIT STRING value. | public byte[] | getBitString(boolean tagImplicit) Returns an ASN.1 BIT STRING value, with the tag assumed implicit
based on the parameter. | public boolean | getBoolean() | final public DerInputStream | getData() | public byte[] | getDataBytes() Helper routine to return all the bytes contained in the
DerInputStream associated with this object. | public int | getEnumerated() Returns an ASN.1 ENUMERATED value. | public String | getGeneralString() Returns the ASN.1 GENERAL STRING value as a Java String. | public Date | getGeneralizedTime() Returns a Date if the DerValue is GeneralizedTime. | public String | getIA5String() | public int | getInteger() Returns an ASN.1 INTEGER value as an integer. | public ObjectIdentifier | getOID() Returns an ASN.1 OBJECT IDENTIFIER. | public byte[] | getOctetString() | public String | getPrintableString() | public String | getT61String() | final public byte | getTag() | public Date | getUTCTime() Returns a Date if the DerValue is UtcTime. | public String | getUTF8String() Returns the ASN.1 UTF-8 STRING value as a Java String. | public BitArray | getUnalignedBitString() Returns an ASN.1 BIT STRING value that need not be byte-aligned. | public BitArray | getUnalignedBitString(boolean tagImplicit) Returns an ASN.1 BIT STRING value, with the tag assumed implicit
based on the parameter. | public int | hashCode() Returns a hashcode for this DerValue. | public boolean | isApplication() Returns true if the tag class is APPLICATION. | public boolean | isConstructed() Returns true iff the CONSTRUCTED bit is set in the type tag. | public boolean | isConstructed(byte constructedTag) Returns true iff the CONSTRUCTED TAG matches the passed tag. | public boolean | isContextSpecific() Returns true iff the CONTEXT SPECIFIC bit is set in the type tag. | public boolean | isContextSpecific(byte cntxtTag) Returns true iff the CONTEXT SPECIFIC TAG matches the passed tag. | public static boolean | isPrintableStringChar(char ch) Determine if a character is one of the permissible characters for
PrintableString:
A-Z, a-z, 0-9, space, apostrophe (39), left and right parentheses,
plus sign, comma, hyphen, period, slash, colon, equals sign,
and question mark. | boolean | isPrivate() | public boolean | isUniversal() Returns true if the tag class is UNIVERSAL. | public int | length() Get the length of the encoded value. | public void | resetTag(byte tag) Set the tag of the attribute. | public byte[] | toByteArray() Returns a DER-encoded value, such that if it's passed to the
DerValue constructor, a value equivalent to "this" is returned. | public DerInputStream | toDerInputStream() For "set" and "sequence" types, this function may be used
to return a DER stream of the members of the set or sequence. | public String | toString() Returns a printable representation of the value. |
TAG_APPLICATION | final public static byte TAG_APPLICATION(Code) | | |
TAG_CONTEXT | final public static byte TAG_CONTEXT(Code) | | |
TAG_PRIVATE | final public static byte TAG_PRIVATE(Code) | | |
TAG_UNIVERSAL | final public static byte TAG_UNIVERSAL(Code) | | The tag class types
|
tag | public byte tag(Code) | | The DER tag of the value; one of the tag_ constants.
|
tag_BMPString | final public static byte tag_BMPString(Code) | | Tag value indicating an ASN.1 "BMPString" value.
|
tag_BitString | final public static byte tag_BitString(Code) | | Tag value indicating an ASN.1 "BIT STRING" value.
|
tag_Boolean | final public static byte tag_Boolean(Code) | | Tag value indicating an ASN.1 "BOOLEAN" value.
|
tag_Enumerated | final public static byte tag_Enumerated(Code) | | Tag value including an ASN.1 "ENUMERATED" value
|
tag_GeneralString | final public static byte tag_GeneralString(Code) | | Tag value indicating an ASN.1 "GenerallString" value.
|
tag_GeneralizedTime | final public static byte tag_GeneralizedTime(Code) | | Tag value indicating an ASN.1 "GeneralizedTime" value.
|
tag_IA5String | final public static byte tag_IA5String(Code) | | Tag value including an ASCII string
|
tag_Integer | final public static byte tag_Integer(Code) | | Tag value indicating an ASN.1 "INTEGER" value.
|
tag_Null | final public static byte tag_Null(Code) | | Tag value indicating an ASN.1 "NULL" value.
|
tag_ObjectId | final public static byte tag_ObjectId(Code) | | Tag value indicating an ASN.1 "OBJECT IDENTIFIER" value.
|
tag_OctetString | final public static byte tag_OctetString(Code) | | Tag value indicating an ASN.1 "OCTET STRING" value.
|
tag_PrintableString | final public static byte tag_PrintableString(Code) | | Tag value including a "printable" string
|
tag_Sequence | final public static byte tag_Sequence(Code) | | Tag value indicating an ASN.1
"SEQUENCE" (zero to N elements, order is significant).
|
tag_SequenceOf | final public static byte tag_SequenceOf(Code) | | Tag value indicating an ASN.1
"SEQUENCE OF" (one to N elements, order is significant).
|
tag_Set | final public static byte tag_Set(Code) | | Tag value indicating an ASN.1
"SET" (zero to N members, order does not matter).
|
tag_SetOf | final public static byte tag_SetOf(Code) | | Tag value indicating an ASN.1
"SET OF" (one to N members, order does not matter).
|
tag_T61String | final public static byte tag_T61String(Code) | | Tag value including a "teletype" string
|
tag_UTF8String | final public static byte tag_UTF8String(Code) | | Tag value indicating an ASN.1 "UTF8String" value.
|
tag_UniversalString | final public static byte tag_UniversalString(Code) | | Tag value indicating an ASN.1 "UniversalString" value.
|
tag_UtcTime | final public static byte tag_UtcTime(Code) | | Tag value indicating an ASN.1 "UTCTime" value.
|
DerValue | public DerValue(String value) throws IOException(Code) | | Creates a PrintableString or UTF8string DER value from a string
|
DerValue | public DerValue(byte stringTag, String value) throws IOException(Code) | | Creates a string type DER value from a String object
Parameters: stringTag - the tag for the DER value to create Parameters: value - the String object to use for the DER value |
DerValue | public DerValue(byte tag, byte[] data)(Code) | | Creates a DerValue from a tag and some DER-encoded data.
Parameters: tag - the DER type tag Parameters: data - the DER-encoded data |
DerValue | public DerValue(byte[] buf) throws IOException(Code) | | Get an ASN.1/DER encoded datum from a buffer. The
entire buffer must hold exactly one datum, including
its tag and length.
Parameters: buf - buffer holding a single DER-encoded datum. |
DerValue | public DerValue(byte[] buf, int offset, int len) throws IOException(Code) | | Get an ASN.1/DER encoded datum from part of a buffer.
That part of the buffer must hold exactly one datum, including
its tag and length.
Parameters: buf - the buffer Parameters: offset - start point of the single DER-encoded dataum Parameters: length - how many bytes are in the encoded datum |
DerValue | public DerValue(InputStream in) throws IOException(Code) | | Get an ASN1/DER encoded datum from an input stream. The
stream may have additional data following the encoded datum.
In case of indefinite length encoded datum, the input stream
must hold only one datum.
Parameters: in - the input stream holding a single DER datum,which may be followed by additional data |
createTag | public static byte createTag(byte tagClass, boolean form, byte val)(Code) | | Create the tag of the attribute.
|
equals | public boolean equals(Object other)(Code) | | Returns true iff the other object is a DER value which
is bitwise equal to this one.
Parameters: other - the object being compared with this one |
equals | public boolean equals(DerValue other)(Code) | | Bitwise equality comparison. DER encoded values have a single
encoding, so that bitwise equality of the encoded values is an
efficient way to establish equivalence of the unencoded values.
Parameters: other - the object being compared with this one |
getAsString | public String getAsString() throws IOException(Code) | | Returns the name component as a Java string, regardless of its
encoding restrictions (ASCII, T61, Printable, IA5, BMP, UTF8).
|
getBMPString | public String getBMPString() throws IOException(Code) | | Returns the ASN.1 BMP (Unicode) STRING value as a Java string.
a string corresponding to the encoded BMPString held in this value |
getBigInteger | public BigInteger getBigInteger() throws IOException(Code) | | Returns an ASN.1 INTEGER value as a BigInteger.
the integer held in this DER value as a BigInteger. |
getBitString | public byte[] getBitString() throws IOException(Code) | | Returns an ASN.1 BIT STRING value. The bit string must be byte-aligned.
the bit string held in this value |
getBitString | public byte[] getBitString(boolean tagImplicit) throws IOException(Code) | | Returns an ASN.1 BIT STRING value, with the tag assumed implicit
based on the parameter. The bit string must be byte-aligned.
the bit string held in this value |
getBoolean | public boolean getBoolean() throws IOException(Code) | | Returns an ASN.1 BOOLEAN
the boolean held in this DER value |
getDataBytes | public byte[] getDataBytes() throws IOException(Code) | | Helper routine to return all the bytes contained in the
DerInputStream associated with this object.
|
getEnumerated | public int getEnumerated() throws IOException(Code) | | Returns an ASN.1 ENUMERATED value.
the integer held in this DER value. |
getGeneralString | public String getGeneralString() throws IOException(Code) | | Returns the ASN.1 GENERAL STRING value as a Java String.
a string corresponding to the encoded GeneralString held in this value |
getGeneralizedTime | public Date getGeneralizedTime() throws IOException(Code) | | Returns a Date if the DerValue is GeneralizedTime.
the Date held in this DER value |
getIA5String | public String getIA5String() throws IOException(Code) | | Returns an ASN.1 IA5 (ASCII) STRING value
the ASCII string held in this value |
getInteger | public int getInteger() throws IOException(Code) | | Returns an ASN.1 INTEGER value as an integer.
the integer held in this DER value. |
getOctetString | public byte[] getOctetString() throws IOException(Code) | | Returns an ASN.1 OCTET STRING
the octet string held in this DER value |
getPrintableString | public String getPrintableString() throws IOException(Code) | | Returns an ASN.1 STRING value
the printable string held in this value |
getT61String | public String getT61String() throws IOException(Code) | | Returns an ASN.1 T61 (Teletype) STRING value
the teletype string held in this value |
getTag | final public byte getTag()(Code) | | |
getUTCTime | public Date getUTCTime() throws IOException(Code) | | Returns a Date if the DerValue is UtcTime.
the Date held in this DER value |
getUTF8String | public String getUTF8String() throws IOException(Code) | | Returns the ASN.1 UTF-8 STRING value as a Java String.
a string corresponding to the encoded UTF8String held in this value |
getUnalignedBitString | public BitArray getUnalignedBitString() throws IOException(Code) | | Returns an ASN.1 BIT STRING value that need not be byte-aligned.
a BitArray representing the bit string held in this value |
getUnalignedBitString | public BitArray getUnalignedBitString(boolean tagImplicit) throws IOException(Code) | | Returns an ASN.1 BIT STRING value, with the tag assumed implicit
based on the parameter. The bit string need not be byte-aligned.
the bit string held in this value |
hashCode | public int hashCode()(Code) | | Returns a hashcode for this DerValue.
a hashcode for this DerValue. |
isApplication | public boolean isApplication()(Code) | | Returns true if the tag class is APPLICATION.
|
isConstructed | public boolean isConstructed()(Code) | | Returns true iff the CONSTRUCTED bit is set in the type tag.
|
isConstructed | public boolean isConstructed(byte constructedTag)(Code) | | Returns true iff the CONSTRUCTED TAG matches the passed tag.
|
isContextSpecific | public boolean isContextSpecific()(Code) | | Returns true iff the CONTEXT SPECIFIC bit is set in the type tag.
This is associated with the ASN.1 "DEFINED BY" syntax.
|
isContextSpecific | public boolean isContextSpecific(byte cntxtTag)(Code) | | Returns true iff the CONTEXT SPECIFIC TAG matches the passed tag.
|
isPrintableStringChar | public static boolean isPrintableStringChar(char ch)(Code) | | Determine if a character is one of the permissible characters for
PrintableString:
A-Z, a-z, 0-9, space, apostrophe (39), left and right parentheses,
plus sign, comma, hyphen, period, slash, colon, equals sign,
and question mark.
Characters that are *not* allowed in PrintableString include
exclamation point, quotation mark, number sign, dollar sign,
percent sign, ampersand, asterisk, semicolon, less than sign,
greater than sign, at sign, left and right square brackets,
backslash, circumflex (94), underscore, back quote (96),
left and right curly brackets, vertical line, tilde,
and the control codes (0-31 and 127).
This list is based on X.680 (the ASN.1 spec).
|
isPrivate | boolean isPrivate()(Code) | | |
isUniversal | public boolean isUniversal()(Code) | | Returns true if the tag class is UNIVERSAL.
|
length | public int length()(Code) | | Get the length of the encoded value.
|
resetTag | public void resetTag(byte tag)(Code) | | Set the tag of the attribute. Commonly used to reset the
tag value used for IMPLICIT encodings.
|
toByteArray | public byte[] toByteArray() throws IOException(Code) | | Returns a DER-encoded value, such that if it's passed to the
DerValue constructor, a value equivalent to "this" is returned.
DER-encoded value, including tag and length. |
toDerInputStream | public DerInputStream toDerInputStream() throws IOException(Code) | | For "set" and "sequence" types, this function may be used
to return a DER stream of the members of the set or sequence.
This operation is not supported for primitive types such as
integers or bit strings.
|
toString | public String toString()(Code) | | Returns a printable representation of the value.
printable representation of the value |
|
|