harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r727976 - in /harmony/enhanced/classlib/branches/java6/modules: jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ext/ x-net/src/main/java/javax/net/ssl/ x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/
Date Fri, 19 Dec 2008 08:35:31 GMT
Author: tonywu
Date: Fri Dec 19 00:35:30 2008
New Revision: 727976

URL: http://svn.apache.org/viewvc?rev=727976&view=rev
Log:
bring missing features back when merging from trunk to Java6

Modified:
    harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImplTest.java
    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/SSLEngineImpl.java
    harmony/enhanced/classlib/branches/java6/modules/x-net/src/main/java/org/apache/harmony/xnet/provider/jsse/SSLSocketImpl.java

Modified: harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImplTest.java?rev=727976&r1=727975&r2=727976&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImplTest.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/jndi/src/test/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImplTest.java
Fri Dec 19 00:35:30 2008
@@ -288,5 +288,16 @@
         public void setWantClientAuth(boolean want) {
             throw new Error("should not be here");
         }
+
+        @Override
+        public SSLParameters getSSLParameters() {
+            throw new Error("should not be here");
+        }
+
+        @Override
+        public void setSSLParameters(SSLParameters params) {
+            throw new Error("should not be here");
+        }
     }
+
 }

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=727976&r1=727975&r2=727976&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
Fri Dec 19 00:35:30 2008
@@ -35,6 +35,27 @@
     // Used to access common engine functionality
     private static Engine engine = new Engine(SERVICE);
 
+    // Storeused provider
+    private final Provider provider;
+
+    private static SSLContext defaultSSLContext;
+    // Storeused SSLContextSpi implementation
+    private final SSLContextSpi spiImpl;
+
+    // Storeused protocol
+    private final String protocol;
+
+    /*
+     * @com.intel.drl.spec_ref
+     *  
+     */
+    protected SSLContext(SSLContextSpi contextSpi, Provider provider,
+            String protocol) {
+        this.provider = provider;
+        this.protocol = protocol;
+        this.spiImpl = contextSpi;
+    }
+
     /**
      * 
      * @throws NullPointerException if protocol is null (instead of NoSuchAlgorithmException
as in
@@ -88,18 +109,6 @@
         }
     }
 
-    private final Provider provider;
-
-    private final SSLContextSpi spiImpl;
-
-    private final String protocol;
-
-    protected SSLContext(SSLContextSpi contextSpi, Provider provider, String protocol) {
-        this.provider = provider;
-        this.protocol = protocol;
-        this.spiImpl = contextSpi;
-    }
-
     public final String getProtocol() {
         return protocol;
     }
@@ -136,4 +145,28 @@
     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;
+    }
+}
\ No newline at end of file

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=727976&r1=727975&r2=727976&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
Fri Dec 19 00:35:30 2008
@@ -17,9 +17,12 @@
 
 package javax.net.ssl;
 
+import java.io.IOException;
 import java.security.KeyManagementException;
 import java.security.SecureRandom;
 
+import javax.net.SocketFactory;
+
 public abstract class SSLContextSpi {
     public SSLContextSpi() {
         super();
@@ -40,4 +43,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=727976&r1=727975&r2=727976&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
Fri Dec 19 00:35:30 2008
@@ -100,7 +100,11 @@
     public abstract void setUseClientMode(boolean mode);
 
     public abstract void setWantClientAuth(boolean want);
+    
+    public abstract void setSSLParameters(SSLParameters sslP);
 
+    public abstract SSLParameters getSSLParameters();
+    
     public abstract SSLEngineResult unwrap(ByteBuffer src, ByteBuffer[] dsts, int offset,
int length)
             throws SSLException;
 

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=727976&r1=727975&r2=727976&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
Fri Dec 19 00:35:30 2008
@@ -82,4 +82,7 @@
     
 	public abstract boolean getEnableSessionCreation();
 
+    public abstract void setSSLParameters(SSLParameters inputSSLParameters);
+    
+    public abstract SSLParameters getSSLParameters();
 }

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=727976&r1=727975&r2=727976&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
Fri Dec 19 00:35:30 2008
@@ -92,6 +92,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
@@ -765,5 +773,16 @@
             ? 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=727976&r1=727975&r2=727976&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
Fri Dec 19 00:35:30 2008
@@ -844,5 +844,24 @@
         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;
+    }
 }
 



Mime
View raw message