Package org.apache.kerby.asn1.type
Class Asn1Encodeable
java.lang.Object
org.apache.kerby.asn1.type.Asn1Object
org.apache.kerby.asn1.type.Asn1Encodeable
- All Implemented Interfaces:
Asn1Type
- Direct Known Subclasses:
AbstractAsn1Type
The abstract ASN1 object for all the ASN1 types. It provides basic
encoding and decoding utilities.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.kerby.asn1.type.Asn1Type
Asn1Type.EncodingType -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAsn1Encodeable(int tag) Constructor with a tagAsn1Encodeable(Tag tag) Constructor with a tagDefault constructor with an universal tag. -
Method Summary
Modifier and TypeMethodDescriptionvoiddecode(byte[] content) Decode the content bytes into this type.voiddecode(ByteBuffer content) Decode the content bytes into this type.voiddecode(Asn1ParseResult parseResult) protected abstract voiddecodeBody(Asn1ParseResult parseResult) byte[]encode()Encode the type, by recursively.voidencode(ByteBuffer buffer) Encode the type, by recursively, using the provided buffer.protected voidencodeBody(ByteBuffer buffer) protected abstract intprotected intintGet length of encoding bytes by just calculating without real encoding.protected intprotected intbooleanisBER()Tells if it's is BERbooleanisCER()Tells if it's is CERbooleanTells if it's definitive length or not.booleanisDER()Tells if it's is DERbooleanTells if it's is IMPLICIT or not.booleanTells if it is PRIMITIVE or not.voidvoidtaggedDecode(byte[] content, TaggingOption taggingOption) Decode the content bytes into this type as it's tagged with the provided tagging option.voidtaggedDecode(ByteBuffer content, TaggingOption taggingOption) Decode the content bytes into this type as it's tagged with the provided tagging option.voidtaggedDecode(Asn1ParseResult parseResult, TaggingOption taggingOption) voidtaggedEncode(ByteBuffer buffer, TaggingOption taggingOption) Tag and encode this type using the provided tagging option.byte[]taggedEncode(TaggingOption taggingOption) Tag and encode this type using the provided tagging option.protected inttaggedEncodingLength(TaggingOption taggingOption) voiduseBER()Set encoding type as BER.voiduseCER()Set encoding type as CER.voiduseDefinitiveLength(boolean isDefinitiveLength) Use definitive length or not.voiduseDER()Set encoding type as DER.voiduseImplicit(boolean isImplicit) Use implicit or not.voidusePrimitive(boolean isPrimitive) Use primitive or constructed.Methods inherited from class org.apache.kerby.asn1.type.Asn1Object
isAppSpecific, isCollection, isContextSpecific, isEOC, isNull, isSimple, isTagSpecific, isUniversal, simpleInfo, tag, tagFlags, tagNo
-
Field Details
-
bodyLength
protected int bodyLength -
outerEncodeable
-
-
Constructor Details
-
Asn1Encodeable
Constructor with a tag- Parameters:
tag- The tag
-
Asn1Encodeable
Default constructor with an universal tag.- Parameters:
tag- the tag
-
Asn1Encodeable
public Asn1Encodeable(int tag) Constructor with a tag- Parameters:
tag- The tag
-
-
Method Details
-
usePrimitive
public void usePrimitive(boolean isPrimitive) Description copied from interface:Asn1TypeUse primitive or constructed.- Specified by:
usePrimitivein interfaceAsn1Type- Overrides:
usePrimitivein classAsn1Object
-
isPrimitive
public boolean isPrimitive()Description copied from interface:Asn1TypeTells if it is PRIMITIVE or not.- Specified by:
isPrimitivein interfaceAsn1Type- Overrides:
isPrimitivein classAsn1Object- Returns:
- true if using PRIMITIVE, false otherwise
-
useDefinitiveLength
public void useDefinitiveLength(boolean isDefinitiveLength) Description copied from interface:Asn1TypeUse definitive length or not. Note definitive length only makes sense when it's constructed.- Specified by:
useDefinitiveLengthin interfaceAsn1Type
-
isDefinitiveLength
public boolean isDefinitiveLength()Description copied from interface:Asn1TypeTells if it's definitive length or not.- Specified by:
isDefinitiveLengthin interfaceAsn1Type- Returns:
- The boolean value
-
useImplicit
public void useImplicit(boolean isImplicit) Description copied from interface:Asn1TypeUse implicit or not.- Specified by:
useImplicitin interfaceAsn1Type
-
isImplicit
public boolean isImplicit()Description copied from interface:Asn1TypeTells if it's is IMPLICIT or not.- Specified by:
isImplicitin interfaceAsn1Type- Returns:
- true if using IMPLICIT, false otherwise
-
useDER
public void useDER()Description copied from interface:Asn1TypeSet encoding type as DER. -
isDER
public boolean isDER()Description copied from interface:Asn1TypeTells if it's is DER -
useBER
public void useBER()Description copied from interface:Asn1TypeSet encoding type as BER. -
isBER
public boolean isBER()Description copied from interface:Asn1TypeTells if it's is BER -
useCER
public void useCER()Description copied from interface:Asn1TypeSet encoding type as CER. -
isCER
public boolean isCER()Description copied from interface:Asn1TypeTells if it's is CER -
encode
Description copied from interface:Asn1TypeEncode the type, by recursively.- Specified by:
encodein interfaceAsn1Type- Returns:
- encoded bytes
- Throws:
IOException
-
encode
Description copied from interface:Asn1TypeEncode the type, by recursively, using the provided buffer.- Specified by:
encodein interfaceAsn1Type- Parameters:
buffer- The byte buffer- Throws:
IOException
-
resetBodyLength
public void resetBodyLength() -
encodeBody
- Throws:
IOException
-
decode
Description copied from interface:Asn1TypeDecode the content bytes into this type.- Specified by:
decodein interfaceAsn1Type- Parameters:
content- The content bytes- Throws:
IOException- e
-
encodingLength
public int encodingLength()Description copied from interface:Asn1TypeGet length of encoding bytes by just calculating without real encoding. Generally it's called to prepare for the encoding buffer.- Specified by:
encodingLengthin interfaceAsn1Type- Returns:
- length of encoding bytes
-
getHeaderLength
protected int getHeaderLength()- Specified by:
getHeaderLengthin classAsn1Object
-
getBodyLength
protected int getBodyLength()- Specified by:
getBodyLengthin classAsn1Object
-
encodingHeaderLength
- Throws:
IOException
-
encodingBodyLength
- Throws:
IOException
-
decode
Description copied from interface:Asn1TypeDecode the content bytes into this type.- Specified by:
decodein interfaceAsn1Type- Parameters:
content- The content bytes- Throws:
IOException- e
-
decode
- Throws:
IOException
-
decodeBody
- Throws:
IOException
-
taggedEncodingLength
-
taggedEncode
Description copied from interface:Asn1TypeTag and encode this type using the provided tagging option.- Specified by:
taggedEncodein interfaceAsn1Type- Parameters:
taggingOption- The tagging option- Returns:
- encoded bytes
- Throws:
IOException
-
taggedEncode
Description copied from interface:Asn1TypeTag and encode this type using the provided tagging option.- Specified by:
taggedEncodein interfaceAsn1Type- Parameters:
buffer- The byte buffertaggingOption- The tagging option- Throws:
IOException
-
taggedDecode
Description copied from interface:Asn1TypeDecode the content bytes into this type as it's tagged with the provided tagging option. SeeTaggingOption- Specified by:
taggedDecodein interfaceAsn1Type- Parameters:
content- The content bytestaggingOption- The tagging option- Throws:
IOException- e
-
taggedDecode
Description copied from interface:Asn1TypeDecode the content bytes into this type as it's tagged with the provided tagging option. SeeTaggingOption- Specified by:
taggedDecodein interfaceAsn1Type- Parameters:
content- The content bytestaggingOption- The tagging option- Throws:
IOException- e
-
taggedDecode
public void taggedDecode(Asn1ParseResult parseResult, TaggingOption taggingOption) throws IOException - Throws:
IOException
-