harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r470353 - in /incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl: SslRMIClientSocketFactory.java SslRMIServerSocketFactory.java
Date Thu, 02 Nov 2006 12:40:43 GMT
Author: mloenko
Date: Thu Nov  2 04:40:43 2006
New Revision: 470353

URL: http://svn.apache.org/viewvc?view=rev&rev=470353
Log:
applied patch for HARMONY-2043
[classlib][rmi] javax.rmi.ssl implementation

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl/SslRMIClientSocketFactory.java
  (with props)
    incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl/SslRMIServerSocketFactory.java
  (with props)

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl/SslRMIClientSocketFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl/SslRMIClientSocketFactory.java?view=auto&rev=470353
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl/SslRMIClientSocketFactory.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl/SslRMIClientSocketFactory.java
Thu Nov  2 04:40:43 2006
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.rmi.ssl;
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.Socket;
+import java.rmi.server.RMIClientSocketFactory;
+import java.security.AccessController;
+
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+public class SslRMIClientSocketFactory implements RMIClientSocketFactory,
+        Serializable {
+
+    private static final long serialVersionUID = -8310631444933958385L;
+
+    private static SSLSocketFactory factory;
+
+    private static String enabledCipherSuites;
+
+    private static String enabledProtocols;
+
+    private static boolean isEnabledInitialized;
+
+    public SslRMIClientSocketFactory() {
+        if (factory == null) {
+            factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
+        }
+    }
+
+    public Socket createSocket(String host, int port) throws IOException {
+
+        SSLSocket soc = (SSLSocket) factory.createSocket(host, port);
+        if (!isEnabledInitialized) {
+            isEnabledInitialized = true;
+            AccessController.doPrivileged(new java.security.PrivilegedAction() {
+
+                public Object run() {
+                    enabledCipherSuites = System
+                            .getProperty("javax.rmi.ssl.client.enabledCipherSuites");
+                    enabledProtocols = System
+                            .getProperty("javax.rmi.ssl.client.enabledProtocols");
+                    return null;
+                }
+            });
+        }
+        if (enabledCipherSuites != null) {
+            soc.setEnabledCipherSuites(enabledCipherSuites.split(","));
+        }
+
+        if (enabledProtocols != null) {
+            soc.setEnabledProtocols(enabledProtocols.split(","));
+        }
+
+        return soc;
+    }
+
+    public boolean equals(Object obj) {
+        return this.getClass().equals(obj.getClass());
+    }
+
+    public int hashCode() {
+        return "javax.rmi.ssl.SslRMIClientSocketFactory".hashCode();
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl/SslRMIClientSocketFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl/SslRMIServerSocketFactory.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl/SslRMIServerSocketFactory.java?view=auto&rev=470353
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl/SslRMIServerSocketFactory.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl/SslRMIServerSocketFactory.java
Thu Nov  2 04:40:43 2006
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package javax.rmi.ssl;
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.rmi.server.RMIServerSocketFactory;
+import java.util.Arrays;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+
+public class SslRMIServerSocketFactory implements RMIServerSocketFactory {
+
+    static SSLServerSocketFactory factory;
+
+    private String[] enabledCipherSuites;
+
+    private String[] enabledProtocols;
+
+    private boolean needClientAuth;
+
+    public SslRMIServerSocketFactory() {
+
+        if (factory == null) {
+            factory = (SSLServerSocketFactory) SSLServerSocketFactory
+                    .getDefault();
+        }
+    }
+
+    public SslRMIServerSocketFactory(String[] enabledCipherSuites,
+            String[] enabledProtocols, boolean needClientAuth)
+            throws IllegalArgumentException {
+
+        if (factory == null) {
+            factory = (SSLServerSocketFactory) SSLServerSocketFactory
+                    .getDefault();
+        }
+        SSLServerSocket soc = null;
+        try {
+            soc = (SSLServerSocket) factory.createServerSocket();
+            if (enabledProtocols != null) {
+                soc.setEnabledProtocols(enabledProtocols);
+            }
+            if (enabledCipherSuites != null) {
+                soc.setEnabledCipherSuites(enabledCipherSuites);
+            }
+            this.enabledCipherSuites = enabledCipherSuites;
+            this.enabledProtocols = enabledProtocols;
+            this.needClientAuth = needClientAuth;
+        } catch (IOException e) {
+            throw new IllegalArgumentException(e);
+        } finally {
+            try {
+                soc.close();
+            } catch (IOException e) {}
+        }
+
+    }
+
+    public final String[] getEnabledCipherSuites() {
+        return enabledCipherSuites;
+    }
+
+    public final String[] getEnabledProtocols() {
+        return enabledProtocols;
+    }
+
+    public final boolean getNeedClientAuth() {
+        return needClientAuth;
+    }
+
+    public ServerSocket createServerSocket(int port) throws IOException {
+        SSLServerSocket soc;
+
+        soc = (SSLServerSocket) factory.createServerSocket();
+        if (enabledProtocols != null) {
+            soc.setEnabledProtocols(enabledProtocols);
+        }
+        if (enabledCipherSuites != null) {
+            soc.setEnabledCipherSuites(enabledCipherSuites);
+        }
+        soc.setNeedClientAuth(needClientAuth);
+        return soc;
+    }
+
+    public boolean equals(Object obj) {
+
+        if (obj instanceof SslRMIServerSocketFactory
+                || Arrays.equals(enabledCipherSuites,
+                        ((SslRMIServerSocketFactory) obj)
+                                .getEnabledCipherSuites())
+                || Arrays
+                        .equals(enabledProtocols,
+                                ((SslRMIServerSocketFactory) obj)
+                                        .getEnabledProtocols())) {
+            return true;
+        }
+        return false;
+    }
+
+    public int hashCode() {
+
+        String hashSting = "javax.rmi.ssl.SslRMIServerSocketFactory";
+        if (enabledCipherSuites != null) {
+            for (int i = 0; i < enabledCipherSuites.length; i++) {
+                hashSting = hashSting + enabledCipherSuites[i];
+            }
+        }
+        if (enabledProtocols != null) {
+            for (int i = 0; i < enabledProtocols.length; i++) {
+                hashSting = hashSting + enabledProtocols[i];
+            }
+        }
+        return hashSting.hashCode();
+    }
+
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/rmi/src/main/java/javax/rmi/ssl/SslRMIServerSocketFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message