harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r583670 - in /harmony/enhanced/classlib/branches/java6/modules/x-net/src: main/java/javax/net/ssl/ main/java/org/apache/harmony/xnet/provider/jsse/ test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/ test/java/javax/net/ssl/ test/sup...
Date Thu, 11 Oct 2007 02:25:16 GMT
Author: leoli
Date: Wed Oct 10 19:25:15 2007
New Revision: 583670

URL: http://svn.apache.org/viewvc?rev=583670&view=rev
Log:
Apply patch for ([java6][classlib][x-net]New Features about SSLParameters).

Added:
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLParameters.java
  (with props)
Modified:
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLContext.java
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLContextSpi.java
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLEngine.java
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLSocket.java
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLContextImpl.java
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLEngineImpl.java
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext1Test.java
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSocketTest.java
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/java/javax/net/ssl/MySSLContextSpi.java
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MySSLContextSpi.java

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLContext.java?rev=583670&r1=583669&r2=583670&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLContext.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLContext.java
Wed Oct 10 19:25:15 2007
@@ -22,9 +22,11 @@
 
 package javax.net.ssl;
 
+import java.security.AccessController;
 import java.security.KeyManagementException;
 import java.security.NoSuchAlgorithmException;
 import java.security.NoSuchProviderException;
+import java.security.Permission;
 import java.security.Provider;
 import java.security.SecureRandom;
 import java.security.Security;
@@ -47,6 +49,7 @@
     // Storeused provider
     private final Provider provider;
 
+    private static SSLContext defaultSSLContext;
     // Storeused SSLContextSpi implementation
     private final SSLContextSpi spiImpl;
 
@@ -195,5 +198,29 @@
      */
     public final SSLSessionContext getClientSessionContext() {
         return spiImpl.engineGetClientSessionContext();
+    }
+
+    public final SSLParameters getDefaultSSLParameters() {
+        return spiImpl.engineGetDefaultSSLParameters();
+    }
+
+    public final SSLParameters getSupportedSSLParameters() {
+        return spiImpl.engineGetSupportedSSLParameters();
+    }
+
+    public static SSLContext getDefault() throws NoSuchAlgorithmException {
+        if (defaultSSLContext == null)
+            defaultSSLContext = SSLContext.getInstance("Default");
+        return defaultSSLContext;
+    }
+
+    public static void setDefault(SSLContext sslContext) {
+        if (sslContext == null)
+            throw new NullPointerException();
+        SecurityManager securityManager = System.getSecurityManager();
+        if (securityManager != null)
+            securityManager.checkPermission(new SSLPermission(
+                    "setDefaultSSLContext"));
+        defaultSSLContext = sslContext;
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLContextSpi.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLContextSpi.java?rev=583670&r1=583669&r2=583670&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLContextSpi.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLContextSpi.java
Wed Oct 10 19:25:15 2007
@@ -22,9 +22,12 @@
 
 package javax.net.ssl;
 
+import java.io.IOException;
 import java.security.KeyManagementException;
 import java.security.SecureRandom;
 
+import javax.net.SocketFactory;
+
 /**
  * @com.intel.drl.spec_ref
  * 
@@ -81,4 +84,62 @@
      */
     protected abstract SSLSessionContext engineGetClientSessionContext();
 
+    protected SSLParameters engineGetDefaultSSLParameters() {
+        // Initially, a default set of cipher suites will be enabled on a new
+        // socket that represents the minimum suggested configuration
+        SSLParameters defaultSSLParameters = new SSLParameters();
+        SocketFactory sslSocketFactory = SSLSocketFactory.getDefault();
+        SSLSocket sslSocket = null;
+        try {
+            sslSocket = (SSLSocket) sslSocketFactory.createSocket();
+            if (sslSocket == null)
+                return null;
+            defaultSSLParameters.setCipherSuites(sslSocket
+                    .getEnabledCipherSuites());
+            defaultSSLParameters.setProtocols(sslSocket.getEnabledProtocols());
+        } catch (IOException e1) {
+            e1.printStackTrace();
+            throw new UnsupportedOperationException(
+                    "the default SSL parameters could not be obtained");
+        } finally {
+            try {
+                if (sslSocket != null) {
+                    sslSocket.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return defaultSSLParameters;
+    };
+
+    protected SSLParameters engineGetSupportedSSLParameters() {
+        SSLParameters supportSSLParameters = new SSLParameters();
+        SocketFactory sslSocketFactory = SSLSocketFactory.getDefault();
+        if (sslSocketFactory == null)
+            return null;
+        SSLSocket sslSocket = null;
+        try {
+            sslSocket = (SSLSocket) sslSocketFactory.createSocket();
+            if (sslSocket == null)
+                return null;
+            supportSSLParameters.setCipherSuites(sslSocket
+                    .getSupportedCipherSuites());
+            supportSSLParameters
+                    .setProtocols(sslSocket.getSupportedProtocols());
+        } catch (IOException e1) {
+            e1.printStackTrace();
+            throw new UnsupportedOperationException(
+                    "the supported SSL parameters could not be obtained");
+        } finally {
+            try {
+                if (sslSocket != null) {
+                    sslSocket.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+        return supportSSLParameters;
+    };
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLEngine.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLEngine.java?rev=583670&r1=583669&r2=583670&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLEngine.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLEngine.java
Wed Oct 10 19:25:15 2007
@@ -204,6 +204,10 @@
      */
     public abstract void setWantClientAuth(boolean want);
 
+    public abstract void setSSLParameters(SSLParameters sslP);
+
+    public abstract SSLParameters getSSLParameters();
+
     /**
      * @com.intel.drl.spec_ref
      *  

Added: harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLParameters.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLParameters.java?rev=583670&view=auto
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLParameters.java
(added)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLParameters.java
Wed Oct 10 19:25:15 2007
@@ -0,0 +1,67 @@
+package javax.net.ssl;
+
+public class SSLParameters {
+
+    protected String[] enabledCipherSuites;
+
+    private String[] enabledProtocols;
+
+    private boolean need_client_auth;
+
+    private boolean want_client_auth;
+
+    public SSLParameters() {
+        enabledCipherSuites = null;
+        enabledProtocols = null;
+        need_client_auth = false;
+        want_client_auth = false;
+    };
+
+    public SSLParameters(String[] cipherSuites) {
+        this.enabledCipherSuites = cipherSuites;
+    }
+
+    public SSLParameters(String[] cipherSuites, String[] protocols) {
+        // input maybe is null
+        this.enabledCipherSuites = cipherSuites;
+        this.enabledCipherSuites = protocols;
+    }
+
+    public String[] getCipherSuites() {
+        if (enabledCipherSuites == null)
+            return null;
+        return this.enabledCipherSuites.clone();
+    }
+
+    public boolean getNeedClientAuth() {
+        return this.need_client_auth;
+    }
+
+    public String[] getProtocols() {
+        if (enabledProtocols == null)
+            return null;
+        else
+            return enabledProtocols.clone();
+    }
+
+    public boolean getWantClientAuth() {
+        return this.want_client_auth;
+    }
+
+    public void setCipherSuites(String[] cipherSuites) {
+        this.enabledCipherSuites = cipherSuites.clone();
+    }
+
+    public void setNeedClientAuth(boolean needClientAuth) {
+        this.need_client_auth = needClientAuth;
+    }
+
+    public void setProtocols(String[] protocols) {
+
+        this.enabledProtocols = protocols.clone();
+    }
+
+    public void setWantClientAuth(boolean wantClientAuth) {
+        this.want_client_auth = wantClientAuth;
+    }
+}

Propchange: harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLParameters.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLSocket.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLSocket.java?rev=583670&r1=583669&r2=583670&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLSocket.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/javax/net/ssl/SSLSocket.java
Wed Oct 10 19:25:15 2007
@@ -72,6 +72,10 @@
     public abstract void setWantClientAuth(boolean want);
     public abstract boolean getWantClientAuth();
     public abstract void setEnableSessionCreation(boolean flag);
+
+    public abstract void setSSLParameters(SSLParameters inputSSLParameters);
+    public abstract SSLParameters getSSLParameters();
+
     public abstract boolean getEnableSessionCreation();
     
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLContextImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLContextImpl.java?rev=583670&r1=583669&r2=583670&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLContextImpl.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLContextImpl.java
Wed Oct 10 19:25:15 2007
@@ -100,5 +100,36 @@
     public SSLSessionContext engineGetClientSessionContext() {
         return clientSessionContext;
     }
-}
 
+    @Override
+    protected javax.net.ssl.SSLParameters engineGetDefaultSSLParameters() {
+        SSLParameters providerSSLParameters = null;
+        try {
+            providerSSLParameters = SSLParameters.getDefault();
+        } catch (KeyManagementException e) {
+            
+        }
+        if (providerSSLParameters == null)
+            return null;
+
+        javax.net.ssl.SSLParameters sslParameters = new javax.net.ssl.SSLParameters();
+        sslParameters.setCipherSuites(providerSSLParameters
+                .getEnabledCipherSuites());
+        sslParameters.setProtocols(providerSSLParameters.getEnabledProtocols());
+        sslParameters.setNeedClientAuth(sslParameters.getNeedClientAuth());
+        sslParameters.setWantClientAuth(providerSSLParameters
+                .getWantClientAuth());
+        return sslParameters;
+    }
+
+    @Override
+    protected javax.net.ssl.SSLParameters engineGetSupportedSSLParameters() {
+        javax.net.ssl.SSLParameters sslParameters = new javax.net.ssl.SSLParameters();
+        sslParameters.setCipherSuites(CipherSuite
+                .getSupportedCipherSuiteNames());
+        sslParameters
+                .setProtocols((String[]) ProtocolVersion.supportedProtocols
+                        .clone());
+        return sslParameters;
+    }
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLEngineImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLEngineImpl.java?rev=583670&r1=583669&r2=583670&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLEngineImpl.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLEngineImpl.java
Wed Oct 10 19:25:15 2007
@@ -97,6 +97,14 @@
         this.sslParameters = sslParameters;
     }
 
+    @Override
+    public void setSSLParameters(javax.net.ssl.SSLParameters inputSSLParameters) {
+        setEnabledCipherSuites(inputSSLParameters.getCipherSuites());
+        setEnabledProtocols(inputSSLParameters.getProtocols());
+        setNeedClientAuth(inputSSLParameters.getNeedClientAuth());
+        setWantClientAuth(inputSSLParameters.getWantClientAuth());
+    }
+
     /**
      * Ctor
      * @param   host:   String
@@ -747,5 +755,15 @@
             ? SSLEngineResult.Status.CLOSED
             : SSLEngineResult.Status.OK;
     }
-}
 
+
+    @Override
+    public javax.net.ssl.SSLParameters getSSLParameters() {
+        javax.net.ssl.SSLParameters outputSSLParameters = new javax.net.ssl.SSLParameters();
+        outputSSLParameters.setCipherSuites(sslParameters.getEnabledCipherSuites());
+        outputSSLParameters.setProtocols(sslParameters.getEnabledProtocols());
+        outputSSLParameters.setNeedClientAuth(sslParameters.getNeedClientAuth());
+        outputSSLParameters.setWantClientAuth(sslParameters.getWantClientAuth());
+        return outputSSLParameters;
+    }
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java?rev=583670&r1=583669&r2=583670&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java
Wed Oct 10 19:25:15 2007
@@ -821,5 +821,23 @@
         shutdown();
         throw reason;
     }
-}
 
+
+    @Override
+    public void setSSLParameters(javax.net.ssl.SSLParameters inputSSLParameters) {
+        setEnabledCipherSuites(inputSSLParameters.getCipherSuites());
+        setNeedClientAuth(inputSSLParameters.getNeedClientAuth());
+        setWantClientAuth(inputSSLParameters.getWantClientAuth());
+        setEnabledProtocols(inputSSLParameters.getProtocols());
+    }
+
+    @Override
+    public javax.net.ssl.SSLParameters getSSLParameters() {
+        javax.net.ssl.SSLParameters outputSSLParameters = new javax.net.ssl.SSLParameters();
+        outputSSLParameters.setCipherSuites(sslParameters.getEnabledCipherSuites());
+        outputSSLParameters.setProtocols(sslParameters.getEnabledProtocols());
+        outputSSLParameters.setNeedClientAuth(sslParameters.getNeedClientAuth());
+        outputSSLParameters.setWantClientAuth(sslParameters.getWantClientAuth());
+        return outputSSLParameters;
+    }
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext1Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext1Test.java?rev=583670&r1=583669&r2=583670&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext1Test.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLContext1Test.java
Wed Oct 10 19:25:15 2007
@@ -24,6 +24,7 @@
 import java.security.NoSuchProviderException;
 import java.security.Provider;
 import java.security.SecureRandom;
+import java.security.Security;
 import java.security.UnrecoverableKeyException;
 
 import javax.net.ssl.KeyManager;
@@ -31,12 +32,16 @@
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLContextSpi;
 import javax.net.ssl.SSLEngine;
+import javax.net.ssl.SSLParameters;
+import javax.net.ssl.SSLPermission;
 import javax.net.ssl.SSLSessionContext;
 import javax.net.ssl.SSLServerSocketFactory;
 import javax.net.ssl.SSLSocketFactory;
+import javax.net.ssl.SSLSocket;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.TrustManagerFactory;
 
+import org.apache.harmony.security.fortress.Services;
 import org.apache.harmony.security.tests.support.SpiEngUtils;
 import org.apache.harmony.xnet.tests.support.MySSLContextSpi;
 import junit.framework.TestCase;
@@ -77,6 +82,14 @@
         } else {
             defaultProtocol = null;
         }
+        
+        SSLParameters staticSupportSSLParameter = new SSLParameters(new String[] {
+                "TLS_RSA_WITH_RC4_128_MD5", "TLS_RSA_WITH_RC4_128_SHA" },
+                new String[] { "TLSv1", "SSLv3" });
+        
+        SSLParameters staticDefaultSSLParameter = new SSLParameters(new String[] {
+                "TLS_RSA_WITH_RC4_128_MD5", "TLS_RSA_WITH_RC4_128_SHA" },
+                new String[] { "TLSv1", "SSLv3" });
     }
 
     protected SSLContext[] createSSLCon() {
@@ -372,7 +385,7 @@
             return;
         }
         SSLContextSpi spi = new MySSLContextSpi();
-        SSLContext sslContext = new mySSLContext(spi, defaultProvider,
+        SSLContext sslContext = new MySSLContext(spi, defaultProvider,
                 defaultProtocol);
         assertTrue("Not CertStore object", sslContext instanceof SSLContext);
         assertEquals("Incorrect protocol", sslContext.getProtocol(),
@@ -390,7 +403,7 @@
         } catch (KeyManagementException e) {
         }
 
-        sslContext = new mySSLContext(null, null, null);
+        sslContext = new MySSLContext(null, null, null);
         assertTrue("Not CertStore object", sslContext instanceof SSLContext);
         assertNull("Incorrect protocol", sslContext.getProtocol());
         assertNull("Incorrect provider", sslContext.getProvider());
@@ -405,15 +418,91 @@
         } catch (NullPointerException e) {
         }
     }
+    
+    public void testGetDefault() throws Exception {
+        //TODO: Need evaluation
+        class PrivateClassLoader extends ClassLoader {}
+        try {
+            // register my provider and its service.
+            Security.addProvider(new MyProvider());
+            // FIXME 
+            ClassLoader privateClassLoader = new PrivateClassLoader();
+            Class class1 = privateClassLoader
+                    .loadClass("org.apache.harmony.xnet.tests.javax.net.ssl.MySSLContext");
+            SSLContext sslContext = (SSLContext) class1.newInstance();      
+            System.out.println(SSLContext.getInstance("Default"));
+            assertTrue((sslContext.getDefault()) instanceof SSLContext);
+        } catch (NoSuchAlgorithmException e) {
+            // expected            
+        }
+    }    
+    
 
+
+    
+    
+    public void testGetDefaultSSLParameters() throws Exception {
+        SSLContext[] sslContexts = createSSLCon();
+        assertNotNull("SSLContext objects were not created", sslContexts);
+
+        for (int i = 0; i < sslContexts.length; i++) {
+            sslContexts[i].init(null, null, null);
+            SSLParameters defaultSSLParameters = sslContexts[i]
+                    .getDefaultSSLParameters();
+            SSLSocket sslSocket = (SSLSocket) (sslContexts[i]
+                    .getSocketFactory().createSocket());
+
+            String[] enabledCipherSuites = sslSocket.getEnabledCipherSuites();
+            String[] enabledProtocols = sslSocket.getEnabledProtocols();
+
+            for (int j = 0; j < enabledCipherSuites.length; j++)
+                assertEquals((defaultSSLParameters.getCipherSuites())[j],
+                        enabledCipherSuites[j]);
+            for (int k = 0; k < enabledProtocols.length; k++)
+                assertEquals((defaultSSLParameters.getProtocols())[k],
+                        enabledProtocols[k]);
+        }
+    }
+
+    public void testGetSupportedSSLParameters() throws Exception {
+        SSLContext[] sslContexts = createSSLCon();
+        assertNotNull("SSLContext objects were not created", sslContexts);
+
+        for (int i = 0; i < sslContexts.length; i++) {
+            sslContexts[i].init(null, null, null);
+            SSLParameters defaultSSLParameters = sslContexts[i]
+                    .getSupportedSSLParameters();
+            SSLSocket sslSocket = (SSLSocket) (sslContexts[i]
+                    .getSocketFactory().createSocket());
+            String[] supportedCipherSuites = sslSocket.getSupportedCipherSuites();
+            String[] supportedProtocols = sslSocket.getSupportedProtocols();
+
+            for (int j = 0; j < supportedCipherSuites.length; j++)
+                assertEquals((defaultSSLParameters.getCipherSuites())[j],
+                        supportedCipherSuites[j]);
+            for (int k = 0; k < supportedProtocols.length; k++)
+                assertEquals((defaultSSLParameters.getProtocols())[k],
+                        supportedProtocols[k]);
+        }
+    }
 }
 
 /**
  * Addifional class to verify SSLContext constructor
  */
-
-class mySSLContext extends SSLContext {
-    public mySSLContext(SSLContextSpi spi, Provider prov, String alg) {
+class MyProvider extends Provider {    
+    MyProvider() {
+        super("MyProviderForSSLContextTest", 1.0, "Provider for testing");
+        put("SSLContext.Default", "org.apache.harmony.xnet.tests.javax.net.ssl.MySSLContext");
+    }
+}
+    
+class MySSLContext extends SSLContext {
+    public MySSLContext(SSLContextSpi spi, Provider prov, String alg) {
         super(spi, prov, alg);
+    }
+    
+    public MySSLContext(){
+        super(null, null, null);
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java?rev=583670&r1=583669&r2=583670&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLEngineTest.java
Wed Oct 10 19:25:15 2007
@@ -22,6 +22,7 @@
 
 import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLParameters;
 import javax.net.ssl.SSLEngineResult.HandshakeStatus;
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLEngineResult;
@@ -471,6 +472,18 @@
             ByteBuffer dst) throws SSLException {
         return new SSLEngineResult(SSLEngineResult.Status.OK,
                 SSLEngineResult.HandshakeStatus.FINISHED, 10, 20);
+    }
+
+    @Override
+    public SSLParameters getSSLParameters() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void setSSLParameters(SSLParameters sslP) {
+        // TODO Auto-generated method stub
+
     }
 }
 

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSocketTest.java?rev=583670&r1=583669&r2=583670&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSocketTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/api/java/org/apache/harmony/xnet/tests/javax/net/ssl/SSLSocketTest.java
Wed Oct 10 19:25:15 2007
@@ -22,6 +22,7 @@
 import java.net.ServerSocket;
 import java.net.UnknownHostException;
 
+import javax.net.ssl.SSLParameters;
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLSocket;
 import javax.net.ssl.HandshakeCompletedListener;
@@ -202,5 +203,16 @@
     public boolean getEnableSessionCreation() {
         return false;
     }
-}
 
+    @Override
+    public SSLParameters getSSLParameters() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void setSSLParameters(SSLParameters sslP) {
+        // TODO Auto-generated method stub
+
+    }
+}

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/java/javax/net/ssl/MySSLContextSpi.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/java/javax/net/ssl/MySSLContextSpi.java?rev=583670&r1=583669&r2=583670&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/java/javax/net/ssl/MySSLContextSpi.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/java/javax/net/ssl/MySSLContextSpi.java
Wed Oct 10 19:25:15 2007
@@ -135,5 +135,17 @@
                 int length, ByteBuffer dst) throws SSLException { 
             return null;
         }
+
+        @Override
+        public SSLParameters getSSLParameters() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        @Override
+        public void setSSLParameters(SSLParameters sslP) {
+            // TODO Auto-generated method stub
+
+        }
     }
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MySSLContextSpi.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MySSLContextSpi.java?rev=583670&r1=583669&r2=583670&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MySSLContextSpi.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/x-net/src/test/support/common/java/org/apache/harmony/xnet/tests/support/MySSLContextSpi.java
Wed Oct 10 19:25:15 2007
@@ -26,6 +26,7 @@
 import javax.net.ssl.SSLEngine;
 import javax.net.ssl.SSLEngineResult;
 import javax.net.ssl.SSLException;
+import javax.net.ssl.SSLParameters;
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.SSLSessionContext;
 import javax.net.ssl.SSLServerSocketFactory;
@@ -141,5 +142,29 @@
                 int length, ByteBuffer dst) throws SSLException { 
             return null;
         }
+
+        @Override
+        public SSLParameters getSSLParameters() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        @Override
+        public void setSSLParameters(SSLParameters sslP) {
+            // TODO Auto-generated method stub
+
+        }
+    }    
+    
+    @Override
+    protected SSLParameters engineGetDefaultSSLParameters() {
+        return new SSLParameters(new String[] { "Default_SSL_Parameters_For_Test1" },
+                new String[] { "TLSv1" });
+    }
+
+    @Override
+    protected SSLParameters engineGetSupportedSSLParameters() {
+        return new SSLParameters(new String[] { "Default_SSL_Parameters_For_Test1",
+                "Default_SSL_Parameters_For_Test2" }, new String[] { "TLSv1", "SSLv3" });
     }
 }



Mime
View raw message