Search in sources :

Example 56 with CollectionCertStoreParameters

use of java.security.cert.CollectionCertStoreParameters in project j2objc by google.

the class CollectionCertStoreParametersTest method testCollectionCertStoreParametersCollection01.

/**
 * Test #1 for <code>CollectionCertStoreParameters(Collection)</code>
 * constructor<br>
 */
public final void testCollectionCertStoreParametersCollection01() {
    Vector<Certificate> certificates = new Vector<Certificate>();
    certificates.add(new MyCertificate("TEST", new byte[] {}));
    new CollectionCertStoreParameters(certificates);
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) CollectionCertStoreParameters(java.security.cert.CollectionCertStoreParameters) Vector(java.util.Vector) Certificate(java.security.cert.Certificate) MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate)

Example 57 with CollectionCertStoreParameters

use of java.security.cert.CollectionCertStoreParameters in project j2objc by google.

the class CollectionCertStoreParametersTest method testClone02.

/**
 * Test #2 for <code>clone()</code> method<br>
 */
public final void testClone02() {
    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 both objects hold the same reference
    assertTrue(cp1.getCollection() == cp2.getCollection());
}
Also used : MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate) CollectionCertStoreParameters(java.security.cert.CollectionCertStoreParameters) Vector(java.util.Vector) Certificate(java.security.cert.Certificate) MyCertificate(org.apache.harmony.security.tests.support.cert.MyCertificate)

Example 58 with CollectionCertStoreParameters

use of java.security.cert.CollectionCertStoreParameters in project j2objc by google.

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) {
    }
}
Also used : CollectionCertStoreParameters(java.security.cert.CollectionCertStoreParameters) Collection(java.util.Collection)

Example 59 with CollectionCertStoreParameters

use of java.security.cert.CollectionCertStoreParameters in project j2objc by google.

the class CollectionCertStoreParametersTest method testGetCollection02.

/**
 * Test #2 for <code>getCollection()</code> method<br>
 */
public final void testGetCollection02() {
    Vector certificates = new Vector();
    CollectionCertStoreParameters cp = new CollectionCertStoreParameters(certificates);
    assertNotNull(cp.getCollection());
}
Also used : CollectionCertStoreParameters(java.security.cert.CollectionCertStoreParameters) Vector(java.util.Vector)

Example 60 with CollectionCertStoreParameters

use of java.security.cert.CollectionCertStoreParameters in project Payara by payara.

the class JSSE14SocketFactory method getParameters.

/**
 * Return the initialization parameters for the TrustManager. Currently, only the default <code>PKIX</code> is
 * supported.
 *
 * @param algorithm The algorithm to get parameters for.
 * @param crlf The path to the CRL file.
 * @param trustStore The configured TrustStore.
 *
 * @return The parameters including the CRLs and TrustStore.
 */
protected CertPathParameters getParameters(String algorithm, String crlf, KeyStore trustStore) throws Exception {
    CertPathParameters params;
    if ("PKIX".equalsIgnoreCase(algorithm)) {
        PKIXBuilderParameters xparams = new PKIXBuilderParameters(trustStore, new X509CertSelector());
        Collection crls = getCRLs(crlf);
        CertStoreParameters csp = new CollectionCertStoreParameters(crls);
        CertStore store = CertStore.getInstance("Collection", csp);
        xparams.addCertStore(store);
        xparams.setRevocationEnabled(true);
        String trustLength = (String) attributes.get("trustMaxCertLength");
        if (trustLength != null) {
            try {
                xparams.setMaxPathLength(Integer.parseInt(trustLength));
            } catch (Exception ex) {
                logger.warning("Bad maxCertLength: " + trustLength);
            }
        }
        params = xparams;
    } else {
        throw new CRLException("CRLs not supported for type: " + algorithm);
    }
    return params;
}
Also used : CertStoreParameters(java.security.cert.CertStoreParameters) CollectionCertStoreParameters(java.security.cert.CollectionCertStoreParameters) CollectionCertStoreParameters(java.security.cert.CollectionCertStoreParameters) PKIXBuilderParameters(java.security.cert.PKIXBuilderParameters) Collection(java.util.Collection) CertPathParameters(java.security.cert.CertPathParameters) X509CertSelector(java.security.cert.X509CertSelector) CertStore(java.security.cert.CertStore) CRLException(java.security.cert.CRLException) IOException(java.io.IOException) CertificateException(java.security.cert.CertificateException) SSLException(javax.net.ssl.SSLException) CRLException(java.security.cert.CRLException)

Aggregations

CollectionCertStoreParameters (java.security.cert.CollectionCertStoreParameters)66 X509CertSelector (java.security.cert.X509CertSelector)33 PKIXBuilderParameters (java.security.cert.PKIXBuilderParameters)32 X509Certificate (java.security.cert.X509Certificate)29 CertStore (java.security.cert.CertStore)25 Certificate (java.security.cert.Certificate)21 ArrayList (java.util.ArrayList)18 CertPathBuilder (java.security.cert.CertPathBuilder)17 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)16 HashSet (java.util.HashSet)16 TrustAnchor (java.security.cert.TrustAnchor)15 Vector (java.util.Vector)12 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)11 CertStoreParameters (java.security.cert.CertStoreParameters)11 IOException (java.io.IOException)10 MyCertificate (org.apache.harmony.security.tests.support.cert.MyCertificate)10 PKIXCertPathBuilderResult (java.security.cert.PKIXCertPathBuilderResult)9 KeyStoreException (java.security.KeyStoreException)8 CertPath (java.security.cert.CertPath)8 CertPathBuilderException (java.security.cert.CertPathBuilderException)8