Example usage for java.security.cert X509Certificate getSubjectUniqueID

List of usage examples for java.security.cert X509Certificate getSubjectUniqueID

Introduction

In this page you can find the example usage for java.security.cert X509Certificate getSubjectUniqueID.

Prototype

public abstract boolean[] getSubjectUniqueID();

Source Link

Document

Gets the subjectUniqueID value from the certificate.

Usage

From source file:it.cnr.icar.eric.server.security.authentication.AuthenticationServiceImpl.java

/**
 * Compares two certificates. It will compare the issuerUniqueID and
 * subjectUniqueID fields of the certificates. If either certificate does
 * not contain either field, it will return false.
 *//* ww  w  .jav a2 s.  com*/
private boolean certificatesAreSame(X509Certificate cert, X509Certificate oldCert) throws RegistryException {
    boolean[] certIssuerID = cert.getIssuerUniqueID();
    boolean[] oldCertIssuerID = oldCert.getIssuerUniqueID();

    if ((certIssuerID == null) || (oldCertIssuerID == null)
            || (certIssuerID.length != oldCertIssuerID.length)) {
        return false;
    }

    for (int i = 0; i < certIssuerID.length; i++) {
        if (certIssuerID[i] != oldCertIssuerID[i]) {
            return false;
        }
    }

    boolean[] certSubjectID = cert.getSubjectUniqueID();
    boolean[] oldCertSubjectID = oldCert.getSubjectUniqueID();

    if ((certSubjectID == null) || (oldCertSubjectID == null)
            || (certSubjectID.length != oldCertSubjectID.length)) {
        return false;
    }

    for (int i = 0; i < certSubjectID.length; i++) {
        if (certSubjectID[i] != oldCertSubjectID[i]) {
            return false;
        }
    }

    return true;
}