Search in sources :

Example 1 with MyKeyManagerFactorySpi

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

the class ProtectionParameterImpl method test_Constructor.

/**
     * Test for <code>KeyManagerFactory</code> constructor
     * Assertion: returns KeyManagerFactory object
     */
public void test_Constructor() throws NoSuchAlgorithmException {
    if (!DEFSupported) {
        fail(NotSupportedMsg);
        return;
    }
    KeyManagerFactorySpi spi = new MyKeyManagerFactorySpi();
    KeyManagerFactory keyMF = new myKeyManagerFactory(spi, defaultProvider, defaultAlgorithm);
    assertEquals("Incorrect algorithm", keyMF.getAlgorithm(), defaultAlgorithm);
    assertEquals("Incorrect provider", keyMF.getProvider(), defaultProvider);
    try {
        keyMF.init(null, new char[1]);
        fail("UnrecoverableKeyException must be thrown");
    } catch (UnrecoverableKeyException e) {
    } catch (Exception e) {
        fail("Unexpected: " + e.toString() + " was thrown");
    }
    keyMF = new myKeyManagerFactory(null, null, null);
    assertNull("Aalgorithm must be null", keyMF.getAlgorithm());
    assertNull("Provider must be null", keyMF.getProvider());
    try {
        keyMF.getKeyManagers();
    } catch (NullPointerException e) {
    }
}
Also used : UnrecoverableKeyException(java.security.UnrecoverableKeyException) KeyManagerFactorySpi(javax.net.ssl.KeyManagerFactorySpi) MyKeyManagerFactorySpi(org.apache.harmony.xnet.tests.support.MyKeyManagerFactorySpi) MyKeyManagerFactorySpi(org.apache.harmony.xnet.tests.support.MyKeyManagerFactorySpi) IOException(java.io.IOException) KeyStoreException(java.security.KeyStoreException) CertificateException(java.security.cert.CertificateException) InvalidAlgorithmParameterException(java.security.InvalidAlgorithmParameterException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) UnrecoverableKeyException(java.security.UnrecoverableKeyException) NoSuchProviderException(java.security.NoSuchProviderException) KeyManagerFactory(javax.net.ssl.KeyManagerFactory)

Aggregations

IOException (java.io.IOException)1 InvalidAlgorithmParameterException (java.security.InvalidAlgorithmParameterException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 NoSuchProviderException (java.security.NoSuchProviderException)1 UnrecoverableKeyException (java.security.UnrecoverableKeyException)1 CertificateException (java.security.cert.CertificateException)1 KeyManagerFactory (javax.net.ssl.KeyManagerFactory)1 KeyManagerFactorySpi (javax.net.ssl.KeyManagerFactorySpi)1 MyKeyManagerFactorySpi (org.apache.harmony.xnet.tests.support.MyKeyManagerFactorySpi)1