01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2002-2004 French National Institute For Research In Computer
04: * Science And Control (INRIA).
05: * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
06: * Contact: sequoia@continuent.org
07: *
08: * Licensed under the Apache License, Version 2.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: * Initial developer(s): Marc Wick.
21: * Contributor(s): ______________________.
22: */package org.continuent.sequoia.common.net;
23:
24: import java.io.IOException;
25: import java.io.Serializable;
26: import java.net.Socket;
27: import java.rmi.server.RMIClientSocketFactory;
28:
29: import javax.net.ssl.SSLSocket;
30: import javax.net.ssl.SSLSocketFactory;
31:
32: /**
33: * This class defines a RMISSLClientSocketFactory
34: *
35: * @author <a href="mailto:marc.wick@monte-bre.ch">Marc Wick </a>
36: * @version 1.0
37: */
38: public class RMISSLClientSocketFactory implements
39: RMIClientSocketFactory, Serializable {
40: private static final long serialVersionUID = -5994304413561755872L;
41:
42: /**
43: * @see java.rmi.server.RMIClientSocketFactory#createSocket(java.lang.String,
44: * int)
45: */
46: public Socket createSocket(String host, int port)
47: throws IOException {
48: SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault()
49: .createSocket(host, port);
50: if (System.getProperty("javax.net.ssl.trustStore") != null)
51: socket.setNeedClientAuth(true);
52:
53: return socket;
54: }
55:
56: /**
57: * @see java.lang.Object#equals(java.lang.Object)
58: * <p>
59: * http://developer.java.sun.com/developer/bugParade/bugs/4492317.html
60: */
61: public boolean equals(Object obj) {
62: if (obj == null)
63: return false;
64: if (this == obj)
65: return true;
66: return getClass() == obj.getClass();
67: }
68:
69: /**
70: * @see java.lang.Object#hashCode()
71: * <p>
72: * http://developer.java.sun.com/developer/bugParade/bugs/4492317.html
73: */
74: public int hashCode() {
75: return 13;
76: }
77: }
|