Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/java/security/PKCS12Attribute#pubctors) \| [Methods](https://developer.android.com/reference/java/security/PKCS12Attribute#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/java/security/PKCS12Attribute#inhmethods)

# PKCS12Attribute

` public final class PKCS12Attribute `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/java/security/KeyStore.Entry.Attribute `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | java.security.PKCS12Attribute |

<br />

*** ** * ** ***

An attribute associated with a PKCS12 keystore entry. The attribute name is an ASN.1 Object Identifier and the attribute value is a set of ASN.1 types.

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/java/security/PKCS12Attribute#PKCS12Attribute(byte[])(byte[] encoded) ` Constructs a PKCS12 attribute from its ASN.1 DER encoding. |
| ` https://developer.android.com/reference/java/security/PKCS12Attribute#PKCS12Attribute(java.lang.String,%20java.lang.String)(https://developer.android.com/reference/java/lang/String name, https://developer.android.com/reference/java/lang/String value) ` Constructs a PKCS12 attribute from its name and value. |

| ### Public methods ||
|---|---|
| ` boolean` | ` https://developer.android.com/reference/java/security/PKCS12Attribute#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) ` Compares this `PKCS12Attribute` and a specified object for equality. |
| ` byte[]` | ` https://developer.android.com/reference/java/security/PKCS12Attribute#getEncoded()() ` Returns the attribute's ASN.1 DER encoding. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/PKCS12Attribute#getName()() ` Returns the attribute's ASN.1 Object Identifier represented as a list of dot-separated integers. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/PKCS12Attribute#getValue()() ` Returns the attribute's ASN.1 DER-encoded value as a string. |
| ` int` | ` https://developer.android.com/reference/java/security/PKCS12Attribute#hashCode()() ` Returns the hashcode for this `PKCS12Attribute`. |
| ` https://developer.android.com/reference/java/lang/String` | ` https://developer.android.com/reference/java/security/PKCS12Attribute#toString()() ` Returns a string representation of this `PKCS12Attribute`. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/java/security/KeyStore.Entry.Attribute ` ` abstract https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/security/KeyStore.Entry.Attribute#getName()() `

Returns the attribute's name.
` abstract https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/security/KeyStore.Entry.Attribute#getValue()() `

Returns the attribute's value.

## Public constructors

### PKCS12Attribute

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PKCS12Attribute (byte[] encoded)
```

Constructs a PKCS12 attribute from its ASN.1 DER encoding. The DER encoding is specified by the following ASN.1 definition:

```
Attribute ::= SEQUENCE {
    type   AttributeType,
    values SET OF AttributeValue
}
AttributeType ::= OBJECT IDENTIFIER
AttributeValue ::= ANY defined by type

```

<br />

<br />

| Parameters ||
|---|---|
| `encoded` | `byte`: the attribute's ASN.1 DER encoding. It is cloned to prevent subsequent modificaion. <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `encoded` is incorrectly formatted |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `encoded` is `null` |

### PKCS12Attribute

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public PKCS12Attribute (String name, 
                String value)
```

Constructs a PKCS12 attribute from its name and value. The name is an ASN.1 Object Identifier represented as a list of dot-separated integers. A string value is represented as the string itself. A binary value is represented as a string of colon-separated pairs of hexadecimal digits. Multi-valued attributes are represented as a comma-separated list of values, enclosed in square brackets. See `https://developer.android.com/reference/java/util/Arrays#toString(java.lang.Object[])`.

A string value will be DER-encoded as an ASN.1 UTF8String and a binary value will be DER-encoded as an ASN.1 Octet String.

<br />

| Parameters ||
|---|---|
| `name` | `String`: the attribute's identifier <br /> |
| `value` | `String`: the attribute's value <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException` | if `name` or `value` is incorrectly formatted |
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `name` or `value` is `null` |

## Public methods

### equals

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public boolean equals (Object obj)
```

Compares this `PKCS12Attribute` and a specified object for equality.

<br />

| Parameters ||
|---|---|
| `obj` | `Object`: the comparison object <br /> |

| Returns ||
|---|---|
| `boolean` | true if `obj` is a `PKCS12Attribute` and their DER encodings are equal. <br /> |

### getEncoded

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public byte[] getEncoded ()
```

Returns the attribute's ASN.1 DER encoding.

<br />

| Returns ||
|---|---|
| `byte[]` | a clone of the attribute's DER encoding <br /> |

### getName

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getName ()
```

Returns the attribute's ASN.1 Object Identifier represented as a list of dot-separated integers.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the attribute's identifier <br /> |

### getValue

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String getValue ()
```

Returns the attribute's ASN.1 DER-encoded value as a string. An ASN.1 DER-encoded value is returned in one of the following `String` formats:

- the DER encoding of a basic ASN.1 type that has a natural string representation is returned as the string itself. Such types are currently limited to BOOLEAN, INTEGER, OBJECT IDENTIFIER, UTCTime, GeneralizedTime and the following six ASN.1 string types: UTF8String, PrintableString, T61String, IA5String, BMPString and GeneralString.
- the DER encoding of any other ASN.1 type is not decoded but returned as a binary string of colon-separated pairs of hexadecimal digits.

Multi-valued attributes are represented as a comma-separated list of values, enclosed in square brackets. See `https://developer.android.com/reference/java/util/Arrays#toString(java.lang.Object[])`.

<br />

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | the attribute value's string encoding <br /> |

### hashCode

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public int hashCode ()
```

Returns the hashcode for this `PKCS12Attribute`. The hash code is computed from its DER encoding.

<br />

| Returns ||
|---|---|
| `int` | the hash code <br /> |

### toString

Added in [API level 26](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public String toString ()
```

Returns a string representation of this `PKCS12Attribute`.

<br />

| Returns ||
|---|---|
| `https://developer.android.com/reference/java/lang/String` | a name/value pair separated by an 'equals' symbol <br /> |