Package org.wildfly.security.asn1
Interface ASN1Decoder
- 
- All Known Implementing Classes:
- DERDecoder
 
 public interface ASN1DecoderAn interface for decoding ASN.1 encoded values from an input stream.- Author:
- Farah Juma
 
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description byte[]decodeBitString()Decode the next ASN.1 element as a bit string.BigIntegerdecodeBitStringAsInteger()Decode the next ASN.1 element as a bit string where the value is a ASN.1 INTEGER.StringdecodeBitStringAsString()Decode the next ASN.1 element as a bit string.default StringdecodeBMPString()Decode the next ASN.1 element as an BMPString.default byte[]decodeBMPStringAsBytes()Decode the next ASN.1 element as an BMPString.booleandecodeBoolean()Decode the next ASN.1 element as a boolean value.StringdecodeIA5String()Decode the next ASN.1 element as an IA5 string.byte[]decodeIA5StringAsBytes()Decode the next ASN.1 element as an IA5 string.voiddecodeImplicit(int number)Indicate that the next ASN.1 element has the given implicit, context-specific tag.voiddecodeImplicit(int clazz, int number)Indicate that the next ASN.1 element has the given implicit tag.BigIntegerdecodeInteger()Decode the next ASN.1 element as an integer.voiddecodeNull()Decode the next ASN.1 element as a null element.StringdecodeObjectIdentifier()Decode the next ASN.1 element as an object identifier.byte[]decodeOctetString()Decode the next ASN.1 element as an octet string.StringdecodeOctetStringAsString()Decode the next ASN.1 element as an octet string.StringdecodeOctetStringAsString(String charSet)Decode the next ASN.1 element as an octet string.StringdecodePrintableString()Decode the next ASN.1 element as a PrintableString.byte[]decodePrintableStringAsBytes()Decode the next ASN.1 element as a PrintableString.default StringdecodeUniversalString()Decode the next ASN.1 element as an UniversalString.default byte[]decodeUniversalStringAsBytes()Decode the next ASN.1 element as an UniversalString.default StringdecodeUtf8String()Decode the next ASN.1 element as an UTF8String.default byte[]decodeUtf8StringAsBytes()Decode the next ASN.1 element as an UTF8String.byte[]drain()Drain all of the remaining bytes from the input stream.byte[]drainElement()Drain all of the bytes from the next ASN.1 element.byte[]drainElementValue()Drain the value bytes from the next ASN.1 element.voidendExplicit()Advance to the end of an explicitly tagged element.voidendSequence()Advance to the end of a sequence.voidendSet()Advance to the end of a set.voidendSetOf()Advance to the end of a "set of" element.booleanhasNextElement()Determine if there is at least one more ASN.1 element that can be read.booleanisNextType(int clazz, int number, boolean isConstructed)Determine if the type of the next ASN.1 element matches the given type without actually decoding the next element.intpeekType()Retrieve the type of the next ASN.1 element without actually decoding the next element.voidskipElement()Skip over the next ASN.1 element.voidstartExplicit(int number)Start decoding an ASN.1 explicitly tagged element.voidstartExplicit(int clazz, int number)Start decoding an ASN.1 explicitly tagged element.voidstartSequence()Start decoding an ASN.1 sequence.voidstartSet()Start decoding an ASN.1 set.voidstartSetOf()Start decoding an ASN.1 "set of" element.
 
- 
- 
- 
Method Detail- 
startSequencevoid startSequence() throws ASN1ExceptionStart decoding an ASN.1 sequence. All subsequent decode operations will decode elements from this sequence untilendSequence()is called.- Throws:
- ASN1Exception- if the next element is not a sequence
 
 - 
endSequencevoid endSequence() throws ASN1ExceptionAdvance to the end of a sequence. If there are any elements in the sequence that have not yet been decoded, they will be discarded.- Throws:
- ASN1Exception- if an error occurs while advancing to the end of the sequence
 
 - 
startSetvoid startSet() throws ASN1ExceptionStart decoding an ASN.1 set. All subsequent decode operations will decode elements from this set untilendSet()is called.- Throws:
- ASN1Exception- if the next element is not a set
 
 - 
endSetvoid endSet() throws ASN1ExceptionAdvance to the end of a set. If there are any elements in the set that have not yet been decoded, they will be discarded.- Throws:
- ASN1Exception- if an error occurs while advancing to the end of the set
 
 - 
startSetOfvoid startSetOf() throws ASN1ExceptionStart decoding an ASN.1 "set of" element. All subsequent decode operations will decode elements from this set untilendSetOf()is called.- Throws:
- ASN1Exception- if the next element is not a set
 
 - 
endSetOfvoid endSetOf() throws ASN1ExceptionAdvance to the end of a "set of" element. If there are any elements in the set that have not yet been decoded, they will be discarded.- Throws:
- ASN1Exception- if an error occurs while advancing to the end of the set
 
 - 
startExplicitvoid startExplicit(int number) throws ASN1ExceptionStart decoding an ASN.1 explicitly tagged element. All subsequent decode operations will decode elements from this explicitly tagged element untilendExplicit()is called.- Parameters:
- number- the tag number for the explicit, context-specific tag
- Throws:
- ASN1Exception- if the next element's type does not match the given type
 
 - 
startExplicitvoid startExplicit(int clazz, int number) throws ASN1ExceptionStart decoding an ASN.1 explicitly tagged element. All subsequent decode operations will decode elements from this explicitly tagged element untilendExplicit()is called.- Parameters:
- clazz- the class for the explicit tag
- number- the tag number for the explicit tag
- Throws:
- ASN1Exception- if the next element's type does not match the given type
 
 - 
endExplicitvoid endExplicit() throws ASN1ExceptionAdvance to the end of an explicitly tagged element. If there are any elements within the explicitly tagged element that have not yet been decoded, they will be discarded.- Throws:
- ASN1Exception- if an error occurs while advancing to the end of the explicitly tagged element
 
 - 
decodeOctetStringbyte[] decodeOctetString() throws ASN1ExceptionDecode the next ASN.1 element as an octet string.- Returns:
- the decoded octet string, as a byte array
- Throws:
- ASN1Exception- if the next element is not an octet string
 
 - 
decodeOctetStringAsStringString decodeOctetStringAsString() throws ASN1Exception Decode the next ASN.1 element as an octet string.- Returns:
- the decoded octet string, as a UTF-8 string
- Throws:
- ASN1Exception- if the next element is not an octet string
 
 - 
decodeOctetStringAsStringString decodeOctetStringAsString(String charSet) throws ASN1Exception Decode the next ASN.1 element as an octet string.- Parameters:
- charSet- the character set to use when decoding
- Returns:
- the decoded octet string
- Throws:
- ASN1Exception- if the next element is not an octet string
 
 - 
decodeIA5StringString decodeIA5String() throws ASN1Exception Decode the next ASN.1 element as an IA5 string.- Returns:
- the decoded IA5 string
- Throws:
- ASN1Exception- if the next element is not an IA5 string
 
 - 
decodeIA5StringAsBytesbyte[] decodeIA5StringAsBytes() throws ASN1ExceptionDecode the next ASN.1 element as an IA5 string.- Returns:
- the decoded IA5 string, as a byte array
- Throws:
- ASN1Exception- if the next element is not an IA5 string
 
 - 
decodeBitStringbyte[] decodeBitString() throws ASN1ExceptionDecode the next ASN.1 element as a bit string.- Returns:
- the decoded bit string as a byte array, with any unused bits removed
- Throws:
- ASN1Exception- if the next element is not a bit string
 
 - 
decodeBitStringAsIntegerBigInteger decodeBitStringAsInteger() Decode the next ASN.1 element as a bit string where the value is a ASN.1 INTEGER.- Returns:
- a BigIntegerdecoded from the bit string
- Throws:
- ASN1Exception- if the next element is not a bit string or its value is not an integer
 
 - 
decodeBitStringAsStringString decodeBitStringAsString() throws ASN1Exception Decode the next ASN.1 element as a bit string.- Returns:
- the decoded bit string as a binary string, with any unused bits removed
- Throws:
- ASN1Exception- if the next element is not a bit string
 
 - 
decodePrintableStringString decodePrintableString() throws ASN1Exception Decode the next ASN.1 element as a PrintableString.- Returns:
- the decoded PrintableString as a string
- Throws:
- ASN1Exception- if the next element is not a PrintableString
 
 - 
decodePrintableStringAsBytesbyte[] decodePrintableStringAsBytes() throws ASN1ExceptionDecode the next ASN.1 element as a PrintableString.- Returns:
- the decoded PrintableString as a byte array
- Throws:
- ASN1Exception- if the next element is not a PrintableString
 
 - 
decodeUniversalStringdefault String decodeUniversalString() throws ASN1Exception Decode the next ASN.1 element as an UniversalString.- Returns:
- the decoded UniversalString as a string
- Throws:
- ASN1Exception- if the next element is not a UniversalString
- UnsupportedOperationException- if this implementation does not provide this method
 
 - 
decodeUniversalStringAsBytesdefault byte[] decodeUniversalStringAsBytes() throws ASN1ExceptionDecode the next ASN.1 element as an UniversalString.- Returns:
- the decoded UniversalString as a byte array
- Throws:
- ASN1Exception- if the next element is not a UniversalString
- UnsupportedOperationException- if this implementation does not provide this method
 
 - 
decodeUtf8Stringdefault String decodeUtf8String() throws ASN1Exception Decode the next ASN.1 element as an UTF8String.- Returns:
- the decoded UTF8String as a string
- Throws:
- ASN1Exception- if the next element is not a UTF8String
- UnsupportedOperationException- if this implementation does not provide this method
 
 - 
decodeUtf8StringAsBytesdefault byte[] decodeUtf8StringAsBytes() throws ASN1ExceptionDecode the next ASN.1 element as an UTF8String.- Returns:
- the decoded UTF8String as a byte array
- Throws:
- ASN1Exception- if the next element is not a UTF8String
- UnsupportedOperationException- if this implementation does not provide this method
 
 - 
decodeBMPStringdefault String decodeBMPString() throws ASN1Exception Decode the next ASN.1 element as an BMPString.- Returns:
- the decoded BMPString as a string
- Throws:
- ASN1Exception- if the next element is not a BMPString
- UnsupportedOperationException- if this implementation does not provide this method
 
 - 
decodeBMPStringAsBytesdefault byte[] decodeBMPStringAsBytes() throws ASN1ExceptionDecode the next ASN.1 element as an BMPString.- Returns:
- the decoded BMPString as a byte array
- Throws:
- ASN1Exception- if the next element is not a BMPString
- UnsupportedOperationException- if this implementation does not provide this method
 
 - 
decodeObjectIdentifierString decodeObjectIdentifier() throws ASN1Exception Decode the next ASN.1 element as an object identifier.- Returns:
- the object identifier as a string
- Throws:
- ASN1Exception- if the next element is not a bit string
 
 - 
decodeIntegerBigInteger decodeInteger() Decode the next ASN.1 element as an integer.- Returns:
- an integer decoded from the next element
- Throws:
- ASN1Exception- if the next element is not an integer
 
 - 
decodeNullvoid decodeNull() throws ASN1ExceptionDecode the next ASN.1 element as a null element.- Throws:
- ASN1Exception- if the next element is not null
 
 - 
decodeImplicitvoid decodeImplicit(int number) Indicate that the next ASN.1 element has the given implicit, context-specific tag.- Parameters:
- number- the tag number for the implicit tag
 
 - 
decodeImplicitvoid decodeImplicit(int clazz, int number)Indicate that the next ASN.1 element has the given implicit tag.- Parameters:
- clazz- the class for the implicit tag
- number- the tag number for the implicit tag
 
 - 
decodeBooleanboolean decodeBoolean() throws ASN1ExceptionDecode the next ASN.1 element as a boolean value.- Returns:
- the decoded boolean value
- Throws:
- ASN1Exception- if the next element is not a boolean value
- Since:
- 1.2.0
 
 - 
isNextTypeboolean isNextType(int clazz, int number, boolean isConstructed)Determine if the type of the next ASN.1 element matches the given type without actually decoding the next element. This method can be used to determine if an optional ASN.1 value has been included in the encoding or not.- Parameters:
- clazz- the tag class to match against
- number- the tag number to match against
- isConstructed- whether or not the next element should be constructed
- Returns:
- trueif the type of the next ASN.1 element matches the given type and- falseotherwise
 
 - 
peekTypeint peekType() throws ASN1ExceptionRetrieve the type of the next ASN.1 element without actually decoding the next element.- Returns:
- the type of the next ASN.1 element
- Throws:
- ASN1Exception- if an error occurs while determining the type of the next element
 
 - 
skipElementvoid skipElement() throws ASN1ExceptionSkip over the next ASN.1 element.- Throws:
- ASN1Exception- if the next element cannot be skipped
 
 - 
hasNextElementboolean hasNextElement() Determine if there is at least one more ASN.1 element that can be read. If called while decoding a constructed element (i.e., while decoding a sequence, set, or explicitly tagged element), this method will return whether the constructed element has at least one more ASN.1 element that can be read. Otherwise, this method will return whether at least one more ASN.1 element can be read from the input stream.- Returns:
- trueif there is at least one more ASN.1 element that can be read and- falseotherwise
 
 - 
drainElementValuebyte[] drainElementValue() throws ASN1ExceptionDrain the value bytes from the next ASN.1 element.- Returns:
- the value bytes from the next ASN.1 element, as a byte array
- Throws:
- ASN1Exception- if the value bytes from the next ASN.1 element cannot be obtained
 
 - 
drainElementbyte[] drainElement() throws ASN1ExceptionDrain all of the bytes from the next ASN.1 element.- Returns:
- all of the bytes from the next ASN.1 element
- Throws:
- ASN1Exception- if the bytes from the next ASN.1 element cannot be obtained
 
 - 
drainbyte[] drain() Drain all of the remaining bytes from the input stream.- Returns:
- all of the remaining bytes from the input stream
 
 
- 
 
-