001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2002-2004 French National Institute For Research In Computer
004: * Science And Control (INRIA).
005: * Contact: sequoia@continuent.org
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: *
019: * Initial developer(s): Marc Wick.
020: * Contributor(s): ______________________.
021: */package org.continuent.sequoia.common.net;
022:
023: import java.io.IOException;
024: import java.net.InetAddress;
025: import java.net.ServerSocket;
026: import java.net.UnknownHostException;
027:
028: import javax.net.ssl.SSLServerSocket;
029: import javax.net.ssl.SSLServerSocketFactory;
030:
031: /**
032: * This class defines a AuthenticatedSSLSocketFactory
033: * <p>
034: * It is a wrapper around the socket factory in the constructor and sets the
035: * setNeedClientAuth to true to enforce client authentication with the public
036: * key
037: *
038: * @author <a href="mailto:marc.wick@monte-bre.ch">Marc Wick </a>
039: * @version 1.0
040: */
041: public class AuthenticatedServerSocketFactory extends
042: SSLServerSocketFactory
043:
044: {
045:
046: private SSLServerSocketFactory factory;
047:
048: /**
049: * Creates a new <code>AuthenticatedSSLSocketFactory.java</code> object
050: *
051: * @param factory - the factory
052: */
053: public AuthenticatedServerSocketFactory(
054: SSLServerSocketFactory factory) {
055: this .factory = factory;
056: }
057:
058: /**
059: * @see javax.net.ServerSocketFactory#createServerSocket(int)
060: */
061: public ServerSocket createServerSocket(int port)
062: throws IOException, UnknownHostException {
063: SSLServerSocket socket = (SSLServerSocket) factory
064: .createServerSocket(port);
065: socket.setNeedClientAuth(true);
066: return socket;
067: }
068:
069: /**
070: * @see javax.net.ServerSocketFactory#createServerSocket(int,int)
071: */
072: public ServerSocket createServerSocket(int port, int backlog)
073: throws IOException, UnknownHostException {
074: SSLServerSocket socket = (SSLServerSocket) factory
075: .createServerSocket(port, backlog);
076: socket.setNeedClientAuth(true);
077: return socket;
078: }
079:
080: /**
081: * @see javax.net.ServerSocketFactory#createServerSocket(int, int,
082: * java.net.InetAddress)
083: */
084: public ServerSocket createServerSocket(int port, int backlog,
085: InetAddress ifAddress) throws IOException,
086: UnknownHostException {
087: SSLServerSocket socket = (SSLServerSocket) factory
088: .createServerSocket(port, backlog, ifAddress);
089: socket.setNeedClientAuth(true);
090: return socket;
091: }
092:
093: /**
094: * @see javax.net.ssl.SSLServerSocketFactory#getDefaultCipherSuites()
095: */
096: public String[] getDefaultCipherSuites() {
097: return factory.getDefaultCipherSuites();
098: }
099:
100: /**
101: * @see javax.net.ssl.SSLServerSocketFactory#getSupportedCipherSuites()
102: */
103: public String[] getSupportedCipherSuites() {
104: return factory.getDefaultCipherSuites();
105: }
106:
107: }
|