001: /*
002: * @(#)Certificate.java 1.23 02/07/24 @(#)
003: *
004: * Copyright (c) 2001-2002 Sun Microsystems, Inc. All rights reserved.
005: * PROPRIETARY/CONFIDENTIAL
006: * Use is subject to license terms.
007: */
008:
009: package com.sun.portal.microedition.pki;
010:
011: import java.lang.String;
012:
013: /**
014: * Interface common to certificates.
015: * The features abstracted of <CODE>Certificates</CODE> include subject,
016: * issuer, type, version, serial number, signing algorithm, dates of valid use,
017: * and serial number.
018: * <p>
019: * <b>Printable Representation for Binary Values</b></p>
020: * <p>
021: * A non-string values in a certificate are represented as strings with each
022: * byte as two hex digits (capital letters for A-F) separated by ":" (Unicode
023: * 0x3A).</p>
024: * <p>
025: * For example: <tt>0C:56:FA:80</tt></p>
026: * <p>
027: * <b>Printable Representation for X.509 Distinguished Names</b></p>
028: * <p>
029: * For a X.509 certificate the value returned is the printable verision of
030: * the distingished name (DN) from the certificate.</p>
031: * <p>
032: * An X.509 distinguished name of is set of attributes, each attribute is a
033: * sequence of an object ID and a value. For string comparison purposes, the
034: * following rules define a strict printable representation.</p>
035: * <p>
036: * <ol>
037: * <li>There is no added white space around separators.</li>
038: *
039: * <li>Attributes are not reordered.</li>
040: *
041: * <li>If an object ID is in the table below, the label from the table
042: * will be substituted for the object ID, else the ID is formatted as
043: * a string using the binary printable representation above.</li>
044: *
045: * <li>Each object ID or label and value within an attribute will be
046: * separated by a "=" (Unicode 0x3D), even if the value is empty.</li>
047: *
048: * <li>If value is not a string, then it is formatted as a string using the
049: * binary printable representation above.</li>
050: *
051: * <li>Attributes will be separated by a ";" (Unicode 0x3B)</li>
052: * </ol>
053: * </p>
054: * <br><b>Labels for X.500 Distinguished Name Attributes</b>
055: * <table border="1" cellpadding=4 cellspacing=0 width="100%">
056: *
057: * <tr>
058: * <th bgcolor="#CCCCFF">Object ID</th>
059: * <th bgcolor="#CCCCFF">Binary</th>
060: * <th bgcolor="#CCCCFF">Label</th>
061: * <tr>
062: * <td>id-at-commonName</td>
063: * <td><tt>55:04:03</tt></td>
064: * <td>CN</td>
065: * </tr>
066: * <tr>
067: * <td>id-at-surname</td>
068: * <td><tt>55:04:04</tt></td>
069: * <td>SN</td>
070: * </tr>
071: * <tr>
072: * <td>id-at-countryName</td>
073: * <td><tt>55:04:06</tt></td>
074: * <td>C</td>
075: * </tr>
076: * <tr>
077: * <td>id-at-localityName</td>
078: * <td><tt>55:04:07</tt></td>
079: * <td>L</td>
080: * </tr>
081: * <tr>
082: * <td>id-at-stateOrProvinceName</td>
083: * <td><tt>55:04:08</tt></td>
084: * <td>ST</td>
085: * </tr>
086: * <tr>
087: * <td>id-at-streetAddress</td>
088: * <td><tt>55:04:09</tt></td>
089: * <td>STREET</td>
090: * </tr>
091: * <tr>
092: * <td>id-at-organizationName</td>
093: * <td><tt>55:04:0A</tt></td>
094: * <td>O</td>
095: * </tr>
096: * <tr>
097: * <td>id-at-organizationUnitName</td>
098: * <td><tt>55:04:0B</tt></td>
099: * <td>OU</td>
100: * </tr>
101: * <tr>
102: * <td>emailAddress</td>
103: * <td><tt>2A:86:48:86:F7:0D:01:09:01</tt></td>
104: * <td>EmailAddress</td>
105: * </tr>
106: * </table>
107: * <p>
108: * Example of a printable distinguished name:</p>
109: * <blockquote>
110: * <tt>C=US;O=Any Company, Inc.;CN=www.anycompany.com</tt></blockquote>
111: *
112: * @since MIDP 2.0
113: */
114: public interface Certificate {
115:
116: /**
117: * Gets the name of this certificate's subject.
118: * @return The subject of this <CODE>Certificate</CODE>;
119: * the value MUST NOT be <CODE>null</CODE>.
120: */
121: public String getSubject();
122:
123: /**
124: * Gets the name of this certificate's issuer.
125: * @return The issuer of the <CODE>Certificate</CODE>;
126: * the value MUST NOT be <CODE>null</CODE>.
127: */
128: public String getIssuer();
129:
130: /**
131: * Get the type of the <CODE>Certificate</CODE>.
132: * For X.509 Certificates the value returned is "X.509".
133: *
134: * @return The type of the <CODE>Certificate</CODE>;
135: * the value MUST NOT be <CODE>null</CODE>.
136: */
137: public String getType();
138:
139: /**
140: * Gets the version number of this <CODE>Certificate</CODE>.
141: * The format of the version number depends on the specific
142: * type and specification.
143: * For a X.509 certificate per RFC 2459 it would be "3".
144: * @return The version number of the <CODE>Certificate</CODE>;
145: * the value MUST NOT be <CODE>null</CODE>.
146: */
147: public String getVersion();
148:
149: /**
150: * Gets the name of the algorithm used to sign the
151: * <CODE>Certificate</CODE>.
152: * The algorithm names returned should be the labels
153: * defined in RFC2459 Section 7.2.
154: * @return The name of signature algorithm;
155: * the value MUST NOT be <CODE>null</CODE>.
156: */
157: public String getSigAlgName();
158:
159: /**
160: * Gets the time before which this <CODE>Certificate</CODE> may not be used
161: * from the validity period.
162: *
163: * @return The time in milliseconds before which the
164: * <CODE>Certificate</CODE> is not valid; it MUST be positive,
165: * <CODE>0</CODE> is returned if the certificate does not
166: * have its validity restricted based on the time.
167: */
168: public long getNotBefore();
169:
170: /**
171: * Gets the time after which this <CODE>Certificate</CODE> may not be used
172: * from the validity period.
173: * @return The time in milliseconds after which the
174: * <CODE>Certificate</CODE> is not valid (expiration date);
175: * it MUST be positive; <CODE>Long.MAX_VALUE</CODE> is returned if
176: * the certificate does not have its validity restricted based on the
177: * time.
178: */
179: public long getNotAfter();
180:
181: /**
182: * Gets the printable form of the serial number of this
183: * <CODE>Certificate</CODE>.
184: * If the serial number within the <CODE>certificate</CODE>
185: * is binary it should be formatted as a string using the binary printable
186: * representation in class description.
187: * For example, 0C:56:FA:80.
188: * @return A string containing the serial number
189: * in user-friendly form; <CODE>null</CODE> is returned
190: * if there is no serial number.
191: */
192: public String getSerialNumber();
193:
194: }
|