java.lang.Object
org.codelibs.jcifs.smb.pac.ASN1Util
Utility class for ASN.1 parsing and manipulation operations.
This class provides helper methods for working with ASN.1
encoded data structures used in Kerberos PAC processing.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TCasts an object to the specified type with type checkingstatic <T> Tas(Class<T> type, Enumeration<?> enumeration) Gets the next element from an enumeration and casts it to the specified typestatic <T extends org.bouncycastle.asn1.ASN1Primitive>
TReads the next ASN.1 object from a stream and casts it to the specified typestatic <T extends org.bouncycastle.asn1.ASN1Primitive>
TGets an element from an ASN1Sequence at the specified index and casts it to the specified typestatic <T extends org.bouncycastle.asn1.ASN1Primitive>
TExtracts the base object from an ASN.1 tagged object and casts it to the specified typestatic <T extends org.bouncycastle.asn1.ASN1Primitive>
TGets an element from a DLSequence at the specified index and casts it to the specified typestatic byte[]readUnparsedTagged(int expectTag, int limit, org.bouncycastle.asn1.ASN1InputStream in) Read a tagged object without parsing it's contents BC no longer seems to allow that out of the box
-
Method Details
-
as
Casts an object to the specified type with type checking- Type Parameters:
T- the target type- Parameters:
type- the target class typeobject- the object to cast- Returns:
- object cast to type
- Throws:
PACDecodingException- if types are incompatible
-
as
Gets the next element from an enumeration and casts it to the specified type- Type Parameters:
T- the target type- Parameters:
type- the target class typeenumeration- the enumeration to read from- Returns:
- next element from enumeration cast to type
- Throws:
PACDecodingException- if types are incompatible
-
as
public static <T extends org.bouncycastle.asn1.ASN1Primitive> T as(Class<T> type, org.bouncycastle.asn1.ASN1InputStream stream) throws PACDecodingException, IOException Reads the next ASN.1 object from a stream and casts it to the specified type- Type Parameters:
T- the target ASN.1 primitive type- Parameters:
type- the target class typestream- the ASN.1 input stream- Returns:
- next object from stream cast to type
- Throws:
PACDecodingException- if types are incompatibleIOException- if reading from stream fails
-
as
public static <T extends org.bouncycastle.asn1.ASN1Primitive> T as(Class<T> type, org.bouncycastle.asn1.ASN1TaggedObject tagged) throws PACDecodingException Extracts the base object from an ASN.1 tagged object and casts it to the specified type- Type Parameters:
T- the target ASN.1 primitive type- Parameters:
type- the target class typetagged- the ASN.1 tagged object- Returns:
- tagged object contents cast to type
- Throws:
PACDecodingException- if types are incompatible
-
as
public static <T extends org.bouncycastle.asn1.ASN1Primitive> T as(Class<T> type, org.bouncycastle.asn1.DLSequence sequence, int index) throws PACDecodingException Gets an element from a DLSequence at the specified index and casts it to the specified type- Type Parameters:
T- the target ASN.1 primitive type- Parameters:
type- the target class typesequence- the DLSequenceindex- the element index- Returns:
- sequence element cast to type
- Throws:
PACDecodingException- if types are incompatible
-
as
public static <T extends org.bouncycastle.asn1.ASN1Primitive> T as(Class<T> type, org.bouncycastle.asn1.ASN1Sequence sequence, int index) throws PACDecodingException Gets an element from an ASN1Sequence at the specified index and casts it to the specified type- Type Parameters:
T- the target ASN.1 primitive type- Parameters:
type- the target class typesequence- the ASN1Sequenceindex- the element index- Returns:
- sequence element cast to type
- Throws:
PACDecodingException- if types are incompatible
-
readUnparsedTagged
public static byte[] readUnparsedTagged(int expectTag, int limit, org.bouncycastle.asn1.ASN1InputStream in) throws IOException Read a tagged object without parsing it's contents BC no longer seems to allow that out of the box- Parameters:
expectTag- the expected tag numberlimit- the maximum length limitin- the ASN.1 input stream- Returns:
- coded bytes of the tagged object
- Throws:
IOException- if reading fails or tag mismatch
-