Search in sources :

Example 1 with UniformCertificateStore

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

the class TrustChainValidator_IntermidiateCert_Test method testValidateChain_IntermediatePublicResolver_OpenSSLCerts.

public void testValidateChain_IntermediatePublicResolver_OpenSSLCerts() throws Exception {
    X509Certificate anchor = certFromData(getCertificateFileData("cert-c.der"));
    X509Certificate certToValidate = certFromData(getCertificateFileData("cert-a.der"));
    // uniform cert store that will just spit out whatever we put in it
    // will put the anchor in the public resolver... validator should hit it
    X509Certificate intermediateCert = certFromData(getCertificateFileData("cert-b.der"));
    CertificateResolver publicResolver = new UniformCertificateStore(intermediateCert);
    TrustChainValidator validator = new TrustChainValidator();
    validator.setCertificateResolver(Arrays.asList(publicResolver));
    boolean isTrusted = false;
    try {
        isTrusted = validator.isTrusted(certToValidate, Arrays.asList(anchor));
    } catch (Exception e) {
    }
    assertTrue(isTrusted);
}
Also used : UniformCertificateStore(org.nhindirect.stagent.cert.impl.UniformCertificateStore) CertificateResolver(org.nhindirect.stagent.cert.CertificateResolver) X509Certificate(java.security.cert.X509Certificate) NHINDException(org.nhindirect.stagent.NHINDException)

Example 2 with UniformCertificateStore

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

the class TrustChainValidator_IntermidiateCert_Test method testValidateCertAgainstNonRootCA_CAInPublicResolver_OpenSSLCerts.

public void testValidateCertAgainstNonRootCA_CAInPublicResolver_OpenSSLCerts() throws Exception {
    X509Certificate anchor = certFromData(getCertificateFileData("cert-b.der"));
    X509Certificate certToValidate = certFromData(getCertificateFileData("cert-a.der"));
    // uniform cert store that will just spit out whatever we put in it
    // will put the anchor in the public resolver... validator should hit it
    CertificateResolver publicResolver = new UniformCertificateStore(anchor);
    TrustChainValidator validator = new TrustChainValidator();
    validator.setCertificateResolver(Arrays.asList(publicResolver));
    boolean isTrusted = false;
    try {
        isTrusted = validator.isTrusted(certToValidate, Arrays.asList(anchor));
    } catch (Exception e) {
    }
    assertTrue(isTrusted);
}
Also used : UniformCertificateStore(org.nhindirect.stagent.cert.impl.UniformCertificateStore) CertificateResolver(org.nhindirect.stagent.cert.CertificateResolver) X509Certificate(java.security.cert.X509Certificate) NHINDException(org.nhindirect.stagent.NHINDException)

Aggregations

X509Certificate (java.security.cert.X509Certificate)2 NHINDException (org.nhindirect.stagent.NHINDException)2 CertificateResolver (org.nhindirect.stagent.cert.CertificateResolver)2 UniformCertificateStore (org.nhindirect.stagent.cert.impl.UniformCertificateStore)2