1 module hunt.security.x509.CertAttrSet;
2 
3 import hunt.collection.Enumeration;
4 
5 import hunt.stream.Common;
6 
7 /**
8  * This interface defines the methods required of a certificate attribute.
9  * Examples of X.509 certificate attributes are Validity, Issuer_Name, and
10  * Subject Name. A CertAttrSet may comprise one attribute or many
11  * attributes.
12  * <p>
13  * A CertAttrSet itself can also be comprised of other sub-sets.
14  * In the case of X.509 V3 certificates, for example, the "extensions"
15  * attribute has subattributes, such as those for KeyUsage and
16  * AuthorityKeyIdentifier.
17  *
18  * @author Amit Kapoor
19  * @author Hemma Prafullchandra
20  * @see CertificateException
21  */
22 interface CertAttrSet(T, V) {
23     /**
24      * Returns a short string describing this certificate attribute.
25      *
26      * @return value of this certificate attribute in
27      *         printable form.
28      */
29     string toString();
30 
31     /**
32      * Encodes the attribute to the output stream in a format
33      * that can be parsed by the <code>decode</code> method.
34      *
35      * @param outputStream the OutputStream to encode the attribute to.
36      *
37      * @exception CertificateException on encoding or validity errors.
38      * @exception IOException on other errors.
39      */
40     void encode(OutputStream outputStream);
41 
42     /**
43      * Sets an attribute value within this CertAttrSet.
44      *
45      * @param name the name of the attribute (e.g. "x509.info.key")
46      * @param obj the attribute object.
47      *
48      * @exception CertificateException on attribute handling errors.
49      * @exception IOException on other errors.
50      */
51     void set(string name, V obj);
52 
53     /**
54      * Gets an attribute value for this CertAttrSet.
55      *
56      * @param name the name of the attribute to return.
57      *
58      * @exception CertificateException on attribute handling errors.
59      * @exception IOException on other errors.
60      */
61     V get(string name);
62 
63     /**
64      * Deletes an attribute value from this CertAttrSet.
65      *
66      * @param name the name of the attribute to delete.
67      *
68      * @exception CertificateException on attribute handling errors.
69      * @exception IOException on other errors.
70      */
71     void remove(string name);
72 
73     /**
74      * Returns an enumeration of the names of the attributes existing within
75      * this attribute.
76      *
77      * @return an enumeration of the attribute names.
78      */
79     Enumeration!T getElements();
80 
81     /**
82      * Returns the name (identifier) of this CertAttrSet.
83      *
84      * @return the name of this CertAttrSet.
85      */
86     string getName();
87 }