diff options
Diffstat (limited to 'libraries/spongycastle/prov/src/test/jdk1.1/org/spongycastle/jce/provider/test/CertPathValidatorTest.java')
-rw-r--r-- | libraries/spongycastle/prov/src/test/jdk1.1/org/spongycastle/jce/provider/test/CertPathValidatorTest.java | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/libraries/spongycastle/prov/src/test/jdk1.1/org/spongycastle/jce/provider/test/CertPathValidatorTest.java b/libraries/spongycastle/prov/src/test/jdk1.1/org/spongycastle/jce/provider/test/CertPathValidatorTest.java deleted file mode 100644 index f4607bc09..000000000 --- a/libraries/spongycastle/prov/src/test/jdk1.1/org/spongycastle/jce/provider/test/CertPathValidatorTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.spongycastle.jce.provider.test; - -import java.io.ByteArrayInputStream; -import java.security.PublicKey; -import java.security.Security; -import java.security.cert.*; -import java.util.ArrayList; -import java.util.Calendar; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.spongycastle.jce.provider.BouncyCastleProvider; -import org.spongycastle.util.test.SimpleTestResult; -import org.spongycastle.util.test.Test; -import org.spongycastle.util.test.TestResult; - -public class CertPathValidatorTest - implements Test -{ - - public TestResult perform() - { - try - { - CertificateFactory cf = CertificateFactory.getInstance("X.509", "SC"); - - // initialise CertStore - X509Certificate rootCert = (X509Certificate)cf.generateCertificate(new ByteArrayInputStream(CertPathTest.rootCertBin)); - X509Certificate interCert = (X509Certificate)cf.generateCertificate(new ByteArrayInputStream(CertPathTest.interCertBin)); - X509Certificate finalCert = (X509Certificate)cf.generateCertificate(new ByteArrayInputStream(CertPathTest.finalCertBin)); - X509CRL rootCrl = (X509CRL)cf.generateCRL(new ByteArrayInputStream(CertPathTest.rootCrlBin)); - X509CRL interCrl = (X509CRL)cf.generateCRL(new ByteArrayInputStream(CertPathTest.interCrlBin)); - List list = new ArrayList(); - list.add( rootCert ); - list.add( interCert ); - list.add( finalCert ); - list.add( rootCrl ); - list.add( interCrl ); - CollectionCertStoreParameters ccsp = new CollectionCertStoreParameters( list ); - CertStore store = CertStore.getInstance("Collection", ccsp ); - Calendar validDate = Calendar.getInstance(); - validDate.set(2002,2,21,2,21,10); - - //validating path - List certchain = new ArrayList(); - certchain.add( finalCert ); - certchain.add( interCert ); - CertPath cp = CertificateFactory.getInstance("X.509","SC").generateCertPath( certchain ); - Set trust = new HashSet(); - trust.add( new TrustAnchor( rootCert, null ) ); - - CertPathValidator cpv = CertPathValidator.getInstance("PKIX","SC"); - PKIXParameters param = new PKIXParameters( trust ); - param.addCertStore(store); - param.setDate( validDate.getTime() ); - PKIXCertPathValidatorResult result = - (PKIXCertPathValidatorResult) cpv.validate(cp, param); - PolicyNode policyTree = result.getPolicyTree(); - PublicKey subjectPublicKey = result.getPublicKey(); - } - catch (Exception e) - { - e.printStackTrace(); - return new SimpleTestResult(false, this.getName() + ": exception - " + e.toString()); - } - - return new SimpleTestResult(true, this.getName() + ": Okay"); - } - - public String getName() - { - return "CertPathValidator"; - } - - public static void main( - String[] args) - { - Security.addProvider(new BouncyCastleProvider()); - - Test test = new CertPathValidatorTest(); - TestResult result = test.perform(); - - System.out.println(result.toString()); - } -} - |