public final class PKCS12Attribute extends Object implements KeyStore.Entry.Attribute
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.
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 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.
name
- the attribute's identifiervalue
- the attribute's valueNullPointerException
- if name
or value
is null
IllegalArgumentException
- if name
or value
is incorrectly formattedpublic 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
encoded
- the attribute's ASN.1 DER encoding. It is cloned to prevent subsequent modificaion.NullPointerException
- if encoded
is null
IllegalArgumentException
- if encoded
is incorrectly formattedpublic String getName()
Returns the attribute's ASN.1 Object Identifier represented as a list of dot-separated integers.
getName
in interface KeyStore.Entry.Attribute
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:
Arrays.toString(java.lang.Object[])
. getValue
in interface KeyStore.Entry.Attribute
public byte[] getEncoded()
Returns the attribute's ASN.1 DER encoding.
public boolean equals(Object obj)
Compares this PKCS12Attribute
and a specified object for equality.
equals
in class Object
obj
- the comparison objectobj
is a PKCS12Attribute
and their DER encodings are equal.Object.hashCode()
, HashMap
public int hashCode()
Returns the hashcode for this PKCS12Attribute
. The hash code is computed from its DER encoding.
hashCode
in class Object
Object.equals(java.lang.Object)
, System.identityHashCode(java.lang.Object)
public String toString()
Returns a string representation of this PKCS12Attribute
.
© 1993–2017, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.