All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javax.security.cert.Certificate Maven / Gradle / Ivy

/*
 *  Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  See the NOTICE file distributed with
 *  this work for additional information regarding copyright ownership.
 *  The ASF licenses this file to You under the Apache License, Version 2.0
 *  (the "License"); you may not use this file except in compliance with
 *  the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package javax.security.cert;

import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.PublicKey;
import java.security.SignatureException;
import java.util.Arrays;

/**
 * Abstract class to represent identity certificates. It represents a way to
 * verify the binding of a Principal and its public key. Examples are X.509,
 * PGP, and SDSI.
 * 

* Note: This package is provided only for compatibility reasons. * It contains a simplified version of the java.security.cert package that was * previously used by JSSE (Java SSL package). All applications that do not have * to be compatible with older versions of JSSE (that is before Java SDK 1.5) * should only use java.security.cert. */ public abstract class Certificate { /** * Creates a new {@code Certificate}. */ public Certificate() {} /** * Compares the argument to this Certificate. If both have the same bytes * they are assumed to be equal. * * @param obj * the {@code Certificate} to compare with this object * @return true if {@code obj} is the same as this * {@code Certificate}, false otherwise * @see #hashCode */ public boolean equals(Object obj) { if (obj == this) { return true; } if (!(obj instanceof Certificate)) { return false; } Certificate object = (Certificate) obj; try { return Arrays.equals(getEncoded(), object.getEncoded()); } catch (CertificateEncodingException e) { return false; } } /** * Returns an integer hash code for the receiver. Any two objects which * return true when passed to equals must answer * the same value for this method. * * @return the receiver's hash * @see #equals */ public int hashCode() { int res = 0; try { byte[] array = getEncoded(); for (int i=0; i





© 2015 - 2024 Weber Informatics LLC | Privacy Policy