Search in sources :

Example 1 with Thumbprint

use of org.nhindirect.stagent.cert.Thumbprint in project nhin-d by DirectProject.

the class LDAPCertificateStore method contains.

@Override
public boolean contains(X509Certificate cert) {
    Collection<X509Certificate> foundCerts;
    String subject = CryptoExtensions.getSubjectAddress(cert);
    if (subject == null || subject.isEmpty())
        // this should not happen, but in case need to get the entire cert list
        foundCerts = getAllCertificates();
    else
        foundCerts = getCertificates(subject);
    if (foundCerts != null) {
        Thumbprint searchCertTP = Thumbprint.toThumbprint(cert);
        for (X509Certificate foundCert : foundCerts) if (Thumbprint.toThumbprint(foundCert).equals(searchCertTP))
            return true;
    }
    return false;
}
Also used : Thumbprint(org.nhindirect.stagent.cert.Thumbprint) X509Certificate(java.security.cert.X509Certificate)

Example 2 with Thumbprint

use of org.nhindirect.stagent.cert.Thumbprint in project nhin-d by DirectProject.

the class DefaultMessageSignatureImpl method checkThumbprint.

/**
	 * Validates if the senders certificate matches the signature certificate using certificate thumb printing.
	 * @param messageSender The senders address.  The address should contain the senders public certificate.
	 * @return True if the thumb print of the signature matches the senders certificate thumb print.  False otherwise.
	 */
public boolean checkThumbprint(NHINDAddress messageSender) {
    thumbprintVerified = false;
    //try
    //{
    // generate a thumb print of our cert
    Thumbprint sigThumbprint = Thumbprint.toThumbprint(this.getSignerCert());
    if (messageSender.hasCertificates())
        // now iterate through the sender's certificates until a thumb print match is found
        for (X509Certificate checkCert : messageSender.getCertificates()) if (sigThumbprint.equals(Thumbprint.toThumbprint(checkCert))) {
            thumbprintVerified = true;
            break;
        }
    return thumbprintVerified;
}
Also used : Thumbprint(org.nhindirect.stagent.cert.Thumbprint) X509Certificate(java.security.cert.X509Certificate)

Aggregations

X509Certificate (java.security.cert.X509Certificate)2 Thumbprint (org.nhindirect.stagent.cert.Thumbprint)2