Package org.bouncycastle.asn1.x509

## Class ExtendedKeyUsage

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

- All Implemented Interfaces:
    `ASN1Encodable`, `Encodable`

      public class ExtendedKeyUsage
      extends ASN1Object

  The extendedKeyUsage object.

            extendedKeyUsage ::= SEQUENCE SIZE (1..MAX) OF KeyPurposeId

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ExtendedKeyUsage​(java.util.Vector usages)` | Deprecated. use KeyPurposeId[] constructor.
    `ExtendedKeyUsage​(KeyPurposeId usage)` | Base constructor, from a single KeyPurposeId.
    `ExtendedKeyUsage​(KeyPurposeId[] usages)` | Base constructor, from multiple KeyPurposeIds.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static ExtendedKeyUsage` | `fromExtensions​(Extensions extensions)` | Retrieve an ExtendedKeyUsage for a passed in Extensions object, if present.
    `static ExtendedKeyUsage` | `getInstance​(java.lang.Object obj)` | Return an ExtendedKeyUsage from the passed in object.
    `static ExtendedKeyUsage` | `getInstance​(ASN1TaggedObject obj, boolean explicit)` | Return an ExtendedKeyUsage from the passed in tagged object.
    `KeyPurposeId[]` | `getUsages()` | Returns all extended key usages.
    `boolean` | `hasKeyPurposeId​(KeyPurposeId keyPurposeId)` | Return true if this ExtendedKeyUsage object contains the passed in keyPurposeId.
    `int` | `size()` | Return the number of KeyPurposeIds present in this ExtendedKeyUsage.
    `ASN1Primitive` | `toASN1Primitive()` | Return the ASN.1 primitive form of this object.

    - ### 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

    - #### ExtendedKeyUsage

          public ExtendedKeyUsage​(KeyPurposeId usage)

      Base constructor, from a single KeyPurposeId.
      Parameters:
        `usage` - the keyPurposeId to be included.

    - #### ExtendedKeyUsage

          public ExtendedKeyUsage​(KeyPurposeId[] usages)

      Base constructor, from multiple KeyPurposeIds.
      Parameters:
        `usages` - an array of KeyPurposeIds.

    - #### ExtendedKeyUsage

          public ExtendedKeyUsage​(java.util.Vector usages)

      Deprecated.
      use KeyPurposeId[] constructor.

  - ### Method Detail

    - #### getInstance

          public static ExtendedKeyUsage getInstance​(ASN1TaggedObject obj,
                                                     boolean explicit)

      Return an ExtendedKeyUsage from the passed in tagged object.
      Parameters:
        `obj` - the tagged object containing the ExtendedKeyUsage
        `explicit` - true if the tagged object should be interpreted as explicitly tagged, false if implicit.
      Returns:
        the ExtendedKeyUsage contained.

    - #### getInstance

          public static ExtendedKeyUsage getInstance​(java.lang.Object obj)

      Return an ExtendedKeyUsage from the passed in object.
      Parameters:
        `obj` - an ExtendedKeyUsage, some form or encoding of one, or null.
      Returns:
        an ExtendedKeyUsage object, or null if null is passed in.

    - #### fromExtensions

          public static ExtendedKeyUsage fromExtensions​(Extensions extensions)

      Retrieve an ExtendedKeyUsage for a passed in Extensions object, if present.
      Parameters:
        `extensions` - the extensions object to be examined.
      Returns:
        the ExtendedKeyUsage, null if the extension is not present.

    - #### hasKeyPurposeId

          public boolean hasKeyPurposeId​(KeyPurposeId keyPurposeId)

      Return true if this ExtendedKeyUsage object contains the passed in keyPurposeId.
      Parameters:
        `keyPurposeId` - the KeyPurposeId of interest.
      Returns:
        true if the keyPurposeId is present, false otherwise.

    - #### getUsages

          public KeyPurposeId[] getUsages()

      Returns all extended key usages.
      Returns:
        An array with all key purposes.

    - #### size

          public int size()

      Return the number of KeyPurposeIds present in this ExtendedKeyUsage.
      Returns:
        the number of KeyPurposeIds

    - #### toASN1Primitive

          public ASN1Primitive toASN1Primitive()

      Return the ASN.1 primitive form of this object.
      Specified by:
        `toASN1Primitive` in interface `ASN1Encodable`
      Specified by:
        `toASN1Primitive` in class `ASN1Object`
      Returns:
        an ASN1Sequence.