KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > common > net > AuthenticatedServerSocketFactory


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: sequoia@continuent.org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * Initial developer(s): Marc Wick.
20  * Contributor(s): ______________________.
21  */

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

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

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

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

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

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

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

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