Search in sources :

Example 1 with FileSystemDirectoryCertStore

use of xades4j.utils.FileSystemDirectoryCertStore in project xades4j by luisgoncalves.

the class PKIXCertificateValidationProviderTest method testValidateMy.

@Test
public void testValidateMy() throws Exception {
    System.out.println("validateMy");
    FileSystemDirectoryCertStore certStore = new FileSystemDirectoryCertStore("./src/test/cert/my");
    KeyStore ks = KeyStore.getInstance("jks");
    FileInputStream fis = new FileInputStream("./src/test/cert/my/myStore");
    ks.load(fis, "mystorepass".toCharArray());
    fis.close();
    X509CertSelector certSelector = new X509CertSelector();
    certSelector.setSubject(new X500Principal("CN = Luis Goncalves,OU = CC,O = ISEL,C = PT"));
    Collection<X509Certificate> otherCerts = Collections.emptyList();
    PKIXCertificateValidationProvider instance = new PKIXCertificateValidationProvider(ks, false, certStore.getStore());
    ValidationData result = instance.validate(certSelector, new Date(), otherCerts);
    assertEquals(result.getCerts().size(), 3);
}
Also used : ValidationData(xades4j.providers.ValidationData) FileSystemDirectoryCertStore(xades4j.utils.FileSystemDirectoryCertStore) X500Principal(javax.security.auth.x500.X500Principal) X509CertSelector(java.security.cert.X509CertSelector) KeyStore(java.security.KeyStore) FileInputStream(java.io.FileInputStream) X509Certificate(java.security.cert.X509Certificate) Date(java.util.Date) Test(org.junit.Test)

Example 2 with FileSystemDirectoryCertStore

use of xades4j.utils.FileSystemDirectoryCertStore in project xades4j by luisgoncalves.

the class PKIXCertificateValidationProviderTest method testValidateNist.

@Test
public void testValidateNist() throws Exception {
    System.out.println("validateNist");
    FileSystemDirectoryCertStore certStore = new FileSystemDirectoryCertStore("./src/test/cert/csrc.nist");
    KeyStore ks = KeyStore.getInstance("jks");
    FileInputStream fis = new FileInputStream("./src/test/cert/csrc.nist/trustAnchor");
    ks.load(fis, "password".toCharArray());
    fis.close();
    X509CertSelector certSelector = new X509CertSelector();
    certSelector.setSubject(new X500Principal("CN = User1-CP.02.01,OU = Testing,OU = DoD,O = U.S. Government,C = US"));
    Collection<X509Certificate> otherCerts = Collections.emptyList();
    PKIXCertificateValidationProvider instance = new PKIXCertificateValidationProvider(ks, true, certStore.getStore());
    ValidationData result = instance.validate(certSelector, new Date(), otherCerts);
    assertEquals(result.getCerts().size(), 4);
    assertEquals(result.getCrls().size(), 3);
}
Also used : ValidationData(xades4j.providers.ValidationData) FileSystemDirectoryCertStore(xades4j.utils.FileSystemDirectoryCertStore) X500Principal(javax.security.auth.x500.X500Principal) X509CertSelector(java.security.cert.X509CertSelector) KeyStore(java.security.KeyStore) FileInputStream(java.io.FileInputStream) X509Certificate(java.security.cert.X509Certificate) Date(java.util.Date) Test(org.junit.Test)

Aggregations

FileInputStream (java.io.FileInputStream)2 KeyStore (java.security.KeyStore)2 X509CertSelector (java.security.cert.X509CertSelector)2 X509Certificate (java.security.cert.X509Certificate)2 Date (java.util.Date)2 X500Principal (javax.security.auth.x500.X500Principal)2 Test (org.junit.Test)2 ValidationData (xades4j.providers.ValidationData)2 FileSystemDirectoryCertStore (xades4j.utils.FileSystemDirectoryCertStore)2