APIdia Launch Partner
Top Description Inners Fields Constructors Methods
sun.security.pkcs

public Class PKCS9Attribute

extends Object
implements DerEncoder
Class Inheritance
All Implemented Interfaces
sun.security.util.DerEncoder
Imports
java.io.IOException, java.lang.reflect.Array, java.util.*, java.util.function.BiFunction, sun.security.x509.CertificateExtensions, sun.security.util.*

Class supporting any PKCS9 attributes. Supports DER decoding/encoding and access to attribute values.
Author
Douglas Hoover

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record
PKCS9Attribute.AttributeInfo<T>

Contains information for encoding and getting the value of a given PKCS9 attribute

public static interface
public static interface

Field Summary

Modifier and TypeField and Description
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
private static final Debug
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
private final PKCS9Attribute.AttributeInfo<?>
info

The AttributeInfo of this attribute.

private static final Map<ObjectIdentifier, PKCS9Attribute.AttributeInfo<?>>
infoMap

Map containing the AttributeInfo for supported OIDs

public static final ObjectIdentifier
public static final ObjectIdentifier
private final ObjectIdentifier
oid

The OID of this attribute.

public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
public static final ObjectIdentifier
private final Object
value

Value set of this attribute.

Constructor Summary

AccessConstructor and Description
public
PKCS9Attribute(ObjectIdentifier oid, Object value)

Construct an attribute object from the attribute's OID and value.

public
PKCS9Attribute(DerValue
the DerValue representing the DER encoding of the attribute.
derVal
)

Construct a PKCS9Attribute from its encoding on an input stream.

Method Summary

Modifier and TypeMethod and Description
private static <T> void
add(ObjectIdentifier oid, boolean singleValued, Class<T> valueClass, PKCS9Attribute.Decoder<T> decoder, PKCS9Attribute.Encoder<T> encoder, byte... valueTags)

public void
encode(DerOutputStream out)

Implements sun.security.util.DerEncoder.encode.

Write the DER encoding of this attribute to an output stream.

public String
getName()

Return the name of this attribute.

public static String
getName(ObjectIdentifier oid)

Return the attribute name for a given OID or null if we don't recognize the oid.

public ObjectIdentifier
getOID()

Return the OID of this attribute.

public static ObjectIdentifier
getOID(String name)

Return the OID for a given attribute name or null if we don't recognize the name.

public static Set<ObjectIdentifier>
public Object
getValue()

Get the value of this attribute.

pack-priv static int

Returns:

the index, if found, and -1 otherwise.
indexOf
(byte b, byte[] bs, int start)

Beginning the search at start, find the first index i such that a[i] = obj.

public boolean
isKnown()

Returns if the attribute is known.

public boolean
isSingleValued()

Show whether this attribute is single-valued.

private void
throwSingleValuedException()

Throw an exception when there are multiple values for a single-valued attribute.

private void
throwTagException(byte tag)

Throw an exception when the tag on a value encoding is wrong for the attribute whose value it is.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of this attribute.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

CHALLENGE_PASSWORD_OIDback to summary
public static final ObjectIdentifier CHALLENGE_PASSWORD_OID
CMS_ALGORITHM_PROTECTION_OIDback to summary
public static final ObjectIdentifier CMS_ALGORITHM_PROTECTION_OID
CONTENT_TYPE_OIDback to summary
public static final ObjectIdentifier CONTENT_TYPE_OID
COUNTERSIGNATURE_OIDback to summary
public static final ObjectIdentifier COUNTERSIGNATURE_OID
debugback to summary
private static final Debug debug
EMAIL_ADDRESS_OIDback to summary
public static final ObjectIdentifier EMAIL_ADDRESS_OID
EXTENDED_CERTIFICATE_ATTRIBUTES_OIDback to summary
public static final ObjectIdentifier EXTENDED_CERTIFICATE_ATTRIBUTES_OID
EXTENSION_REQUEST_OIDback to summary
public static final ObjectIdentifier EXTENSION_REQUEST_OID
infoback to summary
private final PKCS9Attribute.AttributeInfo<?> info

The AttributeInfo of this attribute. Can be null if oid is unknown.

infoMapback to summary
private static final Map<ObjectIdentifier, PKCS9Attribute.AttributeInfo<?>> infoMap

Map containing the AttributeInfo for supported OIDs

ISSUER_SERIALNUMBER_OIDback to summary
public static final ObjectIdentifier ISSUER_SERIALNUMBER_OID
MESSAGE_DIGEST_OIDback to summary
public static final ObjectIdentifier MESSAGE_DIGEST_OID
oidback to summary
private final ObjectIdentifier oid

The OID of this attribute.

SIGNATURE_TIMESTAMP_TOKEN_OIDback to summary
public static final ObjectIdentifier SIGNATURE_TIMESTAMP_TOKEN_OID
SIGNING_CERTIFICATE_OIDback to summary
public static final ObjectIdentifier SIGNING_CERTIFICATE_OID
SIGNING_TIME_OIDback to summary
public static final ObjectIdentifier SIGNING_TIME_OID
UNSTRUCTURED_ADDRESS_OIDback to summary
public static final ObjectIdentifier UNSTRUCTURED_ADDRESS_OID
UNSTRUCTURED_NAME_OIDback to summary
public static final ObjectIdentifier UNSTRUCTURED_NAME_OID
valueback to summary
private final Object value

Value set of this attribute. Its class is given by AttributeInfo.valueClass. The SET itself as byte[] if unknown.

Constructor Detail

PKCS9Attributeback to summary
public PKCS9Attribute(ObjectIdentifier oid, Object value) throws IllegalArgumentException

Construct an attribute object from the attribute's OID and value. If the attribute is single-valued, provide only one value. If the attribute is multi-valued, provide an array containing all the values. Arrays of length zero are accepted, though probably useless.

The table gives the class that value must have for a given attribute.

Exceptions
IllegalArgumentException:
if the value has the wrong type.
PKCS9Attributeback to summary
public PKCS9Attribute(DerValue derVal) throws IOException

Construct a PKCS9Attribute from its encoding on an input stream.

Parameters
derVal:DerValue

the DerValue representing the DER encoding of the attribute.

Annotations
@SuppressWarnings:this-escape
Exceptions
IOException:
on parsing error.

Method Detail

addback to summary
private static <T> void add(ObjectIdentifier oid, boolean singleValued, Class<T> valueClass, PKCS9Attribute.Decoder<T> decoder, PKCS9Attribute.Encoder<T> encoder, byte... valueTags)
encodeback to summary
public void encode(DerOutputStream out)

Implements sun.security.util.DerEncoder.encode.

Write the DER encoding of this attribute to an output stream.

Note

This method always encodes values of ChallengePassword and UnstructuredAddress attributes as ASN.1 PrintableStrings, without checking whether they should be encoded as T61Strings.

Annotations
@Override
getNameback to summary
public String getName()

Return the name of this attribute.

getNameback to summary
public static String getName(ObjectIdentifier oid)

Return the attribute name for a given OID or null if we don't recognize the oid.

getOIDback to summary
public ObjectIdentifier getOID()

Return the OID of this attribute.

getOIDback to summary
public static ObjectIdentifier getOID(String name)

Return the OID for a given attribute name or null if we don't recognize the name.

getOIDsback to summary
public static Set<ObjectIdentifier> getOIDs()
getValueback to summary
public Object getValue()

Get the value of this attribute. If the attribute is single-valued, return just the one value. If the attribute is multi-valued, return an array containing all the values. It is possible for this array to be of length 0.

The table gives the class of the value returned, depending on the type of this attribute.

indexOfback to summary
pack-priv static int indexOf(byte b, byte[] bs, int start)

Beginning the search at start, find the first index i such that a[i] = obj.

Returns:int

the index, if found, and -1 otherwise.

isKnownback to summary
public boolean isKnown()

Returns if the attribute is known. Unknown attributes can be created from DER encoding with unknown OIDs.

isSingleValuedback to summary
public boolean isSingleValued()

Show whether this attribute is single-valued.

throwSingleValuedExceptionback to summary
private void throwSingleValuedException() throws IOException

Throw an exception when there are multiple values for a single-valued attribute.

throwTagExceptionback to summary
private void throwTagException(byte tag) throws IOException

Throw an exception when the tag on a value encoding is wrong for the attribute whose value it is. This method will only be called for known tags.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Returns a string representation of this attribute.

Annotations
@Override
sun.security.pkcs back to summary

private final Record PKCS9Attribute.AttributeInfo<T>

extends Record
Class Inheritance
Record Components
singleValued:boolean 
valueClass:Class<?> 
decoder:PKCS9Attribute.Decoder<T> 
encoder:PKCS9Attribute.Encoder<T> 
valueTags:byte[] 

Contains information for encoding and getting the value of a given PKCS9 attribute

Field Summary

Modifier and TypeField and Description
private final PKCS9Attribute.Decoder<T>
decoder

Record Component accessed by decoder().

private final PKCS9Attribute.Encoder<T>
encoder

Record Component accessed by encoder().

private final boolean
singleValued

Record Component accessed by singleValued().

private final Class<?>
valueClass

Record Component accessed by valueClass().

private final byte[]
valueTags

Record Component accessed by valueTags().

Constructor Summary

AccessConstructor and Description
private
AttributeInfo(boolean singleValued, Class<?> valueClass, PKCS9Attribute.Decoder<T> decoder, PKCS9Attribute.Encoder<T> encoder, byte... valueTags)

Method Summary

Modifier and TypeMethod and Description
pack-priv T
public PKCS9Attribute.Decoder<T>
decoder()

Record Component getter of decoder.

pack-priv DerOutputStream
public PKCS9Attribute.Encoder<T>
encoder()

Record Component getter of encoder.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public boolean
singleValued()

Record Component getter of singleValued.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public Class<?>
valueClass()

Record Component getter of valueClass.

public byte[]
valueTags()

Record Component getter of valueTags.

Field Detail

decoderback to summary
private final PKCS9Attribute.Decoder<T> decoder

Record Component accessed by decoder().

encoderback to summary
private final PKCS9Attribute.Encoder<T> encoder

Record Component accessed by encoder().

singleValuedback to summary
private final boolean singleValued

Record Component accessed by singleValued().

valueClassback to summary
private final Class<?> valueClass

Record Component accessed by valueClass().

valueTagsback to summary
private final byte[] valueTags

Record Component accessed by valueTags().

Constructor Detail

AttributeInfoback to summary
private AttributeInfo(boolean singleValued, Class<?> valueClass, PKCS9Attribute.Decoder<T> decoder, PKCS9Attribute.Encoder<T> encoder, byte... valueTags)

Method Detail

decodeback to summary
pack-priv T decode(DerValue d) throws IOException
decoderback to summary
public PKCS9Attribute.Decoder<T> decoder()

Record Component getter of decoder.

encodeback to summary
pack-priv DerOutputStream encode(Object o)
Annotations
@SuppressWarnings:unchecked
encoderback to summary
public PKCS9Attribute.Encoder<T> encoder()

Record Component getter of encoder.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

singleValuedback to summary
public boolean singleValued()

Record Component getter of singleValued.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

valueClassback to summary
public Class<?> valueClass()

Record Component getter of valueClass.

valueTagsback to summary
public byte[] valueTags()

Record Component getter of valueTags.

sun.security.pkcs back to summary

public Interface PKCS9Attribute.Decoder<R>

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public R

Method Detail

decodeback to summary
public R decode(DerValue t) throws IOException
sun.security.pkcs back to summary

public Interface PKCS9Attribute.Encoder<R>

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public void

Method Detail

encodeback to summary
public void encode(DerOutputStream t, R r)