codec.pkcs9
Class Attributes

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.ArrayList
                    |
                    +--codec.asn1.ASN1AbstractCollection
                          |
                          +--codec.asn1.ASN1Set
                                |
                                +--codec.asn1.ASN1SetOf
                                      |
                                      +--codec.pkcs9.Attributes
All Implemented Interfaces:
ASN1Collection, ASN1CollectionOf, ASN1Type, Cloneable, Collection, Externalizable, List, Serializable

public class Attributes
extends ASN1SetOf

This class represents Attributes as defined in PKCS#6. The ASN.1 definition of this structure is

 Attributes ::= SET OF Attribute
 
Instances can be initialized with a OIDRegistry that is used to resolve attribute value types. The type of value of a PKCS#6 Content Type Attribute is for instance OBJECT IDENTIFIER. The OID of this attribute is { pkcs-9 3}. The OID identifies both the attribute and the attribute value's type.

Please note that when a registry is specified, exceptions are thrown if an attribute is encountered whose type cannot be resolved by that registry or any of the global registries.

Version:
"$Id: Attributes.java,v 1.2 2000/12/06 17:47:33 vroth Exp $"
Author:
Volker Roth
See Also:
Serialized Form

Field Summary
protected  OIDRegistry registry_
          The registry that is used to resolve attribute values.
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Attributes()
          Creates an instance ready for parsing.
Attributes(OIDRegistry registry)
          Creates an instance ready for parsing.
 
Method Summary
 boolean containsAttribute(ASN1ObjectIdentifier oid)
          Returns true if an attribute of the given type exists in this instance.
 Attribute getAttribute(ASN1ObjectIdentifier oid)
          Returns the first attribute of the given type that is found in this instance.
 Attribute getAttribute(int index)
          Returns the attribute at the given position.
 Class getElementType()
          Returns Attribute.class.
 ASN1Type newElement()
          Returns a new attribute instance.
 
Methods inherited from class codec.asn1.ASN1SetOf
decode
 
Methods inherited from class codec.asn1.ASN1Set
getTag
 
Methods inherited from class codec.asn1.ASN1AbstractCollection
checkConstraints, encode, getCollection, getConstraint, getTagClass, getValue, isExplicit, isOptional, isType, readExternal, setConstraint, setExplicit, setOptional, toString, writeExternal
 
Methods inherited from class java.util.ArrayList
add, add, addAll, addAll, clear, clone, contains, ensureCapacity, get, indexOf, isEmpty, lastIndexOf, remove, removeRange, set, size, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
equals, hashCode, iterator, listIterator, listIterator, subList
 
Methods inherited from class java.util.AbstractCollection
containsAll, remove, removeAll, retainAll
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface codec.asn1.ASN1Collection
getCollection
 
Methods inherited from interface codec.asn1.ASN1Type
checkConstraints, encode, getConstraint, getTag, getTagClass, getValue, isExplicit, isOptional, isType, setConstraint, setExplicit, setOptional
 
Methods inherited from interface java.util.Collection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface java.util.List
containsAll, equals, hashCode, iterator, listIterator, listIterator, remove, removeAll, retainAll, subList
 

Field Detail

registry_

protected OIDRegistry registry_
The registry that is used to resolve attribute values.
Constructor Detail

Attributes

public Attributes()
Creates an instance ready for parsing. Any type of attribute is accepted.

Attributes

public Attributes(OIDRegistry registry)
Creates an instance ready for parsing. The given OIDRegistry is used to resolve the attribute value types. Attributes that cannot be resolved will cause exceptions upon decoding.
Parameters:
registry - The OIDRegistry to use for resolving attribute value types, or null if the default PKCS registry shall be used.
Method Detail

getAttribute

public Attribute getAttribute(ASN1ObjectIdentifier oid)
Returns the first attribute of the given type that is found in this instance.
Parameters:
oid - The type of the attribute.
Returns:
The attribute with the given OID or null if no matching attribute is found.

containsAttribute

public boolean containsAttribute(ASN1ObjectIdentifier oid)
Returns true if an attribute of the given type exists in this instance. This method calls getAttribute(ASN1ObjectIdentifier). Do not use it if you want to retrieve the attribute subsequent to this method call anyway.
Parameters:
oid - The type of the attribute.
Returns:
true if an attribute with the given OID exists.

getAttribute

public Attribute getAttribute(int index)
Returns the attribute at the given position.
Parameters:
index - The position of the attribute to return.
Throws:
ArrayIndexOutOfBoundsException - if the given index is not within the bounds of the attributes list.

getElementType

public Class getElementType()
Returns Attribute.class.
Overrides:
getElementType in class ASN1SetOf
Returns:
Attribute.class

newElement

public ASN1Type newElement()
Returns a new attribute instance. The new attribute is added to this instance automatically.
Overrides:
newElement in class ASN1SetOf
Returns:
The new attribute, ready to be decoded.


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.