Package net.aifusion.asn
Class AsnValue
java.lang.Object
net.aifusion.asn.AsnValue
- Direct Known Subclasses:
BitStringValue
,BMPStringValue
,BooleanValue
,EnumeratedValue
,GeneralizedTimeValue
,IA5StringValue
,IntegerValue
,LargeInteger
,NoOpValue
,NullValue
,NumericStringValue
,OctetStringValue
,OidValue
,PrintableStringValue
,RealValue
,RelativeOidValue
,SequenceValue
,SetValue
,TaggedValue
,UTCTimeValue
,Utf8StringValue
,VisibleStringValue
Wrapper class for all ASN.1 values. This class manages the tag, and provides common methods used in subclasses,
while individual subclasses handle the actual values.
- Author:
- Sharad Singhal
-
Method Summary
Modifier and TypeMethodDescriptionstatic AsnValue
create
(byte[] buffer, int blen, int cursor) Create an ASN.1 value from a serialized value.abstract byte[]
Get the encoded value for this ASN.1 value.int
Get the encoded length of this valuegetTag()
Get the ASN.1 predefined (UNIVERSAL) tag associated with this valueGet the ASN.1 Tag class for this valueGet the ASN.1 Tag Encoding for this valuelong
Get the value of the tag associated with this valuetoAsnString
(String prefix) Get a (semi) ASN.1 notation for this value.static String
toHex
(byte b) static String
toHex
(byte[] bytes) static String
toHex
(byte[] bytes, int start, int end) static String
toHex
(long value)
-
Method Details
-
getTag
Get the ASN.1 predefined (UNIVERSAL) tag associated with this value- Returns:
- - associated tag, if any. Null if the tag is context specific or not a pre-defined tag
-
getTagNumber
public long getTagNumber()Get the value of the tag associated with this value- Returns:
- - long value containing the tag number
-
getTagClass
Get the ASN.1 Tag class for this value- Returns:
- - ASN.1 Tag Class
-
getTagEncoding
Get the ASN.1 Tag Encoding for this value- Returns:
- - ASN.1 Tag Encoding
-
getLength
public int getLength()Get the encoded length of this value- Returns:
- - encoded length of the value
-
getEncodedValue
public abstract byte[] getEncodedValue()Get the encoded value for this ASN.1 value. This method should be implemented by subclasses to provide the encoded ASN.1 value- Returns:
- byte [] containing encoded value for this ASN.1 value (including tag, length, content)
-
create
Create an ASN.1 value from a serialized value. This method dispatches the call to subclasses which should also implement the create method to construct and return the proper AsnValue.- Parameters:
buffer
- - input bufferblen
- - length of buffercursor
- - offset pointing to the first byte (tag) for the value- Returns:
- - parsed ASN.1 value
-
toAsnString
Get a (semi) ASN.1 notation for this value.- Parameters:
prefix
- - prefix to add to each line- Returns:
- - string containing the ASN.1 value
-
toHex
-
toHex
-
toHex
-
toHex
-