Search in sources :

Example 1 with KeyManagerFactorySpiImpl

use of org.apache.harmony.xnet.tests.support.KeyManagerFactorySpiImpl in project robovm by robovm.

the class KeyManagerFactorySpiTest method test_Constructor.

/**
     * javax.net.ssl.KeyManagerFactorySpi#KeyManagerFactorySpi()
     */
public void test_Constructor() {
    try {
        KeyManagerFactorySpiImpl kmf = new KeyManagerFactorySpiImpl();
        assertTrue(kmf instanceof KeyManagerFactorySpi);
    } catch (Exception e) {
        fail("Unexpected Exception " + e.toString());
    }
}
Also used : KeyManagerFactorySpiImpl(org.apache.harmony.xnet.tests.support.KeyManagerFactorySpiImpl) KeyManagerFactorySpi(javax.net.ssl.KeyManagerFactorySpi) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnrecoverableKeyException(java.security.UnrecoverableKeyException) KeyStoreException(java.security.KeyStoreException) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException)

Example 2 with KeyManagerFactorySpiImpl

use of org.apache.harmony.xnet.tests.support.KeyManagerFactorySpiImpl in project robovm by robovm.

the class KeyManagerFactorySpiTest method test_engineInit_02.

/**
     * javax.net.ssl.KeyManagerFactorySpi#KengineInit(ManagerFactoryParameters spec)
     */
public void test_engineInit_02() {
    KeyManagerFactorySpiImpl kmf = new KeyManagerFactorySpiImpl();
    try {
        kmf.engineInit(null);
        fail("InvalidAlgorithmParameterException wasn't thrown");
    } catch (InvalidAlgorithmParameterException iape) {
    //expected
    } catch (Exception e) {
        fail(e + " was thrown instead of InvalidAlgorithmParameterException");
    }
    try {
        char[] psw = "password".toCharArray();
        Parameters pr = new Parameters(psw);
        kmf.engineInit(pr);
    } catch (Exception e) {
        fail(e + " unexpected exception was thrown");
    }
}
Also used : KeyManagerFactorySpiImpl(org.apache.harmony.xnet.tests.support.KeyManagerFactorySpiImpl) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) ManagerFactoryParameters(javax.net.ssl.ManagerFactoryParameters) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnrecoverableKeyException(java.security.UnrecoverableKeyException) KeyStoreException(java.security.KeyStoreException) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException)

Example 3 with KeyManagerFactorySpiImpl

use of org.apache.harmony.xnet.tests.support.KeyManagerFactorySpiImpl in project robovm by robovm.

the class KeyManagerFactorySpiTest method test_engineInit_01.

/**
     * javax.net.ssl.KeyManagerFactorySpi#KengineInit(KeyStore ks, char[] password)
     */
public void test_engineInit_01() {
    KeyManagerFactorySpiImpl kmf = new KeyManagerFactorySpiImpl();
    KeyStore ks;
    char[] psw = "password".toCharArray();
    try {
        kmf.engineInit(null, null);
        fail("NoSuchAlgorithmException wasn't thrown");
    } catch (NoSuchAlgorithmException kse) {
    //expected
    } catch (Exception e) {
        fail(e + " was thrown instead of NoSuchAlgorithmException");
    }
    try {
        kmf.engineInit(null, psw);
        fail("KeyStoreException wasn't thrown");
    } catch (KeyStoreException uke) {
    //expected
    } catch (Exception e) {
        fail(e + " was thrown instead of KeyStoreException");
    }
    try {
        ks = KeyStore.getInstance(KeyStore.getDefaultType());
        kmf.engineInit(ks, null);
        fail("UnrecoverableKeyException wasn't thrown");
    } catch (UnrecoverableKeyException uke) {
    //expected
    } catch (Exception e) {
        fail(e + " was thrown instead of UnrecoverableKeyException");
    }
    try {
        KeyStore kst = KeyStore.getInstance(KeyStore.getDefaultType());
        kst.load(null, null);
        kmf.engineInit(kst, psw);
    } catch (Exception e) {
        fail("Unexpected exception " + e);
    }
}
Also used : KeyManagerFactorySpiImpl(org.apache.harmony.xnet.tests.support.KeyManagerFactorySpiImpl) UnrecoverableKeyException(java.security.UnrecoverableKeyException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) KeyStoreException(java.security.KeyStoreException) KeyStore(java.security.KeyStore) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnrecoverableKeyException(java.security.UnrecoverableKeyException) KeyStoreException(java.security.KeyStoreException) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException)

Example 4 with KeyManagerFactorySpiImpl

use of org.apache.harmony.xnet.tests.support.KeyManagerFactorySpiImpl in project robovm by robovm.

the class KeyManagerFactorySpiTest method test_engineGetKeyManagers.

/**
     * javax.net.ssl.KeyManagerFactorySpi#engineGetKeyManagers()
     */
public void test_engineGetKeyManagers() {
    KeyManagerFactorySpiImpl kmf = new KeyManagerFactorySpiImpl();
    try {
        KeyManager[] km = kmf.engineGetKeyManagers();
        fail("IllegalStateException wasn't thrown");
    } catch (IllegalStateException ise) {
    //expected
    } catch (Exception e) {
        fail(e + " was thrown instead of IllegalStateException");
    }
    try {
        char[] psw = "password".toCharArray();
        Parameters pr = new Parameters(psw);
        kmf.engineInit(pr);
        KeyManager[] km = kmf.engineGetKeyManagers();
        assertNull("Object is not NULL", km);
    } catch (Exception e) {
        fail(e + " unexpected exception was thrown");
    }
}
Also used : KeyManagerFactorySpiImpl(org.apache.harmony.xnet.tests.support.KeyManagerFactorySpiImpl) ManagerFactoryParameters(javax.net.ssl.ManagerFactoryParameters) KeyManager(javax.net.ssl.KeyManager) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnrecoverableKeyException(java.security.UnrecoverableKeyException) KeyStoreException(java.security.KeyStoreException) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException)

Aggregations

InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)4 KeyStoreException (java.security.KeyStoreException)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 UnrecoverableKeyException (java.security.UnrecoverableKeyException)4 KeyManagerFactorySpiImpl (org.apache.harmony.xnet.tests.support.KeyManagerFactorySpiImpl)4 ManagerFactoryParameters (javax.net.ssl.ManagerFactoryParameters)2 KeyStore (java.security.KeyStore)1 KeyManager (javax.net.ssl.KeyManager)1 KeyManagerFactorySpi (javax.net.ssl.KeyManagerFactorySpi)1