1 /* 2 * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26 package sun.security.x509; 27 28 import java.io.IOException; 29 import java.io.OutputStream; 30 import java.security.cert.CertificateException; 31 import java.util.Enumeration; 32 33 /** 34 * This interface defines the methods required of a certificate attribute. 35 * Examples of X.509 certificate attributes are Validity, Issuer_Name, and 36 * Subject Name. A CertAttrSet may comprise one attribute or many 37 * attributes. 38 * <p> 39 * A CertAttrSet itself can also be comprised of other sub-sets. 40 * In the case of X.509 V3 certificates, for example, the "extensions" 41 * attribute has subattributes, such as those for KeyUsage and 42 * AuthorityKeyIdentifier. 43 * 44 * @author Amit Kapoor 45 * @author Hemma Prafullchandra 46 * @see CertificateException 47 */ 48 public interface CertAttrSet<T> { 49 /** 50 * Returns a short string describing this certificate attribute. 51 * 52 * @return value of this certificate attribute in 53 * printable form. 54 */ toString()55 String toString(); 56 57 /** 58 * Encodes the attribute to the output stream in a format 59 * that can be parsed by the <code>decode</code> method. 60 * 61 * @param out the OutputStream to encode the attribute to. 62 * 63 * @exception CertificateException on encoding or validity errors. 64 * @exception IOException on other errors. 65 */ encode(OutputStream out)66 void encode(OutputStream out) 67 throws CertificateException, IOException; 68 69 /** 70 * Sets an attribute value within this CertAttrSet. 71 * 72 * @param name the name of the attribute (e.g. "x509.info.key") 73 * @param obj the attribute object. 74 * 75 * @exception CertificateException on attribute handling errors. 76 * @exception IOException on other errors. 77 */ set(String name, Object obj)78 void set(String name, Object obj) 79 throws CertificateException, IOException; 80 81 /** 82 * Gets an attribute value for this CertAttrSet. 83 * 84 * @param name the name of the attribute to return. 85 * 86 * @exception CertificateException on attribute handling errors. 87 * @exception IOException on other errors. 88 */ get(String name)89 Object get(String name) 90 throws CertificateException, IOException; 91 92 /** 93 * Deletes an attribute value from this CertAttrSet. 94 * 95 * @param name the name of the attribute to delete. 96 * 97 * @exception CertificateException on attribute handling errors. 98 * @exception IOException on other errors. 99 */ delete(String name)100 void delete(String name) 101 throws CertificateException, IOException; 102 103 /** 104 * Returns an enumeration of the names of the attributes existing within 105 * this attribute. 106 * 107 * @return an enumeration of the attribute names. 108 */ getElements()109 Enumeration<T> getElements(); 110 111 /** 112 * Returns the name (identifier) of this CertAttrSet. 113 * 114 * @return the name of this CertAttrSet. 115 */ getName()116 String getName(); 117 } 118