Search in sources :

Example 6 with KeyStoreBuilderParameters

use of javax.net.ssl.KeyStoreBuilderParameters in project robovm by robovm.

the class ProtectionParameterImpl method test_initLjavax_net_ssl_ManagerFactoryParameters.

/**
     * Test for <code>init(ManagerFactoryParameters params)</code>
     * Assertion:
     * throws InvalidAlgorithmParameterException when params is null
     */
public void test_initLjavax_net_ssl_ManagerFactoryParameters() throws NoSuchAlgorithmException {
    if (!DEFSupported) {
        fail(NotSupportedMsg);
        return;
    }
    ManagerFactoryParameters par = null;
    KeyManagerFactory[] keyMF = createKMFac();
    assertNotNull("KeyManagerFactory object were not created", keyMF);
    for (int i = 0; i < keyMF.length; i++) {
        try {
            keyMF[i].init(par);
            fail("InvalidAlgorithmParameterException must be thrown");
        } catch (InvalidAlgorithmParameterException e) {
        }
    }
    KeyStore.ProtectionParameter pp = new ProtectionParameterImpl();
    KeyStore.Builder bld = KeyStore.Builder.newInstance("testType", null, pp);
    assertNotNull("Null object KeyStore.Builder", bld);
    try {
        KeyManagerFactory kmf = KeyManagerFactory.getInstance(defaultAlgorithm);
        KeyStoreBuilderParameters ksp = new KeyStoreBuilderParameters(bld);
        assertNotNull(ksp.getParameters());
        kmf.init(ksp);
        fail("InvalidAlgorithmParameterException must be thrown");
    } catch (InvalidAlgorithmParameterException e) {
    }
}
Also used : InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) KeyStoreBuilderParameters(javax.net.ssl.KeyStoreBuilderParameters) KeyStore(java.security.KeyStore) ManagerFactoryParameters(javax.net.ssl.ManagerFactoryParameters) KeyManagerFactory(javax.net.ssl.KeyManagerFactory)

Example 7 with KeyStoreBuilderParameters

use of javax.net.ssl.KeyStoreBuilderParameters in project robovm by robovm.

the class KeyStoreBuilderParametersTest method test_init_Builder.

public void test_init_Builder() {
    TestKeyStore testKeyStore = TestKeyStore.getClient();
    Builder builder = Builder.newInstance(testKeyStore.keyStore, new PasswordProtection(testKeyStore.storePassword));
    KeyStoreBuilderParameters ksbp = new KeyStoreBuilderParameters(builder);
    assertNotNull(ksbp);
    assertNotNull(ksbp.getParameters());
    assertEquals(1, ksbp.getParameters().size());
    assertSame(builder, ksbp.getParameters().get(0));
}
Also used : TestKeyStore(libcore.java.security.TestKeyStore) KeyStoreBuilderParameters(javax.net.ssl.KeyStoreBuilderParameters) Builder(java.security.KeyStore.Builder) PasswordProtection(java.security.KeyStore.PasswordProtection)

Example 8 with KeyStoreBuilderParameters

use of javax.net.ssl.KeyStoreBuilderParameters in project robovm by robovm.

the class KeyStoreBuilderParametersTest method test_getParameters.

/**
     * javax.net.ssl.KeyStoreBuilderParameters#getParameters()
     */
public void test_getParameters() {
    String[] param = { "Parameter1", "Parameter2", "Parameter3" };
    List ls = new ArrayList<String>();
    for (int i = 0; i < param.length; i++) {
        ls.add(param[i]);
    }
    KeyStoreBuilderParameters ksp = new KeyStoreBuilderParameters(ls);
    List res_list = ksp.getParameters();
    try {
        res_list.add("test");
        fail();
    } catch (UnsupportedOperationException expected) {
    }
    Object[] res = res_list.toArray();
    assertEquals(res.length, param.length);
    for (int i = 0; i < res.length; i++) {
        assertEquals(param[i], res[i]);
    }
}
Also used : KeyStoreBuilderParameters(javax.net.ssl.KeyStoreBuilderParameters) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

KeyStoreBuilderParameters (javax.net.ssl.KeyStoreBuilderParameters)8 KeyStore (java.security.KeyStore)3 Builder (java.security.KeyStore.Builder)3 PasswordProtection (java.security.KeyStore.PasswordProtection)3 List (java.util.List)3 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)2 ArrayList (java.util.ArrayList)2 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)2 TestKeyStore (libcore.java.security.TestKeyStore)2 File (java.io.File)1 ManagerFactoryParameters (javax.net.ssl.ManagerFactoryParameters)1 X509KeyManager (javax.net.ssl.X509KeyManager)1