001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /**
019: * @author Alexander Y. Kleymenov
020: * @version $Revision$
021: */package javax.security.cert;
022:
023: import java.security.InvalidKeyException;
024: import java.security.NoSuchAlgorithmException;
025: import java.security.NoSuchProviderException;
026: import java.security.PublicKey;
027: import java.security.SignatureException;
028: import java.util.Arrays;
029: import javax.security.cert.CertificateEncodingException;
030: import javax.security.cert.CertificateException;
031:
032: /**
033: * @com.intel.drl.spec_ref
034: */
035: public abstract class Certificate {
036:
037: /**
038: * @com.intel.drl.spec_ref
039: */
040: public Certificate() {
041: }
042:
043: /**
044: * @com.intel.drl.spec_ref
045: */
046: public boolean equals(Object obj) {
047: if (obj == this ) {
048: return true;
049: }
050: if (!(obj instanceof Certificate)) {
051: return false;
052: }
053: Certificate object = (Certificate) obj;
054: try {
055: return Arrays.equals(getEncoded(), object.getEncoded());
056: } catch (CertificateEncodingException e) {
057: return false;
058: }
059: }
060:
061: /**
062: * @com.intel.drl.spec_ref
063: */
064: public int hashCode() {
065: int res = 0;
066: try {
067: byte[] array = getEncoded();
068: for (int i = 0; i < array.length; i++) {
069: res += array[i];
070: }
071: } catch (CertificateEncodingException e) {
072: }
073: return res;
074: }
075:
076: /**
077: * @com.intel.drl.spec_ref
078: */
079: public abstract byte[] getEncoded()
080: throws CertificateEncodingException;
081:
082: /**
083: * @com.intel.drl.spec_ref
084: */
085: public abstract void verify(PublicKey key)
086: throws CertificateException, NoSuchAlgorithmException,
087: InvalidKeyException, NoSuchProviderException,
088: SignatureException;
089:
090: /**
091: * @com.intel.drl.spec_ref
092: */
093: public abstract void verify(PublicKey key, String sigProvider)
094: throws CertificateException, NoSuchAlgorithmException,
095: InvalidKeyException, NoSuchProviderException,
096: SignatureException;
097:
098: /**
099: * @com.intel.drl.spec_ref
100: */
101: public abstract String toString();
102:
103: /**
104: * @com.intel.drl.spec_ref
105: */
106: public abstract PublicKey getPublicKey();
107: }
|