OSDN Git Service

AI 144816: Bringing XNET down to zero broken tests.
authorJorg Pleumann <>
Tue, 7 Apr 2009 09:51:04 +0000 (02:51 -0700)
committerThe Android Open Source Project <initial-contribution@android.com>
Tue, 7 Apr 2009 09:51:04 +0000 (02:51 -0700)
  BUG=1285921

Automated import of CL 144816

libcore/x-net/src/test/java/tests/api/javax/net/ssl/HandshakeCompletedEventTest.java
libcore/x-net/src/test/java/tests/api/javax/net/ssl/HostnameVerifierTest.java
libcore/x-net/src/test/java/tests/api/javax/net/ssl/KeyManagerFactory1Test.java
libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLContext1Test.java
libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLEngineTest.java
libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLSessionContextTest.java
libcore/x-net/src/test/java/tests/api/javax/net/ssl/SSLSocketFactoryTest.java
libcore/x-net/src/test/java/tests/api/javax/net/ssl/X509KeyManagerTest.java

index fbbde69..fa36d0c 100644 (file)
@@ -662,7 +662,7 @@ public class HandshakeCompletedEventTest extends TestCase {
      * Implements basically a dummy TrustManager. It stores the certificate
      * chain it sees, so it can later be queried.
      */
-    static class TestTrustManager implements X509TrustManager {
+    public static class TestTrustManager implements X509TrustManager {
         
         private X509Certificate[] chain;
         
index 19caa8f..15eb1cc 100644 (file)
@@ -20,6 +20,7 @@ package tests.api.javax.net.ssl;
 import dalvik.annotation.AndroidOnly;
 import dalvik.annotation.BrokenTest;
 import dalvik.annotation.KnownFailure;
+import dalvik.annotation.SideEffect;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -56,7 +57,7 @@ public class HostnameVerifierTest extends TestCase implements
         method = "verify",
         args = {String.class, SSLSession.class}
     )
-    @BrokenTest("Some side effect from other tests seems to make this test fail.")
+    @SideEffect("the DefaultHostnameVerifier is set in some other tests, therefore we need isolation")
     public final void test_verify() {
         mySSLSession session = new mySSLSession("localhost", 1080, null);
         HostnameVerifier hv = HttpsURLConnection.getDefaultHostnameVerifier();
@@ -75,7 +76,7 @@ public class HostnameVerifierTest extends TestCase implements
         args = {String.class, SSLSession.class}
     )
     @AndroidOnly("DefaultHostnameVerifier on RI is weird and cannot be tested this way.")
-    @KnownFailure("DefaultHostnameVerifier is broken on Android, fixed in donutburger")
+    @SideEffect("the DefaultHostnameVerifier is set in some other tests, therefore we need isolation")
     public void testVerify() throws Exception {
         CertificateFactory cf = CertificateFactory.getInstance("X.509");
         InputStream in;
@@ -185,6 +186,7 @@ public class HostnameVerifierTest extends TestCase implements
     )
     @AndroidOnly("DefaultHostnameVerifier on RI is weird and cannot be tested this way.")
     @KnownFailure("DefaultHostnameVerifier is broken on Android, fixed in donutburger")
+    @SideEffect("the DefaultHostnameVerifier is set in some other tests, therefore we need isolation")
     public void testSubjectAlt() throws Exception {
         CertificateFactory cf = CertificateFactory.getInstance("X.509");
         InputStream in = new ByteArrayInputStream(X509_MULTIPLE_SUBJECT_ALT);
index 421966b..29ce384 100644 (file)
@@ -20,6 +20,7 @@ package tests.api.javax.net.ssl;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.KnownFailure;
 
 import java.io.IOException;
 import java.security.InvalidAlgorithmParameterException;
@@ -179,6 +180,8 @@ public class KeyManagerFactory1Test extends TestCase {
         KeyManagerFactory keyMF;
         for (int i = 0; i < validValues.length; i++) {
             keyMF = KeyManagerFactory.getInstance(validValues[i]);
+            assertTrue("Not KeyManagerFactory object",
+                    keyMF instanceof KeyManagerFactory);
             assertEquals("Invalid algorithm", keyMF.getAlgorithm(),
                     validValues[i]);
         }
@@ -333,6 +336,8 @@ public class KeyManagerFactory1Test extends TestCase {
         for (int i = 0; i < validValues.length; i++) {
             kMF = KeyManagerFactory.getInstance(validValues[i],
                     defaultProviderName);
+            assertTrue("Not KeyManagerFactory object",
+                    kMF instanceof KeyManagerFactory);
             assertEquals("Incorrect algorithm", kMF.getAlgorithm(),
                     validValues[i]);
             assertEquals("Incorrect provider", kMF.getProvider().getName(),
@@ -423,6 +428,7 @@ public class KeyManagerFactory1Test extends TestCase {
         for (int i = 0; i < validValues.length; i++) {
             kMF = KeyManagerFactory
                     .getInstance(validValues[i], defaultProvider);
+            assertTrue(kMF instanceof KeyManagerFactory);
             assertEquals(kMF.getAlgorithm(), validValues[i]);
             assertEquals(kMF.getProvider(), defaultProvider);
         }
@@ -438,7 +444,7 @@ public class KeyManagerFactory1Test extends TestCase {
         method = "KeyManagerFactory",
         args = {javax.net.ssl.KeyManagerFactorySpi.class, java.security.Provider.class, java.lang.String.class}
     )
-    public void test_Constructor() {
+    public void test_Constructor() throws NoSuchAlgorithmException {
         if (!DEFSupported) {
             fail(NotSupportedMsg);
             return;
@@ -446,6 +452,7 @@ public class KeyManagerFactory1Test extends TestCase {
         KeyManagerFactorySpi spi = new MyKeyManagerFactorySpi();
         KeyManagerFactory keyMF = new myKeyManagerFactory(spi, defaultProvider,
                 defaultAlgorithm);
+        assertTrue("Not CertStore object", keyMF instanceof KeyManagerFactory);
         assertEquals("Incorrect algorithm", keyMF.getAlgorithm(),
                 defaultAlgorithm);
         assertEquals("Incorrect provider", keyMF.getProvider(), defaultProvider);
@@ -457,12 +464,12 @@ public class KeyManagerFactory1Test extends TestCase {
             fail("Unexpected: "+e.toString()+" was thrown");
         }
         keyMF = new myKeyManagerFactory(null, null, null);
+        assertTrue("Not CertStore object", keyMF instanceof KeyManagerFactory);
         assertNull("Aalgorithm must be null", keyMF.getAlgorithm());
         assertNull("Provider must be null", keyMF.getProvider());
         try {
             keyMF.getKeyManagers();
         } catch (NullPointerException e) {
-            // expected
         }
     }
 
@@ -578,7 +585,7 @@ public class KeyManagerFactory1Test extends TestCase {
      */
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        notes = "",
+        notes = "functionality is not implemented in org.apache.harmony.xnet.provider.jsse.engineInit(ManagerFactoryParameters)",
         method = "init",
         args = {javax.net.ssl.ManagerFactoryParameters.class}
     )
index 244d77b..2fd2ec6 100644 (file)
 
 package tests.api.javax.net.ssl;
 
-import dalvik.annotation.KnownFailure;
-import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-
-import java.io.FileInputStream;
 import java.io.FileNotFoundException;
-import java.io.InputStream;
 import java.security.KeyManagementException;
 import java.security.KeyStore;
 import java.security.KeyStoreException;
@@ -40,15 +32,20 @@ import javax.net.ssl.KeyManagerFactory;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLContextSpi;
 import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLSessionContext;
 import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSessionContext;
 import javax.net.ssl.SSLSocketFactory;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 
+import junit.framework.TestCase;
+
 import org.apache.harmony.security.tests.support.SpiEngUtils;
 import org.apache.harmony.xnet.tests.support.MySSLContextSpi;
-import junit.framework.TestCase;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
 
 /**
  * Tests for <code>SSLContext</code> class constructors and methods.
@@ -108,7 +105,8 @@ public class SSLContext1Test extends TestCase {
         args = {javax.net.ssl.SSLContextSpi.class, java.security.Provider.class, java.lang.String.class}
     )
     public void test_ConstructorLjavax_net_ssl_SSLContextSpiLjava_security_ProviderLjava_lang_String()
-        throws KeyManagementException {
+        throws NoSuchAlgorithmException,
+            KeyManagementException {
         if (!DEFSupported) {
             fail(NotSupportMsg);
             return;
@@ -116,22 +114,24 @@ public class SSLContext1Test extends TestCase {
         SSLContextSpi spi = new MySSLContextSpi();
         SSLContext sslContext = new mySSLContext(spi, defaultProvider,
                 defaultProtocol);
-        assertNotNull("Not CertStore object", sslContext);
-        assertEquals("Incorrect protocol", defaultProtocol,
-                sslContext.getProtocol());
-        assertEquals("Incorrect provider", defaultProvider,
-                sslContext.getProvider());
+        assertTrue("Not CertStore object", sslContext instanceof SSLContext);
+        assertEquals("Incorrect protocol", sslContext.getProtocol(),
+                defaultProtocol);
+        assertEquals("Incorrect provider", sslContext.getProvider(),
+                defaultProvider);
         TrustManager[] tm = null;
         KeyManager[] km = null;
         sslContext.init(km, tm, new SecureRandom());
+        assertTrue(sslContext.createSSLEngine() instanceof SSLEngine);
+        assertTrue(sslContext.createSSLEngine("host host", 8888) instanceof SSLEngine);
         try {
             sslContext.init(km, tm, null);
             fail("KeyManagementException should be thrown for null SEcureRandom");
         } catch (KeyManagementException e) {
-            // expected
         }
 
         sslContext = new mySSLContext(null, null, null);
+        assertTrue("Not CertStore object", sslContext instanceof SSLContext);
         assertNull("Incorrect protocol", sslContext.getProtocol());
         assertNull("Incorrect provider", sslContext.getProvider());
         try {
@@ -191,6 +191,7 @@ public class SSLContext1Test extends TestCase {
      * Test for <code>getClientSessionContext()</code>
      * <code>getServiceSessionContext()</code>
      * methods Assertion: returns correspondent object
+     * @throws KeyManagementException 
      */
     @TestTargetNew(
         level = TestLevel.COMPLETE,
@@ -198,8 +199,7 @@ public class SSLContext1Test extends TestCase {
         method = "getClientSessionContext",
         args = {}
     )
-    @KnownFailure("Works on RI but throws NPE on Android, maybe related to SSLSessionContextTest issues")
-    public void test_getClientSessionContext() {
+    public void test_getClientSessionContext() throws NoSuchAlgorithmException, KeyManagementException {
         if (!DEFSupported) {
             fail(NotSupportMsg);
             return;
@@ -207,10 +207,11 @@ public class SSLContext1Test extends TestCase {
         SSLContext[] sslC = createSSLCon();
         assertNotNull("SSLContext objects were not created", sslC);
         for (int i = 0; i < sslC.length; i++) {
-            assertNotNull("Client session is incorrectly instantiated", 
-                    sslC[i].getClientSessionContext());
-            assertNotNull("Server session is incorrectly instantiated", 
-                    sslC[i].getServerSessionContext());
+            sslC[i].init(null, null, null);
+            assertTrue("Client session is incorrectly instantiated: " + i + " ", 
+                    sslC[i].getClientSessionContext() instanceof SSLSessionContext);
+            assertTrue("Server session is incorrectly instantiated", 
+                    sslC[i].getServerSessionContext() instanceof SSLSessionContext);
         }
     }
 
@@ -220,7 +221,7 @@ public class SSLContext1Test extends TestCase {
      */
     @TestTargetNew(
         level = TestLevel.PARTIAL_COMPLETE,
-        notes = "checks valid protocol values",
+        notes = "",
         method = "getInstance",
         args = {java.lang.String.class}
     )
@@ -232,9 +233,10 @@ public class SSLContext1Test extends TestCase {
         SSLContext sslContext;
         for (int i = 0; i < validValues.length; i++) {
             sslContext = SSLContext.getInstance(validValues[i]);
-            assertNotNull("Not SSLContext object", sslContext);
-            assertEquals("Invalid protocol", validValues[i],
-                    sslContext.getProtocol());
+            assertTrue("Not SSLContext object",
+                    sslContext instanceof SSLContext);
+            assertEquals("Invalid protocol", sslContext.getProtocol(),
+                    validValues[i]);
         }
     }
 
@@ -245,14 +247,14 @@ public class SSLContext1Test extends TestCase {
      */
     @TestTargetNew(
         level = TestLevel.PARTIAL_COMPLETE,
-        notes = "checks invalid protocol values",
+        notes = "",
         method = "getInstance",
         args = {java.lang.String.class}
     )
     public void test_getInstanceLjava_lang_String02() {
         try {
             SSLContext.getInstance(null);
-            fail("NoSuchAlgorithmException or NullPointerException should be thrown (protocol is null)");
+            fail("NoSuchAlgorithmException or NullPointerException should be thrown (protocol is null");
         } catch (NoSuchAlgorithmException e) {
         } catch (NullPointerException e) {
         }
index 3f163c3..b002db2 100644 (file)
 
 package tests.api.javax.net.ssl;
 
-import dalvik.annotation.BrokenTest;
-import dalvik.annotation.KnownFailure;
-import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.AndroidOnly;
-
+import java.io.IOException;
 import java.nio.ByteBuffer;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-import javax.net.ssl.SSLException;
-import javax.net.ssl.SSLEngineResult;
 import java.nio.ReadOnlyBufferException;
+import java.nio.channels.Pipe;
+import java.nio.channels.Pipe.SinkChannel;
+import java.nio.channels.Pipe.SourceChannel;
 import java.security.KeyManagementException;
+import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
 import java.util.Arrays;
+import java.util.Vector;
+
+import javax.net.ssl.KeyManager;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLEngineResult;
+import javax.net.ssl.SSLException;
+import javax.net.ssl.X509TrustManager;
+import javax.net.ssl.SSLEngineResult.HandshakeStatus;
 
 import junit.framework.TestCase;
+import dalvik.annotation.AndroidOnly;
+import dalvik.annotation.KnownFailure;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
 
 
 /**
@@ -46,6 +56,9 @@ import junit.framework.TestCase;
 @TestTargetClass(SSLEngine.class) 
 public class SSLEngineTest extends TestCase {
 
+    private HandshakeHandler clientEngine;
+    private HandshakeHandler serverEngine;
+
     public static void main(String[] args) {
         junit.textui.TestRunner.run(SSLEngineTest.class);
     }
@@ -515,7 +528,7 @@ public class SSLEngineTest extends TestCase {
         method = "getDelegatedTask",
         args = {}
     )
-    @BrokenTest("Throws NPE because sse seems to be null")
+    @KnownFailure("org.apache.harmony.xnet.provider.jsse.SSLEngineImpl#getDelegatedTask() throws NPE instead of returning null")
     public void test_getDelegatedTask() throws NoSuchAlgorithmException {
         SSLEngine sse = getEngine();
         try {
@@ -526,6 +539,8 @@ public class SSLEngineTest extends TestCase {
     }
     
     /**
+     * @throws IOException 
+     * @throws InterruptedException 
      * @tests javax.net.ssl.SSLEngine#unwrap(ByteBuffer src, ByteBuffer[] dsts,
      *                                       int offset, int length)
      * Exception case: SSLException should be thrown.
@@ -536,14 +551,14 @@ public class SSLEngineTest extends TestCase {
         method = "unwrap",
         args = {ByteBuffer.class, ByteBuffer[].class, int.class, int.class}
     )
-    @BrokenTest("SSLException is not thrown")
-    public void test_unwrap_01() {
-        ByteBuffer bbs = ByteBuffer.wrap(new byte[] {1,2,3,1,2,3,1,2,3,1,2,3});
+    public void test_unwrap_01() throws IOException, InterruptedException {
+        prepareEngines();
+        doHandshake();
+        
+        ByteBuffer bbs = ByteBuffer.wrap(new byte[] {1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,31,2,3,1,2,3,1,2,3,1,2,3});
         ByteBuffer bbd = ByteBuffer.allocate(100);
-        SSLEngine sse = getEngine();
-        sse.setUseClientMode(true);
         try {
-            sse.unwrap(bbs, new ByteBuffer[] { bbd }, 0, 1);
+            clientEngine.engine.unwrap(bbs, new ByteBuffer[] { bbd }, 0, 1);
             fail("SSLException wasn't thrown");
         } catch (SSLException ex) {
             //expected
@@ -572,25 +587,25 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.unwrap(bb, bbA, -1, 3);
+            sse.unwrap(bb, bbA, -1, 3);
             fail("IndexOutOfBoundsException wasn't thrown");
         } catch (IndexOutOfBoundsException iobe) {
             //expected
         }
         try {
-            SSLEngineResult res = sse.unwrap(bb, bbA, 0, -3);
+            sse.unwrap(bb, bbA, 0, -3);
             fail("IndexOutOfBoundsException wasn't thrown");
         } catch (IndexOutOfBoundsException iobe) {
             //expected
         }
         try {
-            SSLEngineResult res = sse.unwrap(bb, bbA, bbA.length + 1, bbA.length);
+            sse.unwrap(bb, bbA, bbA.length + 1, bbA.length);
             fail("IndexOutOfBoundsException wasn't thrown");
         } catch (IndexOutOfBoundsException iobe) {
             //expected
         }
         try {
-            SSLEngineResult res = sse.unwrap(bb, bbA, 0, bbA.length + 1);
+            sse.unwrap(bb, bbA, 0, bbA.length + 1);
             fail("IndexOutOfBoundsException wasn't thrown");
         } catch (IndexOutOfBoundsException iobe) {
             //expected
@@ -620,7 +635,7 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.unwrap(bb, bbA, 0, bbA.length);
+            sse.unwrap(bb, bbA, 0, bbA.length);
             fail("ReadOnlyBufferException wasn't thrown");
         } catch (ReadOnlyBufferException iobe) {
             //expected
@@ -653,7 +668,7 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.unwrap(bN, bbA, 0, 3);
+            sse.unwrap(bN, bbA, 0, 3);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iobe) {
             //expected
@@ -662,7 +677,7 @@ public class SSLEngineTest extends TestCase {
             fail(e + " was thrown instead of IllegalArgumentException");
         }
         try {
-            SSLEngineResult res = sse.unwrap(bb, bbAN, 0, 3);
+            sse.unwrap(bb, bbAN, 0, 3);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iobe) {
             //expected
@@ -671,7 +686,7 @@ public class SSLEngineTest extends TestCase {
             fail(e + " was thrown instead of IllegalArgumentException");
         }
         try {
-            SSLEngineResult res = sse.unwrap(bb, bbN, 0, 0);
+            sse.unwrap(bb, bbN, 0, 0);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iobe) {
             //expected
@@ -680,7 +695,7 @@ public class SSLEngineTest extends TestCase {
             fail(e + " was thrown instead of IllegalArgumentException");
         }
         try {
-            SSLEngineResult res = sse.unwrap(bN, bbN, 0, 0);
+            sse.unwrap(bN, bbN, 0, 0);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iobe) {
             //expected
@@ -712,7 +727,7 @@ public class SSLEngineTest extends TestCase {
         SSLEngine sse = getEngine(host, port);
         
         try {
-            SSLEngineResult res = sse.unwrap(bb, bbA, 0, bbA.length);
+            sse.unwrap(bb, bbA, 0, bbA.length);
             fail("IllegalStateException wasn't thrown");
         } catch (IllegalStateException iobe) {
             //expected
@@ -750,26 +765,29 @@ public class SSLEngineTest extends TestCase {
     }
     
     /**
+     * @throws IOException 
+     * @throws InterruptedException 
      * @tests javax.net.ssl.SSLEngine#wrap(ByteBuffer[] srcs, int offset,
      *                                     int length, ByteBuffer dst)
      * Exception case: SSLException should be thrown.
      */
     @TestTargetNew(
-        level = TestLevel.PARTIAL_COMPLETE,
-        notes = "",
+        level = TestLevel.NOT_FEASIBLE,
+        notes = "wrap cannot be forced to fail",
         method = "wrap",
         args = {ByteBuffer[].class, int.class, int.class, ByteBuffer.class}
     )
-    @BrokenTest("SSLException is not thrown")
-    public void test_wrap_01() {
+    public void test_wrap_01() throws IOException, InterruptedException {
+        prepareEngines();
+        doHandshake();
+        
         ByteBuffer bbs = ByteBuffer.allocate(100);
-        ByteBuffer bbd = ByteBuffer.allocate(10);
-        SSLEngine sse = getEngine();
-        sse.setUseClientMode(true);
+        ByteBuffer bbd = ByteBuffer.allocate(20000);
         
         try {
-            sse.wrap(new ByteBuffer[] { bbs }, 0, 1, bbd);
-            fail("SSLException wasn't thrown");
+            @SuppressWarnings("unused")
+            SSLEngineResult result = clientEngine.engine.wrap(new ByteBuffer[] { bbs }, 0, 1, bbd);
+            //fail("SSLException wasn't thrown");
         } catch (SSLException ex) {
             //expected
         }
@@ -796,25 +814,25 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.wrap(bbA, -1, 3, bb);
+            sse.wrap(bbA, -1, 3, bb);
             fail("IndexOutOfBoundsException wasn't thrown");
         } catch (IndexOutOfBoundsException iobe) {
             //expected
         }
         try {
-            SSLEngineResult res = sse.wrap(bbA, 0, -3, bb);
+            sse.wrap(bbA, 0, -3, bb);
             fail("IndexOutOfBoundsException wasn't thrown");
         } catch (IndexOutOfBoundsException iobe) {
             //expected
         }
         try {
-            SSLEngineResult res = sse.wrap(bbA, bbA.length + 1, bbA.length, bb);
+            sse.wrap(bbA, bbA.length + 1, bbA.length, bb);
             fail("IndexOutOfBoundsException wasn't thrown");
         } catch (IndexOutOfBoundsException iobe) {
             //expected
         }
         try {
-            SSLEngineResult res = sse.wrap(bbA, 0, bbA.length + 1, bb);
+            sse.wrap(bbA, 0, bbA.length + 1, bb);
             fail("IndexOutOfBoundsException wasn't thrown");
         } catch (IndexOutOfBoundsException iobe) {
             //expected
@@ -841,7 +859,7 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.wrap(bbA, 0, bbA.length, bb);
+            sse.wrap(bbA, 0, bbA.length, bb);
             fail("ReadOnlyBufferException wasn't thrown");
         } catch (ReadOnlyBufferException iobe) {
             //expected
@@ -864,9 +882,7 @@ public class SSLEngineTest extends TestCase {
         String host = "new host";
         int port = 8080;
         ByteBuffer[] bbA = {ByteBuffer.allocate(100), ByteBuffer.allocate(10), ByteBuffer.allocate(100)};
-        ByteBuffer[] bbAN = {ByteBuffer.allocate(100), null, ByteBuffer.allocate(100)};
         ByteBuffer[] bbN = null;
-        ByteBuffer bb = ByteBuffer.allocate(10);
         ByteBuffer bN = null;
         SSLEngine e = getEngine(host, port);
         e.setUseClientMode(true);
@@ -910,7 +926,7 @@ public class SSLEngineTest extends TestCase {
         SSLEngine sse = getEngine(host, port);
         
         try {
-            SSLEngineResult res = sse.wrap(bbA, 0, bbA.length, bb);
+            sse.wrap(bbA, 0, bbA.length, bb);
             fail("IllegalStateException wasn't thrown");
         } catch (IllegalStateException iobe) {
             //expected
@@ -936,7 +952,7 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);        
         
         try {
-            SSLEngineResult res = sse.wrap(bbA, 0, bbA.length, bb);
+            sse.wrap(bbA, 0, bbA.length, bb);
         } catch (Exception ex) {
             fail("Unexpected exception: " + ex);
         }
@@ -1005,6 +1021,8 @@ public class SSLEngineTest extends TestCase {
     }
     
     /**
+     * @throws InterruptedException 
+     * @throws IOException 
      * @tests javax.net.ssl.SSLEngine#unwrap(ByteBuffer src, ByteBuffer dst)
      * SSLException should be thrown.
      */
@@ -1014,15 +1032,14 @@ public class SSLEngineTest extends TestCase {
         method = "unwrap",
         args = {ByteBuffer.class, ByteBuffer.class}
     )
-    @BrokenTest("SSLException is not thrown")
-    public void test_unwrap_ByteBuffer_ByteBuffer_01() {
+    public void test_unwrap_ByteBuffer_ByteBuffer_01() throws InterruptedException, IOException {
+        prepareEngines();
+        doHandshake();
         ByteBuffer bbs = ByteBuffer.allocate(100);
-        ByteBuffer bbd = ByteBuffer.allocate(10);
-        SSLEngine sse = getEngine();
-        sse.setUseClientMode(true);
+        ByteBuffer bbd = ByteBuffer.allocate(100);
         
         try {
-            sse.unwrap(bbs, bbd);
+            SSLEngineResult unwrap = clientEngine.engine.unwrap(bbs, bbd);
             fail("SSLException wasn't thrown");
         } catch (SSLException ex) {
             //expected
@@ -1049,7 +1066,7 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.unwrap(bbs, bbd);
+            sse.unwrap(bbs, bbd);
             fail("ReadOnlyBufferException wasn't thrown");
         } catch (ReadOnlyBufferException iobe) {
             //expected
@@ -1080,7 +1097,7 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.unwrap(bbsN, bbd);
+            sse.unwrap(bbsN, bbd);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iae) {
             //expected
@@ -1090,7 +1107,7 @@ public class SSLEngineTest extends TestCase {
         }
         
         try {
-            SSLEngineResult res = sse.unwrap(bbs, bbdN);
+            sse.unwrap(bbs, bbdN);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iae) {
             //expected
@@ -1100,7 +1117,7 @@ public class SSLEngineTest extends TestCase {
         }
         
         try {
-            SSLEngineResult res = sse.unwrap(bbsN, bbdN);
+            sse.unwrap(bbsN, bbdN);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iae) {
             //expected
@@ -1129,7 +1146,7 @@ public class SSLEngineTest extends TestCase {
         SSLEngine sse = getEngine(host, port);
         
         try {
-            SSLEngineResult res = sse.unwrap(bbs, bbd);
+            sse.unwrap(bbs, bbd);
             fail("IllegalStateException wasn't thrown");
         } catch (IllegalStateException iobe) {
             //expected
@@ -1174,21 +1191,37 @@ public class SSLEngineTest extends TestCase {
         method = "unwrap",
         args = {ByteBuffer.class, ByteBuffer[].class}
     )
-    @BrokenTest("SSLException is not thrown")
     public void test_unwrap_ByteBuffer$ByteBuffer_01() {
-        ByteBuffer bbs = ByteBuffer.allocate(100);
-        ByteBuffer bbd = ByteBuffer.allocate(10);
+        ByteBuffer bbs = ByteBuffer.allocate(20);
+        bbs.put("blablablabla".getBytes());
+        bbs.rewind();
+        ByteBuffer bbd = ByteBuffer.allocate(20000);
+        bbd.rewind();
         SSLEngine sse = getEngine();
         sse.setUseClientMode(true);
         
         try {
+                       sse.beginHandshake();
+
+               SSLEngineResult.HandshakeStatus status = sse.getHandshakeStatus();
+               int i = 0;
+               while (status == SSLEngineResult.HandshakeStatus.NEED_WRAP && i++ < 10) {
+                       SSLEngineResult result = sse.wrap(bbs, bbd);
+                       status = result.getHandshakeStatus();
+                       bbs.rewind();
+               }
+               } catch (SSLException e) {
+                       fail("unexpected exception : " + e);
+               }
+        
+        try {
             sse.unwrap(bbs, new ByteBuffer[] { bbd });
             fail("SSLException wasn't thrown");
         } catch (SSLException ex) {
             //expected
         }
     }
-    
+
     /**
      * @tests javax.net.ssl.SSLEngine#unwrap(ByteBuffer src, ByteBuffer[] dsts)
      * ReadOnlyBufferException should be thrown.
@@ -1210,7 +1243,7 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.unwrap(bbs, bbA);
+            sse.unwrap(bbs, bbA);
             fail("ReadOnlyBufferException wasn't thrown");
         } catch (ReadOnlyBufferException iobe) {
             //expected
@@ -1242,7 +1275,7 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.unwrap(bN, bbA);
+            sse.unwrap(bN, bbA);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iobe) {
             //expected
@@ -1252,7 +1285,7 @@ public class SSLEngineTest extends TestCase {
         }
         
         try {
-            SSLEngineResult res = sse.unwrap(bb, bbAN);
+            sse.unwrap(bb, bbAN);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iobe) {
             //expected
@@ -1262,7 +1295,7 @@ public class SSLEngineTest extends TestCase {
         }
         
         try {
-            SSLEngineResult res = sse.unwrap(bb, bbN);
+            sse.unwrap(bb, bbN);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iobe) {
             //expected
@@ -1272,7 +1305,7 @@ public class SSLEngineTest extends TestCase {
         }
         
         try {
-            SSLEngineResult res = sse.unwrap(bN, bbAN);
+            sse.unwrap(bN, bbAN);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iobe) {
             //expected
@@ -1301,7 +1334,7 @@ public class SSLEngineTest extends TestCase {
         SSLEngine sse = getEngine(host, port);
         
         try {
-            SSLEngineResult res = sse.unwrap(bbs, bbd);
+            sse.unwrap(bbs, bbd);
             fail("IllegalStateException wasn't thrown");
         } catch (IllegalStateException iobe) {
             //expected
@@ -1337,25 +1370,26 @@ public class SSLEngineTest extends TestCase {
     }
     
     /**
+     * @throws IOException 
+     * @throws InterruptedException 
      * @tests javax.net.ssl.SSLEngine#wrap(ByteBuffer src, ByteBuffer dst)
      * SSLException should be thrown.
      */
     @TestTargetNew(
-        level = TestLevel.PARTIAL_COMPLETE,
-        notes = "",
+        level = TestLevel.NOT_FEASIBLE,
+        notes = "wrap cannot be forced to produce SSLException",
         method = "wrap",
         args = {ByteBuffer.class, ByteBuffer.class}
     )
-    @BrokenTest("SSLException is not thrown")
-    public void test_wrap_ByteBuffer_ByteBuffer_01() {
-        ByteBuffer bbs = ByteBuffer.allocate(100);
-        ByteBuffer bbd = ByteBuffer.allocate(10);
-        SSLEngine sse = getEngine();
-        sse.setUseClientMode(true);
+    public void test_wrap_ByteBuffer_ByteBuffer_01() throws IOException, InterruptedException {
+        prepareEngines();
+        doHandshake();
+        ByteBuffer bbs = ByteBuffer.allocate(20);
+        ByteBuffer bbd = ByteBuffer.allocate(20000);
         
         try {
-            sse.wrap(bbs, bbd);
-            fail("SSLException wasn't thrown");
+            clientEngine.engine.wrap(bbs, bbd);
+            //fail("SSLException wasn't thrown");
         } catch (SSLException ex) {
             //expected
         }
@@ -1380,7 +1414,7 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.wrap(bbs, bbd);
+            sse.wrap(bbs, bbd);
             fail("ReadOnlyBufferException wasn't thrown");
         } catch (ReadOnlyBufferException iobe) {
             //expected
@@ -1411,7 +1445,7 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.wrap(bbsN, bbd);
+            sse.wrap(bbsN, bbd);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iae) {
             //expected
@@ -1421,7 +1455,7 @@ public class SSLEngineTest extends TestCase {
         }
         
         try {
-            SSLEngineResult res = sse.wrap(bbs, bbdN);
+            sse.wrap(bbs, bbdN);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iae) {
             //expected
@@ -1431,7 +1465,7 @@ public class SSLEngineTest extends TestCase {
         }
         
         try {
-            SSLEngineResult res = sse.wrap(bbsN, bbdN);
+            sse.wrap(bbsN, bbdN);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iae) {
             //expected
@@ -1460,7 +1494,7 @@ public class SSLEngineTest extends TestCase {
         SSLEngine sse = getEngine(host, port);
         
         try {
-            SSLEngineResult res = sse.wrap(bbs, bbd);
+            sse.wrap(bbs, bbd);
             fail("IllegalStateException wasn't thrown");
         } catch (IllegalStateException iobe) {
             //expected
@@ -1495,25 +1529,27 @@ public class SSLEngineTest extends TestCase {
     }
     
     /**
+     * @throws IOException 
+     * @throws InterruptedException 
      * @tests javax.net.ssl.SSLEngine#wrap(ByteBuffer[] srcs, ByteBuffer dst)
      * SSLException should be thrown.
      */
     @TestTargetNew(
         level = TestLevel.PARTIAL_COMPLETE,
-        notes = "",
+        notes = "wrap cannot be forced to throw SSLException",
         method = "wrap",
         args = {ByteBuffer[].class, ByteBuffer.class}
     )
-    @BrokenTest("SSLException is not thrown")
-    public void test_wrap_ByteBuffer$ByteBuffer_01() {
+    public void test_wrap_ByteBuffer$ByteBuffer_01() throws IOException, InterruptedException {
+        prepareEngines();
+        doHandshake();
         ByteBuffer bbs = ByteBuffer.allocate(100);
-        ByteBuffer bbd = ByteBuffer.allocate(10);
-        SSLEngine sse = getEngine();
-        sse.setUseClientMode(true);
+        ByteBuffer bbd = ByteBuffer.allocate(20000);
         
         try {
-            sse.wrap(new ByteBuffer[] { bbs }, bbd);
-            fail("SSLException wasn't thrown");
+            clientEngine.engine.wrap(new ByteBuffer[] { bbs }, bbd);
+            serverEngine.engine.wrap(new ByteBuffer[] { bbs }, bbd);
+            //fail("SSLException wasn't thrown");
         } catch (SSLException ex) {
             //expected
         }
@@ -1538,7 +1574,7 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.wrap(bbA, bb);
+            sse.wrap(bbA, bb);
             fail("ReadOnlyBufferException wasn't thrown");
         } catch (ReadOnlyBufferException iobe) {
             //expected
@@ -1562,7 +1598,6 @@ public class SSLEngineTest extends TestCase {
         String host = "new host";
         int port = 8080;
         ByteBuffer[] bbA = {ByteBuffer.allocate(100), ByteBuffer.allocate(10), ByteBuffer.allocate(100)};
-        ByteBuffer[] bbN = {ByteBuffer.allocate(100), null, ByteBuffer.allocate(100)};
         ByteBuffer[] bbAN = null;
         ByteBuffer bb = ByteBuffer.allocate(10);
         ByteBuffer bN = null;
@@ -1570,7 +1605,7 @@ public class SSLEngineTest extends TestCase {
         sse.setUseClientMode(true);
         
         try {
-            SSLEngineResult res = sse.wrap(bbA, bN);
+            sse.wrap(bbA, bN);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iobe) {
             //expected
@@ -1580,7 +1615,7 @@ public class SSLEngineTest extends TestCase {
         }
         
         try {
-            SSLEngineResult res = sse.wrap(bbAN, bb);
+            sse.wrap(bbAN, bb);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iobe) {
             //expected
@@ -1590,7 +1625,7 @@ public class SSLEngineTest extends TestCase {
         }
         
         try {
-            SSLEngineResult res = sse.wrap(bbAN, bN);
+            sse.wrap(bbAN, bN);
             fail("IllegalArgumentException wasn't thrown");
         } catch (IllegalArgumentException iobe) {
             //expected
@@ -1619,7 +1654,7 @@ public class SSLEngineTest extends TestCase {
         SSLEngine sse = getEngine(host, port);
         
         try {
-            SSLEngineResult res = sse.wrap(bbA, bb);
+            sse.wrap(bbA, bb);
             fail("IllegalStateException wasn't thrown");
         } catch (IllegalStateException iobe) {
             //expected
@@ -1681,4 +1716,288 @@ public class SSLEngineTest extends TestCase {
         }
         return context.createSSLEngine(host, port);
     }
+    
+    class HandshakeHandler implements Runnable {
+
+        private final SSLEngine engine;
+
+        private final SourceChannel in;
+
+        private final SinkChannel out;
+
+        private final ByteBuffer EMPTY = ByteBuffer.allocate(0);
+
+        @SuppressWarnings("unused")
+        private final String LOGTAG;
+
+        private SSLEngineResult.HandshakeStatus status;
+
+        private ByteBuffer readBuffer;
+
+        private ByteBuffer writeBuffer;
+
+        HandshakeHandler(boolean clientMode, SourceChannel in, SinkChannel out) {
+            this.in = in;
+            this.out = out;
+            engine = getEngine();
+            engine.setUseClientMode(clientMode);
+            String[] cipherSuites = engine.getSupportedCipherSuites();
+            Vector<String> enabledSuites = new Vector<String>();
+            for (String cipherSuite : cipherSuites) {
+                if (cipherSuite.contains("anon")) {
+                    enabledSuites.add(cipherSuite);
+                }
+            }
+            engine.setEnabledCipherSuites((String[])enabledSuites.toArray(new String[0]));
+
+            try {
+                engine.beginHandshake();
+                status = engine.getHandshakeStatus();
+            } catch (SSLException e) {
+                throw new RuntimeException("failed to start handshake");
+            }
+
+            if (clientMode) {
+                LOGTAG = "CLIENT: ";
+            } else {
+                LOGTAG = "SERVER: ";
+            }
+
+            log("CipherSuites: " + Arrays.toString(engine.getEnabledCipherSuites()));
+            log(status);
+
+            readBuffer = ByteBuffer.allocate(200000);
+            writeBuffer = ByteBuffer.allocate(20000);
+        }
+
+        public SSLEngineResult.HandshakeStatus getStatus() {
+            return status;
+        }
+
+        private void log(Object o) {
+            //System.out.print(LOGTAG);
+            //System.out.println(o);
+        }
+
+        private void reset(ByteBuffer buffer) {
+            buffer.rewind();
+            buffer.limit(buffer.capacity());
+        }
+
+        private ByteBuffer read() throws IOException {
+            if (readBuffer == null || readBuffer.remaining() == 0 || readBuffer.position() == 0) {
+                reset(readBuffer);
+                int read = in.read(readBuffer);
+                log("read: " + read);
+                readBuffer.rewind();
+                readBuffer.limit(read);
+            }
+            return readBuffer;
+        }
+
+        public void run() {
+            while (true) {
+                try {
+                    switch (status) {
+                        case FINISHED: {
+                            log(status);
+                            return;
+                        }
+                        case NEED_TASK: {
+                            log(status);
+                            Runnable task = null;
+                            while ((task = engine.getDelegatedTask()) != null) {
+                                task.run();
+                            }
+                            status = engine.getHandshakeStatus();
+                            break;
+                        }
+                        case NEED_UNWRAP: {
+                            log(status);
+                            ByteBuffer source = read();
+                            reset(writeBuffer);
+
+                            while (status == HandshakeStatus.NEED_UNWRAP) {
+                                SSLEngineResult result = engine.unwrap(source, writeBuffer);
+                                status = result.getHandshakeStatus();
+                                log(result);
+                            }
+                            break;
+                        }
+                        case NEED_WRAP: {
+                            log(status);
+                            reset(writeBuffer);
+
+                            int produced = 0;
+                            SSLEngineResult result = null;
+                            while (status == HandshakeStatus.NEED_WRAP) {
+                                result = engine.wrap(EMPTY, writeBuffer);
+                                status = result.getHandshakeStatus();
+                                produced += result.bytesProduced();
+                                log(result);
+                            }
+                            writeBuffer.rewind();
+                            writeBuffer.limit(produced);
+                            log("write: " + produced);
+                            out.write(writeBuffer);
+                            break;
+                        }
+                        case NOT_HANDSHAKING: {
+                            log("Not Handshaking");
+                            return;
+                        }
+                    }
+                } catch (IOException e) {
+                    log(e);
+                    return;
+                } catch (RuntimeException e) {
+                    // ignore;
+                    return;
+                }
+            }
+        }
+    }
+    
+    /** 
+     * Implements basically a dummy TrustManager. It stores the certificate
+     * chain it sees, so it can later be queried.
+     */
+    class TestTrustManager implements X509TrustManager {
+        
+        private X509Certificate[] chain;
+        
+        private String authType;
+        
+        public void checkClientTrusted(X509Certificate[] chain, String authType) {
+            this.chain = chain;
+            this.authType = authType;
+        }
+    
+        public void checkServerTrusted(X509Certificate[] chain, String authType) {
+            this.chain = chain;
+            this.authType = authType;
+        }
+    
+        public X509Certificate[] getAcceptedIssuers() {
+            return new X509Certificate[0];
+        }
+    
+        public X509Certificate[] getChain() {
+            return chain;
+        }
+        
+        public String getAuthType() {
+            return authType;
+        }
+        
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+                level = TestLevel.PARTIAL_COMPLETE,
+                notes = "",
+                method = "wrap",
+                args = {ByteBuffer.class, ByteBuffer.class}
+        ),
+        @TestTargetNew(
+                level = TestLevel.PARTIAL_COMPLETE,
+                notes = "",
+                method = "unwrap",
+                args = {ByteBuffer.class, ByteBuffer.class}
+        ),
+        @TestTargetNew(
+                level = TestLevel.PARTIAL_COMPLETE,
+                notes = "",
+                method = "beginHandshake",
+                args = {}
+        ),
+        @TestTargetNew(
+                level = TestLevel.PARTIAL_COMPLETE,
+                notes = "",
+                method = "getHandshakeStatus",
+                args = {}
+        ),
+        @TestTargetNew(
+                level = TestLevel.PARTIAL_COMPLETE,
+                notes = "",
+                method = "wrap",
+                args = {ByteBuffer[].class, ByteBuffer.class}
+        ),
+        @TestTargetNew(
+                level = TestLevel.PARTIAL_COMPLETE,
+                notes = "",
+                method = "getDelegatedTask",
+                args = {}
+        )
+    })
+    @KnownFailure("Handshake Status is never finished. NPE in ClientSessionContext$HostAndPort.hashCode() when host is null")
+    public void testHandshake() throws IOException, InterruptedException {
+       
+        prepareEngines();
+       
+        assertTrue("handshake failed", doHandshake());
+        
+        System.out.println(clientEngine.engine.getSession().getCipherSuite());
+       
+       assertEquals("Handshake not finished", SSLEngineResult.HandshakeStatus.FINISHED, clientEngine.getStatus());
+        assertEquals("Handshake not finished", SSLEngineResult.HandshakeStatus.FINISHED, serverEngine.getStatus());
+    }
+    
+    void prepareEngines() throws IOException {
+        Pipe clientSendPipe = Pipe.open();
+        Pipe serverSendPipe = Pipe.open();
+        
+        SinkChannel clientSink = clientSendPipe.sink();
+        SourceChannel serverSource = clientSendPipe.source();
+        SinkChannel serverSink = serverSendPipe.sink();
+        SourceChannel clientSource = serverSendPipe.source();
+        
+        clientEngine = new HandshakeHandler(true, clientSource, clientSink);
+        serverEngine = new HandshakeHandler(false, serverSource, serverSink);
+    }
+    
+    boolean doHandshake() throws InterruptedException {
+        Thread clientThread = new Thread(clientEngine);
+        clientThread.start();
+        
+        Thread serverThread = new Thread(serverEngine);
+        serverThread.start();
+        
+        int i = 0;
+        while (clientThread.isAlive() && serverThread.isAlive() && i < 20) {
+            Thread.sleep(500);
+            i++;
+        }
+        
+        if (clientThread.isAlive()) {
+            clientThread.interrupt();
+        }
+        
+        if (serverThread.isAlive()) {
+            serverThread.interrupt();
+        }
+        
+        return clientEngine.getStatus() == HandshakeStatus.FINISHED && serverEngine.getStatus() == HandshakeStatus.FINISHED;
+    }
+    
+
+    /**
+     * Loads a keystore from a base64-encoded String. Returns the KeyManager[]
+     * for the result.
+     */
+    private KeyManager[] getKeyManagers(String keys) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException {
+//        byte[] bytes = Base64.decode(keys.getBytes());                    
+//        InputStream inputStream = new ByteArrayInputStream(bytes);
+//        
+//        KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
+//        keyStore.load(inputStream, PASSWORD.toCharArray());
+//        inputStream.close();
+//        
+//        String algorithm = KeyManagerFactory.getDefaultAlgorithm();
+//        KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(algorithm);
+//        keyManagerFactory.init(keyStore, PASSWORD.toCharArray());
+//        
+//        return keyManagerFactory.getKeyManagers();
+        return null;
+    }    
 }
index 75f808b..09ff421 100644 (file)
@@ -1,6 +1,5 @@
 package tests.api.javax.net.ssl;
 
-import dalvik.annotation.BrokenTest;
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
@@ -11,6 +10,7 @@ import junit.framework.TestCase;
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLSessionContext;
 
+import java.security.KeyManagementException;
 import java.security.NoSuchAlgorithmException;
    
 /**
@@ -21,6 +21,7 @@ public class SSLSessionContextTest extends TestCase {
     
     /**
      * @throws NoSuchAlgorithmException 
+     * @throws KeyManagementException 
      * @tests javax.net.ssl.SSLSessionContex#getSessionCacheSize()
      * @tests javax.net.ssl.SSLSessionContex#setSessionCacheSize(int size)
      */
@@ -38,9 +39,10 @@ public class SSLSessionContextTest extends TestCase {
             args = {int.class}
         )
     })
-    @BrokenTest("getClientSessionContext returns null on android but does not on RI")
-    public final void test_sessionCacheSize() throws NoSuchAlgorithmException {
-        SSLSessionContext sc = SSLContext.getInstance("TLS")
+    public final void test_sessionCacheSize() throws NoSuchAlgorithmException, KeyManagementException {
+        SSLContext context = SSLContext.getInstance("TLS");
+        context.init(null, null, null);
+               SSLSessionContext sc = context
                 .getClientSessionContext();
         sc.setSessionCacheSize(10);
         assertEquals("10 wasn't returned", 10, sc.getSessionCacheSize());
@@ -57,6 +59,7 @@ public class SSLSessionContextTest extends TestCase {
     
     /**
      * @throws NoSuchAlgorithmException 
+     * @throws KeyManagementException 
      * @tests javax.net.ssl.SSLSessionContex#getSessionTimeout()
      * @tests javax.net.ssl.SSLSessionContex#setSessionTimeout(int seconds)
      */
@@ -74,9 +77,10 @@ public class SSLSessionContextTest extends TestCase {
             args = {int.class}
         )
     })
-    @BrokenTest("getClientSessionContext returns null on android but does not on RI")
-    public final void test_sessionTimeout() throws NoSuchAlgorithmException {
-        SSLSessionContext sc = SSLContext.getInstance("TLS")
+    public final void test_sessionTimeout() throws NoSuchAlgorithmException, KeyManagementException {
+        SSLContext context = SSLContext.getInstance("TLS");
+        context.init(null, null, null);
+               SSLSessionContext sc = context
                 .getClientSessionContext();
         sc.setSessionTimeout(100);
         assertEquals("100 wasn't returned", 100, sc.getSessionTimeout());
@@ -93,6 +97,7 @@ public class SSLSessionContextTest extends TestCase {
     
     /**
      * @throws NoSuchAlgorithmException 
+     * @throws KeyManagementException 
      * @tests javax.net.ssl.SSLSessionContex#getSession(byte[] sessionId)
      */
     @TestTargetNew(
@@ -101,9 +106,10 @@ public class SSLSessionContextTest extends TestCase {
         method = "getSession",
         args = {byte[].class}
     )
-    @BrokenTest("getClientSessionContext returns null on android but does not on RI")
-    public final void test_getSession() throws NoSuchAlgorithmException {
-        SSLSessionContext sc = SSLContext.getInstance("TLS")
+    public final void test_getSession() throws NoSuchAlgorithmException, KeyManagementException {
+        SSLContext context = SSLContext.getInstance("TLS");
+        context.init(null, null, null);
+               SSLSessionContext sc = context
                 .getClientSessionContext();
         try {
             sc.getSession(null);
@@ -115,6 +121,7 @@ public class SSLSessionContextTest extends TestCase {
     
     /**
      * @throws NoSuchAlgorithmException 
+     * @throws KeyManagementException 
      * @tests javax.net.ssl.SSLSessionContex#getIds()
      */
     @TestTargetNew(
@@ -123,9 +130,10 @@ public class SSLSessionContextTest extends TestCase {
         method = "getIds",
         args = {}
     )
-    @BrokenTest("getClientSessionContext returns null on android but does not on RI")
-    public final void test_getIds() throws NoSuchAlgorithmException {
-        SSLSessionContext sc = SSLContext.getInstance("TLS")
+    public final void test_getIds() throws NoSuchAlgorithmException, KeyManagementException {
+        SSLContext context = SSLContext.getInstance("TLS");
+        context.init(null, null, null);
+               SSLSessionContext sc = context
                 .getClientSessionContext();
         assertFalse(sc.getIds().hasMoreElements());
     }
index 32d775e..d58e08e 100644 (file)
@@ -35,9 +35,10 @@ import tests.support.Support_PortManager;
 @TestTargetClass(SSLSocketFactory.class) 
 public class SSLSocketFactoryTest extends TestCase {
     
+       private ServerSocket ss;
+       
     protected int startServer(String name) {
         int portNumber = Support_PortManager.getNextPort();
-        ServerSocket ss = null;
         try {
             ss = new ServerSocket(portNumber);
         } catch (IOException e) {
@@ -87,33 +88,37 @@ public class SSLSocketFactoryTest extends TestCase {
         method = "createSocket",
         args = {java.net.Socket.class, java.lang.String.class, int.class, boolean.class}
     )
-    @BrokenTest("throws SocketException, socket not connected on both RI and Android")
     public void test_createSocket() {
         SSLSocketFactory sf = (SSLSocketFactory) SSLSocketFactory.getDefault();
         int sport = startServer("test_createSocket()");
         int[] invalid = {Integer.MIN_VALUE, -1, 65536, Integer.MAX_VALUE};
-        String[] str = {null, ""};
+        String[] str = {"bla-bla"};
         try {
-           Socket s = sf.createSocket(new Socket(), "localhost", sport, false);
+               Socket st = new Socket("localhost", sport);
+           Socket s = sf.createSocket(st, "localhost", sport, false);
            assertFalse(s.isClosed());
         } catch (Exception ex) {
             fail("Unexpected exception " + ex);
         }
         try {
-            Socket s = sf.createSocket(new Socket(), "localhost", sport, true);
-            assertTrue(s.isClosed());
+               Socket st = new Socket("localhost", sport);
+            Socket s = sf.createSocket(st, "localhost", sport, true);
+            s.close();
+            assertTrue(st.isClosed());
         } catch (Exception ex) {
             fail("Unexpected exception " + ex);
         }
         try {
-            Socket s = sf.createSocket(null, "localhost", sport, true);
+            sf.createSocket(null, "localhost", sport, true);
             fail("IOException wasn't thrown");
         } catch (IOException ioe) {
             //expected
+        } catch (NullPointerException e) {
+               // expected
         }
         for (int i = 0; i < invalid.length; i++) {
             try {
-                Socket s = sf.createSocket(new Socket(), "localhost", invalid[i], false);
+                Socket s = sf.createSocket(new Socket(), "localhost", 1080, false);
                 fail("IOException wasn't thrown");
             } catch (IOException ioe) {
                 //expected
@@ -121,8 +126,9 @@ public class SSLSocketFactoryTest extends TestCase {
         }
         for (int i = 0; i < str.length; i++) {
             try {
-                Socket s = sf.createSocket(new Socket(), str[i], sport, false);
-                fail("UnknownHostException wasn't thrown");
+               Socket st = new Socket(str[i], sport);
+                Socket s = sf.createSocket(st, str[i], sport, false);
+                fail("UnknownHostException wasn't thrown: " + str[i]);
             } catch (UnknownHostException uhe) {
                 //expected
             } catch (Exception e) {
index ebd61fe..3ea3c8a 100644 (file)
@@ -1,24 +1,22 @@
 package tests.api.javax.net.ssl;
 
-import dalvik.annotation.BrokenTest;
-import dalvik.annotation.TestTargetClass; 
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetNew;
-
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.X509KeyManager;
-
+import java.io.ByteArrayInputStream;
+import java.net.Socket;
 import java.security.KeyFactory;
 import java.security.KeyStore;
 import java.security.NoSuchAlgorithmException;
 import java.security.PrivateKey;
 import java.security.cert.CertificateFactory;
 import java.security.cert.X509Certificate;
-import java.security.spec.X509EncodedKeySpec;
-import java.io.ByteArrayInputStream;
-import java.net.Socket;
+import java.security.spec.PKCS8EncodedKeySpec;
+
+import javax.net.ssl.KeyManagerFactory;
+import javax.net.ssl.X509KeyManager;
 
 import junit.framework.TestCase;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
 
 /**
  * Tests for <code>X509KeyManager</code> class constructors and methods.
@@ -108,6 +106,101 @@ public class X509KeyManagerTest extends TestCase {
        ByteArrayInputStream certArray = new ByteArrayInputStream(certificate
                .getBytes());
        
+       byte[] keyBytes = new byte[] {
+            (byte)0x30, (byte)0x82, (byte)0x02, (byte)0x77, (byte)0x02, (byte)0x01, (byte)0x00,
+            (byte)0x30, (byte)0x0d, (byte)0x06, (byte)0x09, (byte)0x2a, (byte)0x86, (byte)0x48,
+            (byte)0x86, (byte)0xf7, (byte)0x0d, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x05,
+            (byte)0x00, (byte)0x04, (byte)0x82, (byte)0x02, (byte)0x61, (byte)0x30, (byte)0x82,
+            (byte)0x02, (byte)0x5d, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x81,
+            (byte)0x81, (byte)0x00, (byte)0xaa, (byte)0x42, (byte)0x40, (byte)0xed, (byte)0x92,
+            (byte)0x21, (byte)0x17, (byte)0x99, (byte)0x5f, (byte)0x0e, (byte)0xe4, (byte)0x42,
+            (byte)0xb8, (byte)0xcb, (byte)0x66, (byte)0x3d, (byte)0x63, (byte)0x2a, (byte)0x16,
+            (byte)0x34, (byte)0x3c, (byte)0x7b, (byte)0xd3, (byte)0x3e, (byte)0x1f, (byte)0xa8,
+            (byte)0x3f, (byte)0xbd, (byte)0x9a, (byte)0xeb, (byte)0xb3, (byte)0x24, (byte)0x6b,
+            (byte)0x8c, (byte)0xe4, (byte)0xda, (byte)0x2f, (byte)0x31, (byte)0xbc, (byte)0x61,
+            (byte)0x07, (byte)0x27, (byte)0x2e, (byte)0x28, (byte)0x71, (byte)0x77, (byte)0x58,
+            (byte)0xae, (byte)0xb4, (byte)0x89, (byte)0x7c, (byte)0xeb, (byte)0xb0, (byte)0x06,
+            (byte)0x24, (byte)0x07, (byte)0x57, (byte)0x3c, (byte)0x54, (byte)0x71, (byte)0xdb,
+            (byte)0x71, (byte)0x41, (byte)0x05, (byte)0xab, (byte)0x3d, (byte)0x9f, (byte)0x05,
+            (byte)0xd2, (byte)0xca, (byte)0xcb, (byte)0x1c, (byte)0xbf, (byte)0x9d, (byte)0x8a,
+            (byte)0x21, (byte)0x96, (byte)0x8f, (byte)0x13, (byte)0x61, (byte)0x25, (byte)0x69,
+            (byte)0x12, (byte)0x3b, (byte)0x77, (byte)0xbd, (byte)0xf7, (byte)0x34, (byte)0xb2,
+            (byte)0x09, (byte)0xa9, (byte)0xe0, (byte)0x52, (byte)0x94, (byte)0x44, (byte)0x31,
+            (byte)0xce, (byte)0xdb, (byte)0x3d, (byte)0xeb, (byte)0x64, (byte)0xf1, (byte)0xd6,
+            (byte)0xca, (byte)0xc5, (byte)0x7d, (byte)0x2f, (byte)0xd6, (byte)0x6f, (byte)0x8d,
+            (byte)0xe4, (byte)0x29, (byte)0x8b, (byte)0x06, (byte)0x98, (byte)0x8a, (byte)0x95,
+            (byte)0x3d, (byte)0x7a, (byte)0x97, (byte)0x41, (byte)0x9a, (byte)0xf1, (byte)0x66,
+            (byte)0xc5, (byte)0x09, (byte)0x82, (byte)0x0d, (byte)0x02, (byte)0x03, (byte)0x01,
+            (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x81, (byte)0x80, (byte)0x34, (byte)0x91,
+            (byte)0x8e, (byte)0x50, (byte)0x8b, (byte)0xfc, (byte)0xf1, (byte)0xb7, (byte)0x66,
+            (byte)0x35, (byte)0x47, (byte)0xdf, (byte)0x1e, (byte)0x05, (byte)0x97, (byte)0x44,
+            (byte)0xbe, (byte)0xf8, (byte)0x80, (byte)0xb0, (byte)0x92, (byte)0x38, (byte)0x3d,
+            (byte)0x4a, (byte)0x02, (byte)0x26, (byte)0x45, (byte)0xbf, (byte)0xfa, (byte)0x34,
+            (byte)0x6a, (byte)0x34, (byte)0x85, (byte)0x8c, (byte)0x94, (byte)0x20, (byte)0x95,
+            (byte)0xcf, (byte)0xca, (byte)0x75, (byte)0x3e, (byte)0xeb, (byte)0x27, (byte)0x02,
+            (byte)0x4f, (byte)0xbe, (byte)0x64, (byte)0xc0, (byte)0x54, (byte)0x77, (byte)0xda,
+            (byte)0xfd, (byte)0x3e, (byte)0x75, (byte)0x36, (byte)0xec, (byte)0x99, (byte)0x4f,
+            (byte)0xc4, (byte)0x56, (byte)0xff, (byte)0x45, (byte)0x61, (byte)0xa8, (byte)0xa8,
+            (byte)0x41, (byte)0xe4, (byte)0x42, (byte)0x71, (byte)0x7a, (byte)0x8c, (byte)0x84,
+            (byte)0xc2, (byte)0x02, (byte)0x40, (byte)0x0b, (byte)0x3d, (byte)0x42, (byte)0xe0,
+            (byte)0x8b, (byte)0x22, (byte)0xf7, (byte)0x4c, (byte)0xa3, (byte)0xbb, (byte)0xd8,
+            (byte)0x8f, (byte)0x45, (byte)0xa2, (byte)0x55, (byte)0xc7, (byte)0xd0, (byte)0x6a,
+            (byte)0x25, (byte)0xbf, (byte)0xda, (byte)0x54, (byte)0x57, (byte)0x14, (byte)0x91,
+            (byte)0x0c, (byte)0x09, (byte)0x0b, (byte)0x9a, (byte)0x50, (byte)0xca, (byte)0xe6,
+            (byte)0x9e, (byte)0x28, (byte)0xc3, (byte)0x78, (byte)0x39, (byte)0x10, (byte)0x06,
+            (byte)0x02, (byte)0x96, (byte)0x10, (byte)0x1a, (byte)0xd2, (byte)0x4b, (byte)0x7b,
+            (byte)0x6c, (byte)0x72, (byte)0x9e, (byte)0x1e, (byte)0xac, (byte)0xd2, (byte)0xc1,
+            (byte)0x02, (byte)0x41, (byte)0x00, (byte)0xde, (byte)0x27, (byte)0xbd, (byte)0x43,
+            (byte)0xa4, (byte)0xbd, (byte)0x95, (byte)0x14, (byte)0x2e, (byte)0x1c, (byte)0xa0,
+            (byte)0x74, (byte)0xa5, (byte)0x3e, (byte)0xfa, (byte)0xf9, (byte)0x15, (byte)0xb2,
+            (byte)0x29, (byte)0x6a, (byte)0x2a, (byte)0x42, (byte)0x94, (byte)0x5a, (byte)0xf2,
+            (byte)0x81, (byte)0xf3, (byte)0xe1, (byte)0x76, (byte)0x49, (byte)0x11, (byte)0x9d,
+            (byte)0x18, (byte)0xc5, (byte)0xeb, (byte)0xb6, (byte)0xbc, (byte)0x81, (byte)0x3a,
+            (byte)0x14, (byte)0x9c, (byte)0x41, (byte)0x01, (byte)0x58, (byte)0x56, (byte)0xa9,
+            (byte)0x9b, (byte)0x73, (byte)0x2f, (byte)0xd9, (byte)0xa8, (byte)0x8e, (byte)0xc4,
+            (byte)0x48, (byte)0x69, (byte)0x35, (byte)0xe6, (byte)0xf4, (byte)0x73, (byte)0x2f,
+            (byte)0xf9, (byte)0x12, (byte)0x12, (byte)0x71, (byte)0x02, (byte)0x41, (byte)0x00,
+            (byte)0xc4, (byte)0x32, (byte)0x81, (byte)0x5d, (byte)0x19, (byte)0x54, (byte)0x2c,
+            (byte)0x29, (byte)0x5a, (byte)0x9f, (byte)0x36, (byte)0x4c, (byte)0x6f, (byte)0x2d,
+            (byte)0xfd, (byte)0x62, (byte)0x0e, (byte)0xe6, (byte)0x37, (byte)0xc2, (byte)0xf6,
+            (byte)0x69, (byte)0x64, (byte)0xf9, (byte)0x3a, (byte)0xcc, (byte)0xb2, (byte)0x63,
+            (byte)0x2f, (byte)0xa9, (byte)0xfe, (byte)0x7e, (byte)0x8b, (byte)0x2d, (byte)0x69,
+            (byte)0x13, (byte)0xe5, (byte)0x61, (byte)0x58, (byte)0xb7, (byte)0xfa, (byte)0x55,
+            (byte)0x74, (byte)0x2c, (byte)0xe8, (byte)0xa1, (byte)0xac, (byte)0xc3, (byte)0xdd,
+            (byte)0x5b, (byte)0x62, (byte)0xae, (byte)0x0a, (byte)0x27, (byte)0xce, (byte)0xb0,
+            (byte)0xf2, (byte)0x81, (byte)0x5f, (byte)0x9a, (byte)0x6f, (byte)0x5f, (byte)0x3f,
+            (byte)0x5d, (byte)0x02, (byte)0x41, (byte)0x00, (byte)0x92, (byte)0x42, (byte)0xff,
+            (byte)0xac, (byte)0xe5, (byte)0x6d, (byte)0x9c, (byte)0x15, (byte)0x29, (byte)0x36,
+            (byte)0xd7, (byte)0xbd, (byte)0x74, (byte)0x7e, (byte)0x3e, (byte)0xa6, (byte)0x77,
+            (byte)0xce, (byte)0x50, (byte)0xce, (byte)0x00, (byte)0xfc, (byte)0xcc, (byte)0xc8,
+            (byte)0x04, (byte)0x19, (byte)0xe3, (byte)0x03, (byte)0x71, (byte)0xe9, (byte)0x31,
+            (byte)0x9b, (byte)0x88, (byte)0x8f, (byte)0xe6, (byte)0x5c, (byte)0xed, (byte)0x46,
+            (byte)0xf7, (byte)0x82, (byte)0x52, (byte)0x4d, (byte)0xca, (byte)0x20, (byte)0xeb,
+            (byte)0x0d, (byte)0xc7, (byte)0xb6, (byte)0xd2, (byte)0xae, (byte)0x2e, (byte)0xf7,
+            (byte)0xaf, (byte)0xeb, (byte)0x2c, (byte)0xb9, (byte)0xbc, (byte)0x50, (byte)0xfc,
+            (byte)0xf5, (byte)0x7c, (byte)0xba, (byte)0x95, (byte)0x41, (byte)0x02, (byte)0x40,
+            (byte)0x54, (byte)0xf8, (byte)0x46, (byte)0x9c, (byte)0x6a, (byte)0x5e, (byte)0xd0,
+            (byte)0xed, (byte)0x6c, (byte)0x08, (byte)0xed, (byte)0xfc, (byte)0x36, (byte)0x5e,
+            (byte)0x65, (byte)0x91, (byte)0x75, (byte)0x40, (byte)0x71, (byte)0x3f, (byte)0xe7,
+            (byte)0x76, (byte)0x07, (byte)0xbc, (byte)0x04, (byte)0xa2, (byte)0x28, (byte)0x53,
+            (byte)0xda, (byte)0x8d, (byte)0xb5, (byte)0xe1, (byte)0x5a, (byte)0x27, (byte)0x65,
+            (byte)0x8d, (byte)0xaf, (byte)0x56, (byte)0xf4, (byte)0x94, (byte)0x61, (byte)0x3f,
+            (byte)0x67, (byte)0x1c, (byte)0x17, (byte)0xf8, (byte)0x05, (byte)0x19, (byte)0xa2,
+            (byte)0xa1, (byte)0x74, (byte)0x60, (byte)0x49, (byte)0x97, (byte)0xa9, (byte)0xe5,
+            (byte)0x6a, (byte)0x71, (byte)0x6b, (byte)0x55, (byte)0x38, (byte)0x0c, (byte)0xb9,
+            (byte)0x25, (byte)0x02, (byte)0x41, (byte)0x00, (byte)0xae, (byte)0xf2, (byte)0xa8,
+            (byte)0x6d, (byte)0x1d, (byte)0x35, (byte)0x38, (byte)0x73, (byte)0x98, (byte)0x15,
+            (byte)0xc7, (byte)0x15, (byte)0x02, (byte)0x2f, (byte)0x29, (byte)0x5d, (byte)0x18,
+            (byte)0x4b, (byte)0x7d, (byte)0xb2, (byte)0x59, (byte)0xbe, (byte)0x5a, (byte)0xc7,
+            (byte)0x72, (byte)0xd0, (byte)0x80, (byte)0xd8, (byte)0x77, (byte)0xa1, (byte)0x7f,
+            (byte)0xb2, (byte)0x35, (byte)0x0d, (byte)0x78, (byte)0x92, (byte)0x91, (byte)0x35,
+            (byte)0x47, (byte)0xeb, (byte)0x4b, (byte)0x00, (byte)0x59, (byte)0xb4, (byte)0xc4,
+            (byte)0x2c, (byte)0x29, (byte)0xe7, (byte)0x39, (byte)0x9d, (byte)0x48, (byte)0x8b,
+            (byte)0x4f, (byte)0x46, (byte)0xe6, (byte)0xce, (byte)0xd3, (byte)0x6c, (byte)0x84,
+            (byte)0x9b, (byte)0xd2, (byte)0x10, (byte)0xb0, (byte)0xe1
+    };
+       
+       /*
        String key = "-----BEGIN RSA PRIVATE KEY-----\n"
                + "Proc-Type: 4,ENCRYPTED\n"
                + "DEK-Info: DES-EDE3-CBC,69E26FCC3A7F136E\n"
@@ -128,6 +221,7 @@ public class X509KeyManagerTest extends TestCase {
                + "-----END RSA PRIVATE KEY-----";
 
        ByteArrayInputStream keyArray = new ByteArrayInputStream(key.getBytes());
+       */
 
        /*
        Certificate:
@@ -196,6 +290,101 @@ public class X509KeyManagerTest extends TestCase {
        ByteArrayInputStream certArray2 = new ByteArrayInputStream(certificate2
                .getBytes());
        
+       byte[] key2Bytes = new byte[] {
+            (byte)0x30, (byte)0x82, (byte)0x02, (byte)0x75, (byte)0x02, (byte)0x01, (byte)0x00,
+            (byte)0x30, (byte)0x0d, (byte)0x06, (byte)0x09, (byte)0x2a, (byte)0x86, (byte)0x48,
+            (byte)0x86, (byte)0xf7, (byte)0x0d, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x05,
+            (byte)0x00, (byte)0x04, (byte)0x82, (byte)0x02, (byte)0x5f, (byte)0x30, (byte)0x82,
+            (byte)0x02, (byte)0x5b, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x81,
+            (byte)0x81, (byte)0x00, (byte)0xd0, (byte)0x44, (byte)0x5a, (byte)0xc4, (byte)0x76,
+            (byte)0xef, (byte)0xae, (byte)0xff, (byte)0x99, (byte)0x5b, (byte)0xc3, (byte)0x37,
+            (byte)0xc1, (byte)0x09, (byte)0x33, (byte)0xc1, (byte)0x97, (byte)0xe5, (byte)0x64,
+            (byte)0x7a, (byte)0xa9, (byte)0x7e, (byte)0x98, (byte)0x4b, (byte)0x3a, (byte)0xa3,
+            (byte)0x33, (byte)0xd0, (byte)0x5c, (byte)0xc7, (byte)0x56, (byte)0xac, (byte)0xd8,
+            (byte)0x42, (byte)0xe8, (byte)0x4a, (byte)0xac, (byte)0x9c, (byte)0xd9, (byte)0x8f,
+            (byte)0x89, (byte)0x84, (byte)0xc8, (byte)0x46, (byte)0x95, (byte)0xce, (byte)0x22,
+            (byte)0xf7, (byte)0x6a, (byte)0x09, (byte)0xde, (byte)0x91, (byte)0x47, (byte)0x9c,
+            (byte)0x38, (byte)0x23, (byte)0xa5, (byte)0x4a, (byte)0xfc, (byte)0x08, (byte)0xaf,
+            (byte)0x5a, (byte)0xb4, (byte)0x6e, (byte)0x39, (byte)0x8e, (byte)0xe9, (byte)0xf5,
+            (byte)0x0e, (byte)0x46, (byte)0x00, (byte)0x69, (byte)0xe1, (byte)0xe5, (byte)0xcc,
+            (byte)0x4c, (byte)0x81, (byte)0xb6, (byte)0x82, (byte)0x7b, (byte)0x56, (byte)0xfb,
+            (byte)0xf4, (byte)0xdc, (byte)0x04, (byte)0xff, (byte)0x61, (byte)0xe2, (byte)0x7e,
+            (byte)0x5f, (byte)0xe2, (byte)0xf9, (byte)0x97, (byte)0x53, (byte)0x93, (byte)0xd4,
+            (byte)0x69, (byte)0x9b, (byte)0xba, (byte)0x79, (byte)0x20, (byte)0xcd, (byte)0x1e,
+            (byte)0x3e, (byte)0xd5, (byte)0x9a, (byte)0x44, (byte)0x95, (byte)0x7c, (byte)0xcf,
+            (byte)0xc1, (byte)0x51, (byte)0xf2, (byte)0x22, (byte)0xfc, (byte)0xec, (byte)0xcc,
+            (byte)0x66, (byte)0x18, (byte)0x74, (byte)0x60, (byte)0x2a, (byte)0xa2, (byte)0xbe,
+            (byte)0x06, (byte)0xc2, (byte)0x9e, (byte)0x8d, (byte)0x02, (byte)0x03, (byte)0x01,
+            (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x81, (byte)0x80, (byte)0x06, (byte)0x41,
+            (byte)0xd7, (byte)0x7c, (byte)0x49, (byte)0x9a, (byte)0x7f, (byte)0xe6, (byte)0x7c,
+            (byte)0x04, (byte)0x0e, (byte)0xc4, (byte)0x71, (byte)0x0f, (byte)0x46, (byte)0xb7,
+            (byte)0xcd, (byte)0x49, (byte)0x7e, (byte)0x10, (byte)0x55, (byte)0x61, (byte)0x51,
+            (byte)0x50, (byte)0x09, (byte)0x4d, (byte)0xf7, (byte)0xf3, (byte)0x8d, (byte)0xa6,
+            (byte)0x0b, (byte)0x8b, (byte)0x9b, (byte)0xdf, (byte)0xbe, (byte)0xbc, (byte)0xe7,
+            (byte)0x9c, (byte)0xba, (byte)0xc8, (byte)0x9e, (byte)0x38, (byte)0x18, (byte)0x10,
+            (byte)0x4e, (byte)0xd5, (byte)0xe7, (byte)0xa5, (byte)0x09, (byte)0x51, (byte)0x8c,
+            (byte)0x97, (byte)0x4e, (byte)0xd0, (byte)0x79, (byte)0xbb, (byte)0x50, (byte)0x6f,
+            (byte)0x05, (byte)0x4d, (byte)0x79, (byte)0x7f, (byte)0x3f, (byte)0x26, (byte)0x76,
+            (byte)0xc1, (byte)0xcc, (byte)0x40, (byte)0x0f, (byte)0xde, (byte)0x42, (byte)0x5d,
+            (byte)0xc1, (byte)0x5f, (byte)0x70, (byte)0x46, (byte)0x70, (byte)0x8d, (byte)0xff,
+            (byte)0x26, (byte)0x35, (byte)0x75, (byte)0x9a, (byte)0x97, (byte)0xd2, (byte)0x74,
+            (byte)0x53, (byte)0x11, (byte)0x2b, (byte)0xc1, (byte)0x76, (byte)0x9c, (byte)0x9f,
+            (byte)0x93, (byte)0xaa, (byte)0xa8, (byte)0x41, (byte)0x23, (byte)0x9a, (byte)0x04,
+            (byte)0x11, (byte)0x6e, (byte)0x56, (byte)0xea, (byte)0xf5, (byte)0xd6, (byte)0x1d,
+            (byte)0x49, (byte)0x2a, (byte)0x83, (byte)0x49, (byte)0x7d, (byte)0xb7, (byte)0xd1,
+            (byte)0xe6, (byte)0x8d, (byte)0x93, (byte)0x1a, (byte)0x81, (byte)0x8e, (byte)0xc2,
+            (byte)0xb9, (byte)0xbf, (byte)0xfd, (byte)0x00, (byte)0xe2, (byte)0xb5, (byte)0x01,
+            (byte)0x02, (byte)0x41, (byte)0x00, (byte)0xea, (byte)0xce, (byte)0xc6, (byte)0x11,
+            (byte)0x1e, (byte)0xf6, (byte)0xcf, (byte)0x3a, (byte)0x8c, (byte)0xe7, (byte)0x80,
+            (byte)0x16, (byte)0x8f, (byte)0x1d, (byte)0xeb, (byte)0xa2, (byte)0xd2, (byte)0x23,
+            (byte)0x9e, (byte)0xf9, (byte)0xf1, (byte)0x14, (byte)0x16, (byte)0xc8, (byte)0x87,
+            (byte)0xf2, (byte)0x17, (byte)0xdf, (byte)0xc6, (byte)0xe4, (byte)0x1c, (byte)0x74,
+            (byte)0x74, (byte)0xb0, (byte)0xbb, (byte)0x40, (byte)0xeb, (byte)0xa6, (byte)0xb2,
+            (byte)0x5b, (byte)0x6d, (byte)0xf5, (byte)0x9a, (byte)0x85, (byte)0xf1, (byte)0x73,
+            (byte)0x84, (byte)0xec, (byte)0xdb, (byte)0x9b, (byte)0xf9, (byte)0xf8, (byte)0x3d,
+            (byte)0xba, (byte)0xeb, (byte)0xd7, (byte)0x6c, (byte)0x45, (byte)0x7b, (byte)0xca,
+            (byte)0x12, (byte)0x67, (byte)0x5f, (byte)0xcd, (byte)0x02, (byte)0x41, (byte)0x00,
+            (byte)0xe3, (byte)0x10, (byte)0x5b, (byte)0xd0, (byte)0xad, (byte)0x59, (byte)0x90,
+            (byte)0x18, (byte)0x17, (byte)0xdc, (byte)0x68, (byte)0xd4, (byte)0x75, (byte)0x55,
+            (byte)0xab, (byte)0x7d, (byte)0xd1, (byte)0xb5, (byte)0x5a, (byte)0xc4, (byte)0xb0,
+            (byte)0x2d, (byte)0xa9, (byte)0xd1, (byte)0x6f, (byte)0xe9, (byte)0x21, (byte)0x4a,
+            (byte)0x27, (byte)0xc4, (byte)0x98, (byte)0x89, (byte)0xfa, (byte)0x65, (byte)0xb6,
+            (byte)0x10, (byte)0x5d, (byte)0x66, (byte)0xdd, (byte)0x17, (byte)0xb3, (byte)0xf3,
+            (byte)0xd3, (byte)0xe3, (byte)0xa0, (byte)0x1a, (byte)0x93, (byte)0xe4, (byte)0xfb,
+            (byte)0x88, (byte)0xa7, (byte)0x3b, (byte)0x97, (byte)0x1b, (byte)0xf1, (byte)0x08,
+            (byte)0x0c, (byte)0x66, (byte)0xd0, (byte)0x86, (byte)0x5e, (byte)0x39, (byte)0xf9,
+            (byte)0xc1, (byte)0x02, (byte)0x40, (byte)0x24, (byte)0x7c, (byte)0xcd, (byte)0x3a,
+            (byte)0x8b, (byte)0xdd, (byte)0x3e, (byte)0x86, (byte)0x92, (byte)0xae, (byte)0xc6,
+            (byte)0xb0, (byte)0xba, (byte)0xbc, (byte)0xa3, (byte)0x89, (byte)0x41, (byte)0xae,
+            (byte)0x57, (byte)0x5d, (byte)0xef, (byte)0xa0, (byte)0x77, (byte)0x89, (byte)0xe1,
+            (byte)0xd6, (byte)0x34, (byte)0xef, (byte)0x89, (byte)0x30, (byte)0x99, (byte)0x5b,
+            (byte)0x5f, (byte)0x66, (byte)0xb7, (byte)0x32, (byte)0x77, (byte)0x6c, (byte)0x07,
+            (byte)0xfb, (byte)0x3d, (byte)0x33, (byte)0x15, (byte)0x38, (byte)0x0b, (byte)0x35,
+            (byte)0x30, (byte)0x4a, (byte)0xbe, (byte)0x35, (byte)0x96, (byte)0xba, (byte)0x84,
+            (byte)0x9d, (byte)0x2f, (byte)0x58, (byte)0xe2, (byte)0x72, (byte)0x49, (byte)0xb2,
+            (byte)0x34, (byte)0xf9, (byte)0xeb, (byte)0x61, (byte)0x02, (byte)0x40, (byte)0x2a,
+            (byte)0xd4, (byte)0x89, (byte)0x1d, (byte)0x21, (byte)0xb5, (byte)0xc5, (byte)0x32,
+            (byte)0x66, (byte)0x3d, (byte)0xd3, (byte)0x20, (byte)0x50, (byte)0x49, (byte)0xaa,
+            (byte)0xa1, (byte)0x7f, (byte)0x0f, (byte)0x20, (byte)0x61, (byte)0xfd, (byte)0x81,
+            (byte)0x7f, (byte)0x88, (byte)0xdb, (byte)0xfd, (byte)0x33, (byte)0xa4, (byte)0x53,
+            (byte)0x40, (byte)0x08, (byte)0x2d, (byte)0xee, (byte)0xa7, (byte)0x84, (byte)0xe2,
+            (byte)0x2d, (byte)0x5c, (byte)0x1b, (byte)0xd4, (byte)0x3e, (byte)0xc3, (byte)0x7d,
+            (byte)0x72, (byte)0x70, (byte)0x5e, (byte)0xd3, (byte)0x0a, (byte)0xdc, (byte)0x4f,
+            (byte)0x78, (byte)0x8c, (byte)0x0b, (byte)0x02, (byte)0xe0, (byte)0x42, (byte)0x4e,
+            (byte)0x64, (byte)0x8e, (byte)0x6c, (byte)0xea, (byte)0x15, (byte)0x31, (byte)0x81,
+            (byte)0x02, (byte)0x40, (byte)0x57, (byte)0x72, (byte)0xb9, (byte)0x78, (byte)0xc0,
+            (byte)0x1f, (byte)0x5b, (byte)0x1d, (byte)0xb2, (byte)0xcf, (byte)0x94, (byte)0x42,
+            (byte)0xed, (byte)0xbd, (byte)0xe7, (byte)0xaa, (byte)0x14, (byte)0x56, (byte)0xd0,
+            (byte)0x94, (byte)0x25, (byte)0x30, (byte)0x87, (byte)0x35, (byte)0x82, (byte)0xa0,
+            (byte)0x42, (byte)0xb5, (byte)0x7f, (byte)0x66, (byte)0x77, (byte)0xb0, (byte)0x13,
+            (byte)0xbe, (byte)0x57, (byte)0x06, (byte)0x7e, (byte)0x50, (byte)0x67, (byte)0x13,
+            (byte)0xa7, (byte)0x09, (byte)0xac, (byte)0xd6, (byte)0xbf, (byte)0x22, (byte)0x74,
+            (byte)0x6b, (byte)0x37, (byte)0x92, (byte)0x2b, (byte)0x91, (byte)0xbd, (byte)0x0a,
+            (byte)0xd8, (byte)0x0f, (byte)0x8d, (byte)0x86, (byte)0x4b, (byte)0x20, (byte)0x5e,
+            (byte)0x50, (byte)0x60, (byte)0x80
+    };
+
+       /*
        String key2 = "-----BEGIN RSA PRIVATE KEY-----\n"
                + "Proc-Type: 4,ENCRYPTED\n"
                + "DEK-Info: DES-EDE3-CBC,370723FFDC1B1CFA\n"
@@ -216,7 +405,8 @@ public class X509KeyManagerTest extends TestCase {
                + "-----END RSA PRIVATE KEY-----";
 
        ByteArrayInputStream keyArray2 = new ByteArrayInputStream(key2.getBytes());
-
+          */
+       
        /*
        Certificate:
            Data:
@@ -284,6 +474,101 @@ public class X509KeyManagerTest extends TestCase {
     ByteArrayInputStream certArray3 = new ByteArrayInputStream(certificate3
             .getBytes());
     
+    byte[] key3Bytes = new byte[] {
+            (byte)0x30, (byte)0x82, (byte)0x02, (byte)0x76, (byte)0x02, (byte)0x01, (byte)0x00,
+            (byte)0x30, (byte)0x0d, (byte)0x06, (byte)0x09, (byte)0x2a, (byte)0x86, (byte)0x48,
+            (byte)0x86, (byte)0xf7, (byte)0x0d, (byte)0x01, (byte)0x01, (byte)0x01, (byte)0x05,
+            (byte)0x00, (byte)0x04, (byte)0x82, (byte)0x02, (byte)0x60, (byte)0x30, (byte)0x82,
+            (byte)0x02, (byte)0x5c, (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x02, (byte)0x81,
+            (byte)0x81, (byte)0x00, (byte)0xb4, (byte)0xc5, (byte)0xed, (byte)0xdf, (byte)0x30,
+            (byte)0x42, (byte)0x6d, (byte)0x8b, (byte)0xaf, (byte)0x4b, (byte)0xe4, (byte)0x9c,
+            (byte)0x13, (byte)0x5e, (byte)0x83, (byte)0x23, (byte)0xcd, (byte)0x2f, (byte)0xce,
+            (byte)0x34, (byte)0xe2, (byte)0x43, (byte)0xd7, (byte)0x6c, (byte)0x72, (byte)0xbb,
+            (byte)0x03, (byte)0xb3, (byte)0xb9, (byte)0x24, (byte)0x02, (byte)0xe0, (byte)0xcc,
+            (byte)0xb5, (byte)0x8d, (byte)0xd6, (byte)0x92, (byte)0x41, (byte)0x04, (byte)0x2b,
+            (byte)0x5c, (byte)0x94, (byte)0xb2, (byte)0xc3, (byte)0x9c, (byte)0x9d, (byte)0x56,
+            (byte)0xf0, (byte)0x99, (byte)0xbc, (byte)0x0f, (byte)0x81, (byte)0xaf, (byte)0xeb,
+            (byte)0x54, (byte)0xed, (byte)0x80, (byte)0xa6, (byte)0xa0, (byte)0xc7, (byte)0xc2,
+            (byte)0x43, (byte)0x05, (byte)0x04, (byte)0x7c, (byte)0x9c, (byte)0x7e, (byte)0x07,
+            (byte)0x03, (byte)0x10, (byte)0xb9, (byte)0xbd, (byte)0xc5, (byte)0x16, (byte)0xcf,
+            (byte)0x19, (byte)0xdd, (byte)0xe3, (byte)0x4f, (byte)0x73, (byte)0x83, (byte)0x72,
+            (byte)0xc5, (byte)0x66, (byte)0xe4, (byte)0x5b, (byte)0x14, (byte)0xc4, (byte)0x96,
+            (byte)0xd1, (byte)0xe3, (byte)0x24, (byte)0x0b, (byte)0xb6, (byte)0xd4, (byte)0xf7,
+            (byte)0x84, (byte)0x2e, (byte)0xb1, (byte)0xe7, (byte)0x93, (byte)0x02, (byte)0x9d,
+            (byte)0xf5, (byte)0xda, (byte)0xaa, (byte)0xc1, (byte)0xd9, (byte)0xcc, (byte)0x5e,
+            (byte)0x36, (byte)0xe9, (byte)0x8f, (byte)0xbf, (byte)0x8b, (byte)0xda, (byte)0xa7,
+            (byte)0x45, (byte)0x82, (byte)0xf2, (byte)0xb0, (byte)0xf5, (byte)0xa7, (byte)0xe4,
+            (byte)0xe1, (byte)0x80, (byte)0xa3, (byte)0x17, (byte)0x02, (byte)0x03, (byte)0x01,
+            (byte)0x00, (byte)0x01, (byte)0x02, (byte)0x81, (byte)0x80, (byte)0x53, (byte)0xbc,
+            (byte)0x1f, (byte)0x1c, (byte)0x34, (byte)0x09, (byte)0x81, (byte)0x1e, (byte)0xa3,
+            (byte)0xfb, (byte)0x5e, (byte)0x90, (byte)0xa1, (byte)0x34, (byte)0x35, (byte)0x40,
+            (byte)0x9f, (byte)0x29, (byte)0xd6, (byte)0xb5, (byte)0x8e, (byte)0x5d, (byte)0x68,
+            (byte)0x6a, (byte)0xf6, (byte)0x96, (byte)0x03, (byte)0xf7, (byte)0xfa, (byte)0xf9,
+            (byte)0x60, (byte)0x4f, (byte)0xea, (byte)0xe2, (byte)0xea, (byte)0x29, (byte)0x8b,
+            (byte)0x23, (byte)0x8c, (byte)0x9f, (byte)0xdd, (byte)0x49, (byte)0x8f, (byte)0xa8,
+            (byte)0xa6, (byte)0x62, (byte)0x07, (byte)0x44, (byte)0x79, (byte)0xa1, (byte)0xaf,
+            (byte)0xf9, (byte)0x1d, (byte)0x98, (byte)0xbf, (byte)0x85, (byte)0x28, (byte)0x03,
+            (byte)0x87, (byte)0x14, (byte)0x20, (byte)0xba, (byte)0xd4, (byte)0x96, (byte)0x61,
+            (byte)0x2a, (byte)0xd0, (byte)0xaa, (byte)0x30, (byte)0x19, (byte)0x4b, (byte)0x40,
+            (byte)0x35, (byte)0xb0, (byte)0x79, (byte)0x0b, (byte)0x7f, (byte)0xd7, (byte)0xcd,
+            (byte)0x64, (byte)0xd9, (byte)0x93, (byte)0x38, (byte)0xe2, (byte)0x59, (byte)0xe0,
+            (byte)0x9e, (byte)0x3a, (byte)0x25, (byte)0x27, (byte)0xa2, (byte)0xd9, (byte)0x20,
+            (byte)0xb0, (byte)0x45, (byte)0x5f, (byte)0x6c, (byte)0x15, (byte)0x6f, (byte)0x10,
+            (byte)0x55, (byte)0xa7, (byte)0xf9, (byte)0x3d, (byte)0x92, (byte)0x3c, (byte)0x7c,
+            (byte)0x23, (byte)0x1b, (byte)0xc0, (byte)0xb5, (byte)0x17, (byte)0x41, (byte)0x5e,
+            (byte)0x8c, (byte)0xdc, (byte)0x25, (byte)0x1d, (byte)0x35, (byte)0x2b, (byte)0xd3,
+            (byte)0x97, (byte)0x1a, (byte)0x6f, (byte)0xae, (byte)0xeb, (byte)0xf5, (byte)0xf9,
+            (byte)0x02, (byte)0x41, (byte)0x00, (byte)0xd7, (byte)0x3e, (byte)0xed, (byte)0x70,
+            (byte)0xfe, (byte)0xee, (byte)0x0e, (byte)0x30, (byte)0x29, (byte)0xfa, (byte)0xd7,
+            (byte)0x38, (byte)0xcf, (byte)0x8e, (byte)0xc1, (byte)0x9c, (byte)0x78, (byte)0x06,
+            (byte)0x2d, (byte)0xda, (byte)0x33, (byte)0x58, (byte)0xa1, (byte)0x7b, (byte)0xbf,
+            (byte)0x00, (byte)0xb9, (byte)0xdf, (byte)0xea, (byte)0x65, (byte)0x86, (byte)0xbb,
+            (byte)0xcc, (byte)0x83, (byte)0xce, (byte)0xde, (byte)0xc3, (byte)0xf8, (byte)0x89,
+            (byte)0xf5, (byte)0x9f, (byte)0xa6, (byte)0x1d, (byte)0xc9, (byte)0xfb, (byte)0x98,
+            (byte)0xa1, (byte)0x2e, (byte)0xe0, (byte)0x57, (byte)0x6e, (byte)0xbd, (byte)0x57,
+            (byte)0x20, (byte)0xf9, (byte)0x6b, (byte)0x13, (byte)0x42, (byte)0x9d, (byte)0x8d,
+            (byte)0x66, (byte)0x4d, (byte)0x7a, (byte)0x2d, (byte)0x02, (byte)0x41, (byte)0x00,
+            (byte)0xd7, (byte)0x00, (byte)0x18, (byte)0x54, (byte)0xe8, (byte)0x37, (byte)0xdb,
+            (byte)0xf8, (byte)0x98, (byte)0x7b, (byte)0x18, (byte)0x33, (byte)0xf6, (byte)0x28,
+            (byte)0xa8, (byte)0x8c, (byte)0xd9, (byte)0xfd, (byte)0x4c, (byte)0x4e, (byte)0x41,
+            (byte)0x73, (byte)0x2e, (byte)0x79, (byte)0x31, (byte)0xcc, (byte)0x7d, (byte)0x42,
+            (byte)0xb7, (byte)0xa1, (byte)0xd2, (byte)0xbc, (byte)0x1f, (byte)0x62, (byte)0xcf,
+            (byte)0x15, (byte)0x7c, (byte)0x62, (byte)0x97, (byte)0x70, (byte)0xf1, (byte)0x15,
+            (byte)0xf1, (byte)0x33, (byte)0xa1, (byte)0x9d, (byte)0xbb, (byte)0x5f, (byte)0xd7,
+            (byte)0x5a, (byte)0xf9, (byte)0x24, (byte)0x58, (byte)0xac, (byte)0x86, (byte)0x6a,
+            (byte)0xed, (byte)0xd4, (byte)0x84, (byte)0xe4, (byte)0x3f, (byte)0xfe, (byte)0xb0,
+            (byte)0xd3, (byte)0x02, (byte)0x41, (byte)0x00, (byte)0xd4, (byte)0xb7, (byte)0x84,
+            (byte)0xb2, (byte)0x39, (byte)0xce, (byte)0x0b, (byte)0x49, (byte)0x80, (byte)0x03,
+            (byte)0x3c, (byte)0xb5, (byte)0x11, (byte)0x32, (byte)0x34, (byte)0x96, (byte)0xac,
+            (byte)0x6a, (byte)0xf6, (byte)0xdf, (byte)0x80, (byte)0x04, (byte)0xe4, (byte)0x39,
+            (byte)0xc6, (byte)0x0e, (byte)0x32, (byte)0xa3, (byte)0x5e, (byte)0x23, (byte)0x0d,
+            (byte)0x9f, (byte)0x04, (byte)0xc3, (byte)0x72, (byte)0x2a, (byte)0xe6, (byte)0xa2,
+            (byte)0xf5, (byte)0xbc, (byte)0x3f, (byte)0x15, (byte)0x4c, (byte)0xb5, (byte)0x33,
+            (byte)0x26, (byte)0xa8, (byte)0x8c, (byte)0x09, (byte)0xfb, (byte)0x7e, (byte)0x1e,
+            (byte)0x32, (byte)0x40, (byte)0x0d, (byte)0x1d, (byte)0xcb, (byte)0x7f, (byte)0xf6,
+            (byte)0xf2, (byte)0x29, (byte)0x9b, (byte)0x01, (byte)0xd5, (byte)0x02, (byte)0x40,
+            (byte)0x24, (byte)0x26, (byte)0x1c, (byte)0xf1, (byte)0x31, (byte)0xb6, (byte)0x2a,
+            (byte)0xa3, (byte)0x0a, (byte)0xa8, (byte)0x2f, (byte)0xb2, (byte)0x94, (byte)0xe1,
+            (byte)0xd3, (byte)0x2d, (byte)0x13, (byte)0x7d, (byte)0xd6, (byte)0x35, (byte)0x96,
+            (byte)0x25, (byte)0x92, (byte)0x9b, (byte)0xc7, (byte)0xf6, (byte)0xb4, (byte)0xdc,
+            (byte)0xe1, (byte)0xd9, (byte)0x30, (byte)0x80, (byte)0x76, (byte)0xda, (byte)0x7b,
+            (byte)0x2d, (byte)0x06, (byte)0xa3, (byte)0xe1, (byte)0x08, (byte)0x99, (byte)0x50,
+            (byte)0x72, (byte)0x24, (byte)0x97, (byte)0x38, (byte)0xd9, (byte)0x07, (byte)0x4d,
+            (byte)0x43, (byte)0x3b, (byte)0x7e, (byte)0x93, (byte)0xf6, (byte)0x36, (byte)0x07,
+            (byte)0x86, (byte)0x83, (byte)0x63, (byte)0xf0, (byte)0xa8, (byte)0x9d, (byte)0xdf,
+            (byte)0x07, (byte)0x02, (byte)0x40, (byte)0x3e, (byte)0x58, (byte)0x03, (byte)0xbf,
+            (byte)0xea, (byte)0x3e, (byte)0x34, (byte)0x2c, (byte)0xb7, (byte)0xc3, (byte)0x09,
+            (byte)0xe9, (byte)0xf4, (byte)0x43, (byte)0x41, (byte)0xc4, (byte)0x7c, (byte)0x6e,
+            (byte)0x75, (byte)0x72, (byte)0x5d, (byte)0xfc, (byte)0xa3, (byte)0x75, (byte)0x1d,
+            (byte)0xa0, (byte)0xee, (byte)0xc2, (byte)0x1f, (byte)0x71, (byte)0xb0, (byte)0xf3,
+            (byte)0x1d, (byte)0xec, (byte)0x81, (byte)0xdb, (byte)0x45, (byte)0xe5, (byte)0x6a,
+            (byte)0xe8, (byte)0xe0, (byte)0x64, (byte)0x90, (byte)0xff, (byte)0xb9, (byte)0xf8,
+            (byte)0x12, (byte)0xed, (byte)0x55, (byte)0x5c, (byte)0x9b, (byte)0x81, (byte)0xcd,
+            (byte)0xbb, (byte)0x06, (byte)0x91, (byte)0xfe, (byte)0x27, (byte)0x2c, (byte)0x3a,
+            (byte)0xed, (byte)0x96, (byte)0x3b, (byte)0xfe
+    };
+    
+    /*
     String key3 = "-----BEGIN RSA PRIVATE KEY-----\n"
         + "Proc-Type: 4,ENCRYPTED\n"
         + "DEK-Info: DES-EDE3-CBC,0EE6B33EC2D92297\n"
@@ -304,6 +589,7 @@ public class X509KeyManagerTest extends TestCase {
         + "-----END RSA PRIVATE KEY-----";
 
     ByteArrayInputStream keyArray3 = new ByteArrayInputStream(key3.getBytes());
+    */
 
     @Override
     protected void setUp() {
@@ -321,24 +607,28 @@ public class X509KeyManagerTest extends TestCase {
           CertificateFactory cf = CertificateFactory.getInstance("X.509");
           KeyFactory kf = KeyFactory.getInstance("RSA");
           keyTest = KeyStore.getInstance(KeyStore.getDefaultType());
-          keyTest.load(null, null);
+          keyTest.load(null, "1234".toCharArray());
           if (keyType.equals(client)) {
               keys = new PrivateKey[3];
-              keys[0] = kf.generatePrivate(new X509EncodedKeySpec(key.getBytes()));
-              keys[1] = kf.generatePrivate(new X509EncodedKeySpec(key2.getBytes()));
-              keys[2] = kf.generatePrivate(new X509EncodedKeySpec(key3.getBytes()));
+              keys[0] = kf.generatePrivate(new PKCS8EncodedKeySpec(keyBytes));
+              keys[1] = kf.generatePrivate(new PKCS8EncodedKeySpec(key2Bytes));
+              keys[2] = kf.generatePrivate(new PKCS8EncodedKeySpec(key3Bytes));
               cert = new X509Certificate[3];
               cert[0] = (X509Certificate) cf.generateCertificate(certArray);
               cert[1] = (X509Certificate) cf.generateCertificate(certArray2);
               cert[2] = (X509Certificate) cf.generateCertificate(certArray3);
-              keyTest.setKeyEntry("clientKey_01", keys[1], password.toCharArray(), new X509Certificate[] {cert[0], cert[1]});
-              keyTest.setKeyEntry("clientKey_02", keys[2], password.toCharArray(), new X509Certificate[] {cert[0], cert[2]});
+              keyTest.setKeyEntry("clientKey_01", keys[0], password.toCharArray(), new X509Certificate[] {cert[0]});
+              keyTest.setKeyEntry("clientKey_02", keys[1], password.toCharArray(), new X509Certificate[] {cert[0], cert[1]});
+              keyTest.setKeyEntry("clientKey_03", keys[2], password.toCharArray(), new X509Certificate[] {cert[0], cert[2]});
               keyTest.setCertificateEntry("clientAlias_01", cert[0]);
               keyTest.setCertificateEntry("clientAlias_02", cert[0]);
               keyTest.setCertificateEntry("clientAlias_03", cert[1]);
           } else if (keyType.equals(server)) {
+              keys = new PrivateKey[1];
+              keys[0] = kf.generatePrivate(new PKCS8EncodedKeySpec(keyBytes));
               cert = new X509Certificate[1];
               cert[0] = (X509Certificate) cf.generateCertificate(certArray3);
+              keyTest.setKeyEntry("serverKey_00", keys[0], password.toCharArray(), new X509Certificate[] {cert[0]});
               keyTest.setCertificateEntry("serverAlias_00", cert[0]);
           }
       } catch (Exception ex) {
@@ -346,7 +636,7 @@ public class X509KeyManagerTest extends TestCase {
           throw new IllegalArgumentException(ex.getMessage());
       }
       try {
-        factory.init(keyTest, null);
+        factory.init(keyTest, "1234".toCharArray());
       } catch (Exception e) {
         fail("Could't init the KeyManagerFactory");
       }
@@ -362,7 +652,6 @@ public class X509KeyManagerTest extends TestCase {
         method = "getClientAliases",
         args = {java.lang.String.class, java.security.Principal[].class}
     )
-    @BrokenTest("Test needs to add PrivateKeys to the Store to work properly.")
     public void test_getClientAliases() {
         init(client);
         assertNull(manager.getClientAliases(null, null));
@@ -381,16 +670,15 @@ public class X509KeyManagerTest extends TestCase {
         method = "chooseClientAlias",
         args = {java.lang.String[].class, java.security.Principal[].class, java.net.Socket.class}
     )
-    @BrokenTest("Test needs to add PrivateKeys to the Store to work properly.")
     public void test_chooseClientAlias() {
         String[] ar = {client};
         init(client);
         assertNull(manager.chooseClientAlias(null, null, new Socket()));
         assertNull(manager.chooseClientAlias(new String[0], null, new Socket()));
-        String res = manager.chooseClientAlias(ar, null, new Socket());
-        assertEquals("clientalias_03", res);
-        res = manager.chooseClientAlias(ar, null, null);
-        assertEquals("clientalias_02", res);
+        assertNull(manager.chooseClientAlias(ar, null, new Socket()));
+        String res = manager.chooseClientAlias(new String[]{type}, null, null);
+        assertNotNull(res);
+        assertEquals("clientkey_03", res.toLowerCase().toLowerCase());
     }
     
     /**
@@ -402,7 +690,6 @@ public class X509KeyManagerTest extends TestCase {
         method = "getServerAliases",
         args = {java.lang.String.class, java.security.Principal[].class}
     )
-    @BrokenTest("Test needs to add PrivateKeys to the Store to work properly.")
     public void test_getServerAliases() {
         init(server);
         assertNull(manager.getServerAliases(null, null));
@@ -410,7 +697,7 @@ public class X509KeyManagerTest extends TestCase {
         String[] resArray = manager.getServerAliases(type, null);
         assertNotNull(resArray);
         assertEquals("Incorrect length", 1, resArray.length);
-        assertEquals("Incorrect aliase", "serveralias_00", resArray[0]);
+        assertEquals("Incorrect aliase", "serverkey_00", resArray[0].toLowerCase());
     }
     
     /**
@@ -422,14 +709,16 @@ public class X509KeyManagerTest extends TestCase {
         method = "chooseServerAlias",
         args = {java.lang.String.class, java.security.Principal[].class, java.net.Socket.class}
     )
-    @BrokenTest("Test needs to add PrivateKeys to the Store to work properly.")
     public void test_chooseServerAlias() {
         init(server);
         assertNull(manager.chooseServerAlias(null, null, new Socket()));
         assertNull(manager.chooseServerAlias("", null, new Socket()));
-        assertNull(manager.chooseServerAlias(type, null, null));
-        String res = manager.chooseServerAlias(type, null, new Socket());
-        assertEquals("serveralias_00", res);
+        String res = manager.chooseServerAlias(type, null, null);
+        assertNotNull(res);
+        assertEquals("serverkey_00", res.toLowerCase());
+        res = manager.chooseServerAlias(type, null, new Socket());
+        assertNotNull(res);
+        assertEquals("serverkey_00", res.toLowerCase());
     }
    
     /**
@@ -441,7 +730,6 @@ public class X509KeyManagerTest extends TestCase {
         method = "getCertificateChain",
         args = {java.lang.String.class}
     )
-    @BrokenTest("Test needs to add PrivateKeys to the Store to work properly.")
     public void test_getCertificateChain() {
         init(server);
         assertNull("Not NULL for NULL parameter", manager.getCertificateChain(null));
@@ -459,7 +747,6 @@ public class X509KeyManagerTest extends TestCase {
         method = "getPrivateKey",
         args = {java.lang.String.class}
     )
-    @BrokenTest("Test needs to add PrivateKeys to the Store to work properly.")
     public void test_getPrivateKey() {
         init(client);
         assertNull("Not NULL for NULL parameter", manager.getPrivateKey(null));
@@ -473,7 +760,7 @@ public class X509KeyManagerTest extends TestCase {
             return false;
         }
         for (int i = 0; i < ar.length; i++) {
-            if (!ar[i].equals("clientalias_01") && !ar[i].equals("clientalias_02") && !ar[i].equals("clientalias_03")) {
+            if (!ar[i].toLowerCase().equals("clientkey_01") && !ar[i].toLowerCase().equals("clientkey_02") && !ar[i].toLowerCase().equals("clientkey_03")) {
                 return false;
             }
         }