Top Description Fields Constructors Methods
java.security

public final Class PKCS12Attribute

extends Object
implements Attribute
Class Inheritance
All Implemented Interfaces
java.security.KeyStore.Entry.Attribute
Imports
java.io.IOException, java.math.BigInteger, java.util.Arrays, java.util.regex.Pattern, sun.security.util.*

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.
Since
1.8

Field Summary

Modifier and TypeField and Description
private static final Pattern
private final byte[]
private int
private String
private String

Constructor Summary

AccessConstructor and Description
public
PKCS12Attribute(String
the attribute's identifier
name
,
String
the attribute's value
value
)

Constructs a PKCS12 attribute from its name and value.

public
PKCS12Attribute(byte[]
the attribute's ASN.1 DER encoding. It is cloned to prevent subsequent modification.
encoded
)

Constructs a PKCS12 attribute from its ASN.1 DER encoding.

Method Summary

Modifier and TypeMethod and Description
private byte[]
encode(ObjectIdentifier type, String[] values)

public boolean

Returns:

true if obj is a PKCS12Attribute and their DER encodings are equal.
equals
(Object
the comparison object
obj
)

Overrides java.lang.Object.equals.

Compares this PKCS12Attribute and a specified object for equality.

public byte[]

Returns:

a clone of the attribute's DER encoding
getEncoded
()

Returns the attribute's ASN.1 DER encoding.

public String

Returns:

the attribute's identifier
getName
()

Implements java.security.KeyStore.Entry.Attribute.getName.

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

public String

Returns:

the attribute value's string encoding
getValue
()

Implements java.security.KeyStore.Entry.Attribute.getValue.

Returns the attribute's ASN.1 DER-encoded value as a string.

public int

Returns:

the hashcode for this PKCS12Attribute
hashCode
()

Overrides java.lang.Object.hashCode.

Returns the hashcode for this PKCS12Attribute.

private void
parse(byte[] encoded)

public String

Returns:

a name/value pair separated by an 'equals' symbol
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this PKCS12Attribute.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

COLON_SEPARATED_HEX_PAIRSback to summary
private static final Pattern COLON_SEPARATED_HEX_PAIRS
encodedback to summary
private final byte[] encoded
hashValueback to summary
private int hashValue
nameback to summary
private String name
valueback to summary
private String value

Constructor Detail

PKCS12Attributeback to summary
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. Multivalued 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.

Parameters
name:String

the attribute's identifier

value:String

the attribute's value

Exceptions
NullPointerException:
if name or value is null
IllegalArgumentException:
if name or value is incorrectly formatted
PKCS12Attributeback to summary
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

Parameters
encoded:byte[]

the attribute's ASN.1 DER encoding. It is cloned to prevent subsequent modification.

Exceptions
NullPointerException:
if encoded is null
IllegalArgumentException:
if encoded is incorrectly formatted

Method Detail

encodeback to summary
private byte[] encode(ObjectIdentifier type, String[] values) throws IOException
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Compares this PKCS12Attribute and a specified object for equality.

Parameters
obj:Object

the comparison object

Returns:boolean

true if obj is a PKCS12Attribute and their DER encodings are equal.

Annotations
@Override
getEncodedback to summary
public byte[] getEncoded()

Returns the attribute's ASN.1 DER encoding.

Returns:byte[]

a clone of the attribute's DER encoding

getNameback to summary
public String getName()

Implements java.security.KeyStore.Entry.Attribute.getName.

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

Returns:String

the attribute's identifier

Annotations
@Override
getValueback to summary
public String getValue()

Implements java.security.KeyStore.Entry.Attribute.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.
Multivalued attributes are represented as a comma-separated list of values, enclosed in square brackets. See Arrays#toString(java.lang.Object[]).
Returns:String

the attribute value's string encoding

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

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

Returns:int

the hashcode for this PKCS12Attribute

Annotations
@Override
parseback to summary
private void parse(byte[] encoded) throws IOException
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this PKCS12Attribute.

Returns:String

a name/value pair separated by an 'equals' symbol

Annotations
@Override