KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > security > ssl > RMISSLServerSocketFactory


1 /*
2  * JBoss, the OpenSource EJB server
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.security.ssl;
8
9 import java.io.IOException JavaDoc;
10 import java.net.ServerSocket JavaDoc;
11 import java.net.UnknownHostException JavaDoc;
12 import java.rmi.server.RMIServerSocketFactory JavaDoc;
13
14 import org.jboss.security.SecurityDomain;
15
16 /** An implementation of RMIServerSocketFactory that uses a
17  DomainServerSocketFactory for its implementation. This class is just an
18  adaptor from the RMIServerSocketFactory to the DomainServerSocketFactory.
19
20  This class is not suitable for RMI object that require a Serializable socket
21  factory like activatable services. The reason for this limitation is that
22  a SecurityDomain is not serializable due to its association with a local
23  KeyStore.
24
25 @author Scott.Stark@jboss.org
26 @version $Revision: 1.7.6.1 $
27 */

28 public class RMISSLServerSocketFactory implements RMIServerSocketFactory JavaDoc
29 {
30    private DomainServerSocketFactory domainFactory;
31
32    /** Creates new RMISSLServerSocketFactory initialized with a
33     DomainServerSocketFactory with not security domain. The setSecurityDomain
34     method must be invoked to establish the correct non-default value.
35     */

36    public RMISSLServerSocketFactory()
37    {
38       domainFactory = new DomainServerSocketFactory();
39    }
40
41    public String JavaDoc getBindAddress()
42    {
43       return domainFactory.getBindAddress();
44    }
45    public void setBindAddress(String JavaDoc host) throws UnknownHostException JavaDoc
46    {
47       domainFactory.setBindAddress(host);
48    }
49
50    public SecurityDomain getSecurityDomain()
51    {
52       return domainFactory.getSecurityDomain();
53    }
54    public void setSecurityDomain(SecurityDomain securityDomain)
55    {
56       domainFactory.setSecurityDomain(securityDomain);
57    }
58
59    public boolean isWantsClientAuth()
60    {
61       return domainFactory.isWantsClientAuth();
62    }
63    public void setWantsClientAuth(boolean wantsClientAuth)
64    {
65       domainFactory.setWantsClientAuth(wantsClientAuth);
66    }
67
68    public boolean isNeedsClientAuth()
69    {
70       return domainFactory.isNeedsClientAuth();
71    }
72    public void setNeedsClientAuth(boolean needsClientAuth)
73    {
74       domainFactory.setNeedsClientAuth(needsClientAuth);
75    }
76
77    /**
78     * Create a server socket on the specified port (port 0 indicates
79     * an anonymous port).
80     * @param port the port number
81     * @return the server socket on the specified port
82     * @exception IOException if an I/O error occurs during server socket
83     * creation
84     */

85    public ServerSocket JavaDoc createServerSocket(int port)
86       throws IOException JavaDoc
87    {
88       return domainFactory.createServerSocket(port);
89    }
90
91    public boolean equals(Object JavaDoc obj)
92    {
93       return obj instanceof RMISSLServerSocketFactory;
94    }
95    public int hashCode()
96    {
97       return getClass().getName().hashCode();
98    }
99 }
100
Popular Tags