1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2006 by Sun Microsystems, Inc
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
34
* JGDISslRMIClientSocketFactory.java
36
* Created on May 26, 2006, 1:24 PM
39
package com.sun.grid.jgdi.management;
43
import java.io.IOException;
44
import java.net.Socket;
45
import java.util.StringTokenizer;
46
import javax.net.SocketFactory;
47
import javax.net.ssl.SSLSocket;
48
import javax.rmi.ssl.SslRMIClientSocketFactory;
53
* This client socket factory creates <code>SSLSocket</code>s for RMI.
55
* @see javax.rmi.ssl.SslRMIClientSocketFactory
57
public class JGDISslRMIClientSocketFactory extends SslRMIClientSocketFactory {
59
private final static long serialVersionUID = -2008021101L;
61
private final File caTop;
63
public JGDISslRMIClientSocketFactory(File caTop) {
68
* <p>Creates an SSL socket.</p>
70
* <p>If the system property
71
* <code>javax.rmi.ssl.client.enabledCipherSuites</code> is
72
* specified, this method will call {@link
73
* SSLSocket#setEnabledCipherSuites(String[])} before returning
74
* the socket. The value of this system property is a string that
75
* is a comma-separated list of SSL/TLS cipher suites to
78
* <p>If the system property
79
* <code>javax.rmi.ssl.client.enabledProtocols</code> is
80
* specified, this method will call {@link
81
* SSLSocket#setEnabledProtocols(String[])} before returning the
82
* socket. The value of this system property is a string that is a
83
* comma-separated list of SSL/TLS protocol versions to
86
* @param host the host
87
* @param port the port
88
* @return the created socket
89
* @throws java.io.IOException on any io error
92
public final Socket createSocket(final String host, final int port)
95
// Retrieve the SSLSocketFactory
97
final SocketFactory sslSocketFactory = SSLHelper.getInstanceByCaTop(caTop).getSocketFactory();
99
// Create the SSLSocket
101
final SSLSocket sslSocket =
102
(SSLSocket)sslSocketFactory.createSocket(host, port);
104
// Set the SSLSocket Enabled Cipher Suites
106
final String enabledCipherSuites =
107
java.lang.System.getProperty("javax.rmi.ssl.client.enabledCipherSuites");
109
if (enabledCipherSuites != null) {
110
StringTokenizer st = new StringTokenizer(enabledCipherSuites, ",");
111
int tokens = st.countTokens();
112
String [] enabledCipherSuitesList = new String[tokens];
114
for (int i = 0; i < tokens; i++) {
115
enabledCipherSuitesList[i] = st.nextToken();
119
sslSocket.setEnabledCipherSuites(enabledCipherSuitesList);
120
} catch (IllegalArgumentException e) {
121
throw (IOException)new IOException(e.getMessage()).initCause(e);
124
// Set the SSLSocket Enabled Protocols
126
final String enabledProtocols =
127
java.lang.System.getProperty("javax.rmi.ssl.client.enabledProtocols");
129
if (enabledProtocols != null) {
130
StringTokenizer st = new StringTokenizer(enabledProtocols, ",");
131
int tokens = st.countTokens();
132
String [] enabledProtocolsList = new String[tokens];
134
for (int i = 0; i < tokens; i++) {
135
enabledProtocolsList[i] = st.nextToken();
139
sslSocket.setEnabledProtocols(enabledProtocolsList);
140
} catch (IllegalArgumentException e) {
142
new IOException(e.getMessage()).initCause(e);
145
// Return the preconfigured SSLSocket