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

org.bouncycastle.asn1.x509

## Class Target

- java.lang.Object
- - org.bouncycastle.asn1.ASN1Object
  - - org.bouncycastle.asn1.x509.Target

- All Implemented Interfaces:
    ASN1Choice, ASN1Encodable, Encodable

      public class Target
      extends ASN1Object
      implements ASN1Choice

  Target structure used in target information extension for attribute certificates from RFC 3281.

           Target  ::= CHOICE {
             targetName          [0] GeneralName,
             targetGroup         [1] GeneralName,
             targetCert          [2] TargetCert
           }

  The targetCert field is currently not supported and must not be used according to RFC 3281.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `targetGroup`
    `static int` | `targetName`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Target(int type, GeneralName name)` Constructor from given details.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Target` | `getInstance(java.lang.Object obj)` Creates an instance of a Target from the given object.
    `GeneralName` | `getTargetGroup()`
    `GeneralName` | `getTargetName()`
    `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`

- - ### Field Detail

    - #### targetName

          public static final int targetName

      See Also:
        Constant Field Values

    - #### targetGroup

          public static final int targetGroup

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### Target

          public Target(int type,
                        GeneralName name)

      Constructor from given details.

      Exactly one of the parameters must be not `null`.

      Parameters:
        `type` - the choice type to apply to the name.
        `name` - the general name.
      Throws:
        `java.lang.IllegalArgumentException` - if type is invalid.

  - ### Method Detail

    - #### getInstance

          public static Target getInstance(java.lang.Object obj)

      Creates an instance of a Target from the given object.

      `obj` can be a Target or a `ASN1TaggedObject`

      Parameters:
        `obj` - The object.
      Returns:
        A Target instance.
      Throws:
        `java.lang.IllegalArgumentException` - if the given object cannot be interpreted as Target.

    - #### getTargetGroup

          public GeneralName getTargetGroup()

      Returns:
        Returns the targetGroup.

    - #### getTargetName

          public GeneralName getTargetName()

      Returns:
        Returns the targetName.

    - #### toASN1Primitive

          public ASN1Primitive toASN1Primitive()

      Produce an object suitable for an ASN1OutputStream. Returns:

               Target  ::= CHOICE {
                 targetName          [0] GeneralName,
                 targetGroup         [1] GeneralName,
                 targetCert          [2] TargetCert
               }

      Specified by:
        `toASN1Primitive` in interface `ASN1Encodable`
      Specified by:
        `toASN1Primitive` in class `ASN1Object`
      Returns:
        a ASN1Primitive