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
51 * Extension ::= SEQUENCE {
52 * extnId OBJECT IDENTIFIER,
53 * critical BOOLEAN DEFAULT FALSE,
54 * extnValue OCTET STRING
55 * -- contains a DER encoding of a value
56 * -- of the type registered for use with
57 * -- the extnId object identifier value
58 * }
59 * </pre>
60 *
61 * @see X509CRL
62 * @see X509Extension
63 *
64 * @author Hemma Prafullchandra
65 */
66
67 public abstract class X509CRLEntry implements X509Extension {
68
69 /**
70 * Compares this CRL entry for equality with the given
71 * object. If the <code>other</code> object is an
72 * <code>instanceof</code> <code>X509CRLEntry</code>, then
73 * its encoded form (the inner SEQUENCE) is retrieved and compared
74 * with the encoded form of this CRL entry.
75 *
76 * @param other the object to test for equality with this CRL entry.
77 * @return true iff the encoded forms of the two CRL entries
78 * match, false otherwise.
79 */
80 public boolean equals(Object other) {
81 if (this == other)
82 return true;
83 if (!(other instanceof X509CRLEntry))
84 return false;
85 try {
86 byte[] thisCRLEntry = this.getEncoded();
87 byte[] otherCRLEntry = ((X509CRLEntry)other).getEncoded();
88
89 if (thisCRLEntry.length != otherCRLEntry.length)
90 return false;
91 for (int i = 0; i < thisCRLEntry.length; i++)
92 if (thisCRLEntry[i] != otherCRLEntry[i])
161
162 /**
163 * Returns true if this CRL entry has extensions.
164 *
165 * @return true if this entry has extensions, false otherwise.
166 */
167 public abstract boolean hasExtensions();
168
169 /**
170 * Returns a string representation of this CRL entry.
171 *
172 * @return a string representation of this CRL entry.
173 */
174 public abstract String toString();
175
176 /**
177 * Returns the reason the certificate has been revoked, as specified
178 * in the Reason Code extension of this CRL entry.
179 *
180 * @return the reason the certificate has been revoked, or
181 * <code>null</code> if this CRL entry does not have
182 * a Reason Code extension
183 * @since 1.7
184 */
185 public CRLReason getRevocationReason() {
186 if (!hasExtensions()) {
187 return null;
188 }
189 return X509CRLEntryImpl.getRevocationReason(this);
190 }
191 }
|
1 /*
2 * Copyright (c) 1997, 2013, 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
51 * Extension ::= SEQUENCE {
52 * extnId OBJECT IDENTIFIER,
53 * critical BOOLEAN DEFAULT FALSE,
54 * extnValue OCTET STRING
55 * -- contains a DER encoding of a value
56 * -- of the type registered for use with
57 * -- the extnId object identifier value
58 * }
59 * </pre>
60 *
61 * @see X509CRL
62 * @see X509Extension
63 *
64 * @author Hemma Prafullchandra
65 */
66
67 public abstract class X509CRLEntry implements X509Extension {
68
69 /**
70 * Compares this CRL entry for equality with the given
71 * object. If the {@code other} object is an
72 * {@code instanceof} {@code X509CRLEntry}, then
73 * its encoded form (the inner SEQUENCE) is retrieved and compared
74 * with the encoded form of this CRL entry.
75 *
76 * @param other the object to test for equality with this CRL entry.
77 * @return true iff the encoded forms of the two CRL entries
78 * match, false otherwise.
79 */
80 public boolean equals(Object other) {
81 if (this == other)
82 return true;
83 if (!(other instanceof X509CRLEntry))
84 return false;
85 try {
86 byte[] thisCRLEntry = this.getEncoded();
87 byte[] otherCRLEntry = ((X509CRLEntry)other).getEncoded();
88
89 if (thisCRLEntry.length != otherCRLEntry.length)
90 return false;
91 for (int i = 0; i < thisCRLEntry.length; i++)
92 if (thisCRLEntry[i] != otherCRLEntry[i])
161
162 /**
163 * Returns true if this CRL entry has extensions.
164 *
165 * @return true if this entry has extensions, false otherwise.
166 */
167 public abstract boolean hasExtensions();
168
169 /**
170 * Returns a string representation of this CRL entry.
171 *
172 * @return a string representation of this CRL entry.
173 */
174 public abstract String toString();
175
176 /**
177 * Returns the reason the certificate has been revoked, as specified
178 * in the Reason Code extension of this CRL entry.
179 *
180 * @return the reason the certificate has been revoked, or
181 * {@code null} if this CRL entry does not have
182 * a Reason Code extension
183 * @since 1.7
184 */
185 public CRLReason getRevocationReason() {
186 if (!hasExtensions()) {
187 return null;
188 }
189 return X509CRLEntryImpl.getRevocationReason(this);
190 }
191 }
|