KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > common > net > AuthenticatedServerSocketFactory


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Marc Wick.
22  * Contributor(s): ______________________.
23  */

24
25 package org.objectweb.cjdbc.common.net;
26
27 import java.io.IOException JavaDoc;
28 import java.net.InetAddress JavaDoc;
29 import java.net.ServerSocket JavaDoc;
30 import java.net.UnknownHostException JavaDoc;
31
32 import javax.net.ssl.SSLServerSocket;
33 import javax.net.ssl.SSLServerSocketFactory;
34
35 /**
36  * This class defines a AuthenticatedSSLSocketFactory
37  * <p>
38  * It is a wrapper around the socket factory in the constructor and sets the
39  * setNeedClientAuth to true to enforce client authentication with the public
40  * key
41  *
42  * @author <a HREF="mailto:marc.wick@monte-bre.ch">Marc Wick </a>
43  * @version 1.0
44  */

45 public class AuthenticatedServerSocketFactory extends SSLServerSocketFactory
46
47 {
48
49   private SSLServerSocketFactory factory;
50
51   /**
52    * Creates a new <code>AuthenticatedSSLSocketFactory.java</code> object
53    *
54    * @param factory - the factory
55    */

56   public AuthenticatedServerSocketFactory(SSLServerSocketFactory factory)
57   {
58     this.factory = factory;
59   }
60
61   /**
62    * @see javax.net.ServerSocketFactory#createServerSocket(int)
63    */

64   public ServerSocket JavaDoc createServerSocket(int port) throws IOException JavaDoc,
65       UnknownHostException JavaDoc
66   {
67     SSLServerSocket socket = (SSLServerSocket) factory.createServerSocket(port);
68     socket.setNeedClientAuth(true);
69     return socket;
70   }
71
72   /**
73    * @see javax.net.ServerSocketFactory#createServerSocket(int,int)
74    */

75   public ServerSocket JavaDoc createServerSocket(int port, int backlog)
76       throws IOException JavaDoc, UnknownHostException JavaDoc
77   {
78     SSLServerSocket socket = (SSLServerSocket) factory.createServerSocket(port,
79         backlog);
80     socket.setNeedClientAuth(true);
81     return socket;
82   }
83
84   /**
85    * @see javax.net.ServerSocketFactory#createServerSocket(int, int,
86    * java.net.InetAddress)
87    */

88   public ServerSocket JavaDoc createServerSocket(int port, int backlog,
89       InetAddress JavaDoc ifAddress) throws IOException JavaDoc, UnknownHostException JavaDoc
90   {
91     SSLServerSocket socket = (SSLServerSocket) factory.createServerSocket(port,
92         backlog, ifAddress);
93     socket.setNeedClientAuth(true);
94     return socket;
95   }
96
97   /**
98    * @see javax.net.ssl.SSLServerSocketFactory#getDefaultCipherSuites()
99    */

100   public String JavaDoc[] getDefaultCipherSuites()
101   {
102     return factory.getDefaultCipherSuites();
103   }
104
105   /**
106    * @see javax.net.ssl.SSLServerSocketFactory#getSupportedCipherSuites()
107    */

108   public String JavaDoc[] getSupportedCipherSuites()
109   {
110     return factory.getDefaultCipherSuites();
111   }
112
113 }
Popular Tags