use of java.security.cert.CollectionCertStoreParameters in project robovm by robovm.
the class CollectionCertStoreParametersTest method testClone03.
/**
* Test #3 for <code>clone()</code> method<br>
*/
public final void testClone03() {
CollectionCertStoreParameters cp1 = new CollectionCertStoreParameters();
CollectionCertStoreParameters cp2 = (CollectionCertStoreParameters) cp1.clone();
CollectionCertStoreParameters cp3 = (CollectionCertStoreParameters) cp2.clone();
// check that all objects hold the same reference
assertTrue(cp1.getCollection() == cp2.getCollection() && cp3.getCollection() == cp2.getCollection());
}
use of java.security.cert.CollectionCertStoreParameters in project robovm by robovm.
the class CollectionCertStoreParametersTest method testCollectionCertStoreParametersCollection03.
/**
* Test #3 for <code>CollectionCertStoreParameters(Collection)</code>
* constructor<br>
*/
public final void testCollectionCertStoreParametersCollection03() {
Vector<Certificate> certificates = new Vector<Certificate>();
// create using empty collection
CollectionCertStoreParameters cp = new CollectionCertStoreParameters(certificates);
// check that the reference is used
assertTrue("isRefUsed_1", certificates == cp.getCollection());
// check that collection still empty
assertTrue("isEmpty", cp.getCollection().isEmpty());
// modify our collection
certificates.add(new MyCertificate("TEST", new byte[] { (byte) 1 }));
certificates.add(new MyCertificate("TEST", new byte[] { (byte) 2 }));
// check that internal state has been changed accordingly
assertTrue("isRefUsed_2", certificates.equals(cp.getCollection()));
}
use of java.security.cert.CollectionCertStoreParameters in project robovm by robovm.
the class CollectionCertStoreParametersTest method testCollectionCertStoreParameters02.
/**
* Test #2 for <code>CollectionCertStoreParameters</code> constructor<br>
*/
@SuppressWarnings("unchecked")
public final void testCollectionCertStoreParameters02() {
CollectionCertStoreParameters cp = new CollectionCertStoreParameters();
Collection c = cp.getCollection();
assertTrue("isEmpty", c.isEmpty());
// check that empty collection is immutable
try {
// try to modify it
c.add(new Object());
fail("empty collection must be immutable");
} catch (Exception e) {
}
}
use of java.security.cert.CollectionCertStoreParameters in project robovm by robovm.
the class CollectionCertStoreParametersTest method testClone01.
/**
* Test #1 for <code>clone()</code> method<br>
*/
public final void testClone01() {
Vector<Certificate> certificates = new Vector<Certificate>();
certificates.add(new MyCertificate("TEST", new byte[] { (byte) 4 }));
CollectionCertStoreParameters cp1 = new CollectionCertStoreParameters(certificates);
CollectionCertStoreParameters cp2 = (CollectionCertStoreParameters) cp1.clone();
// check that that we have new object
assertTrue(cp1 != cp2);
}
use of java.security.cert.CollectionCertStoreParameters in project robovm by robovm.
the class CertPathBuilderTestPKIX method getCertPathParameters.
@Override
public CertPathParameters getCertPathParameters() throws Exception {
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null, null);
CertificateFactory certificateFactory = CertificateFactory.getInstance("X509");
X509Certificate selfSignedcertificate = (X509Certificate) certificateFactory.generateCertificate(new ByteArrayInputStream(selfSignedCert.getBytes()));
keyStore.setCertificateEntry("selfSignedCert", selfSignedcertificate);
X509CertSelector targetConstraints = new X509CertSelector();
targetConstraints.setCertificate(selfSignedcertificate);
List<Certificate> certList = new ArrayList<Certificate>();
certList.add(selfSignedcertificate);
CertStoreParameters storeParams = new CollectionCertStoreParameters(certList);
CertStore certStore = CertStore.getInstance("Collection", storeParams);
PKIXBuilderParameters parameters = new PKIXBuilderParameters(keyStore, targetConstraints);
parameters.addCertStore(certStore);
parameters.setRevocationEnabled(false);
return parameters;
}
Aggregations