OtherKeyAttribute (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.asn1.cms

## Class OtherKeyAttribute

- java.lang.Object
- - org.bouncycastle.asn1.ASN1Object
  - - org.bouncycastle.asn1.cms.OtherKeyAttribute

- All Implemented Interfaces:
    ASN1Encodable, Encodable

      public class OtherKeyAttribute
      extends ASN1Object

  RFC 5652: OtherKeyAttribute object.

       OtherKeyAttribute ::= SEQUENCE {
           keyAttrId OBJECT IDENTIFIER,
           keyAttr ANY DEFINED BY keyAttrId OPTIONAL
       }

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `OtherKeyAttribute(ASN1ObjectIdentifier keyAttrId, ASN1Encodable keyAttr)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static OtherKeyAttribute` | `getInstance(java.lang.Object o)` Return an OtherKeyAttribute object from the given object.
    `ASN1Encodable` | `getKeyAttr()`
    `ASN1ObjectIdentifier` | `getKeyAttrId()`
    `ASN1Primitive` | `toASN1Primitive()` Produce an object suitable for an ASN1OutputStream.

    - ### Methods inherited from class org.bouncycastle.asn1.ASN1Object

      `encodeTo, encodeTo, equals, getEncoded, getEncoded, hasEncodedTagValue, hashCode`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### OtherKeyAttribute

          public OtherKeyAttribute(ASN1ObjectIdentifier keyAttrId,
                                   ASN1Encodable keyAttr)

  - ### Method Detail

    - #### getInstance

          public static OtherKeyAttribute getInstance(java.lang.Object o)

      Return an OtherKeyAttribute object from the given object.

      Accepted inputs:

      - null → null
      - `OtherKeyAttribute` object
      - `ASN1Sequence` input formats with OtherKeyAttribute structure inside
      Parameters:
        `o` - the object we want converted.
      Throws:
        `java.lang.IllegalArgumentException` - if the object cannot be converted.

    - #### getKeyAttrId

          public ASN1ObjectIdentifier getKeyAttrId()

    - #### getKeyAttr

          public ASN1Encodable getKeyAttr()

    - #### toASN1Primitive

          public ASN1Primitive toASN1Primitive()

      Produce an object suitable for an ASN1OutputStream.
      Specified by:
        `toASN1Primitive` in interface `ASN1Encodable`
      Specified by:
        `toASN1Primitive` in class `ASN1Object`
      Returns:
        a primitive representation of this object.