Module jcifs

Class ASN1Util

java.lang.Object
org.codelibs.jcifs.smb.pac.ASN1Util

public final class ASN1Util extends Object
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 Type
    Method
    Description
    static <T> T
    as(Class<T> type, Object object)
    Casts an object to the specified type with type checking
    static <T> T
    as(Class<T> type, Enumeration<?> enumeration)
    Gets the next element from an enumeration and casts it to the specified type
    static <T extends org.bouncycastle.asn1.ASN1Primitive>
    T
    as(Class<T> type, org.bouncycastle.asn1.ASN1InputStream stream)
    Reads the next ASN.1 object from a stream and casts it to the specified type
    static <T extends org.bouncycastle.asn1.ASN1Primitive>
    T
    as(Class<T> type, org.bouncycastle.asn1.ASN1Sequence sequence, int index)
    Gets an element from an ASN1Sequence at the specified index and casts it to the specified type
    static <T extends org.bouncycastle.asn1.ASN1Primitive>
    T
    as(Class<T> type, org.bouncycastle.asn1.ASN1TaggedObject tagged)
    Extracts the base object from an ASN.1 tagged object and casts it to the specified type
    static <T extends org.bouncycastle.asn1.ASN1Primitive>
    T
    as(Class<T> type, org.bouncycastle.asn1.DLSequence sequence, int index)
    Gets an element from a DLSequence at the specified index and casts it to the specified type
    static 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • as

      public static <T> T as(Class<T> type, Object object) throws PACDecodingException
      Casts an object to the specified type with type checking
      Type Parameters:
      T - the target type
      Parameters:
      type - the target class type
      object - the object to cast
      Returns:
      object cast to type
      Throws:
      PACDecodingException - if types are incompatible
    • as

      public static <T> T as(Class<T> type, Enumeration<?> enumeration) throws PACDecodingException
      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 type
      enumeration - 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 type
      stream - the ASN.1 input stream
      Returns:
      next object from stream cast to type
      Throws:
      PACDecodingException - if types are incompatible
      IOException - 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 type
      tagged - 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 type
      sequence - the DLSequence
      index - 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 type
      sequence - the ASN1Sequence
      index - 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 number
      limit - the maximum length limit
      in - the ASN.1 input stream
      Returns:
      coded bytes of the tagged object
      Throws:
      IOException - if reading fails or tag mismatch