2
* JBoss, Home of Professional Open Source
3
* Copyright 2005, JBoss Inc., and individual contributors as indicated
4
* by the @authors tag. See the copyright.txt in the distribution for a
5
* full listing of individual contributors.
7
* This is free software; you can redistribute it and/or modify it
8
* under the terms of the GNU Lesser General Public License as
9
* published by the Free Software Foundation; either version 2.1 of
10
* the License, or (at your option) any later version.
12
* This software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with this software; if not, write to the Free
19
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
22
package org.jboss.remoting.security;
24
import java.io.IOException;
25
import java.net.InetAddress;
26
import java.net.ServerSocket;
27
import java.security.AccessController;
28
import java.security.PrivilegedActionException;
29
import java.security.PrivilegedExceptionAction;
31
import javax.net.ServerSocketFactory;
33
import org.jboss.remoting.util.SecurityUtility;
36
* @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
38
public class ServerSocketFactoryWrapper extends ServerSocketFactory
40
private ServerSocketFactoryMBean serverSocketFactory = null;
42
public ServerSocketFactoryWrapper(ServerSocketFactoryMBean serverSocketFactory)
44
this.serverSocketFactory = serverSocketFactory;
47
public ServerSocket createServerSocket(final int i) throws IOException
49
return createServerSocket(serverSocketFactory, i);
52
public ServerSocket createServerSocket(final int i, final int i1) throws IOException
54
return createServerSocket(serverSocketFactory, i, i1);
57
public ServerSocket createServerSocket(final int i, final int i1, final InetAddress inetAddress) throws IOException
59
return createServerSocket(serverSocketFactory, i, i1, inetAddress);
62
public ServerSocket createServerSocket() throws IOException
64
return createServerSocket(serverSocketFactory);
67
public ServerSocketFactoryMBean getDelegate()
69
return serverSocketFactory;
72
static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf) throws IOException
74
if (SecurityUtility.skipAccessControl())
76
return ssf.createServerSocket();
81
return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
83
public Object run() throws IOException
85
return ssf.createServerSocket();
89
catch (PrivilegedActionException e)
91
throw (IOException) e.getCause();
95
static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
96
final int port) throws IOException
98
if (SecurityUtility.skipAccessControl())
100
return ssf.createServerSocket(port);
105
return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
107
public Object run() throws Exception
109
return ssf.createServerSocket(port);
113
catch (PrivilegedActionException e)
115
throw (IOException) e.getCause();
119
static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
120
final int port, final int backlog)
123
if (SecurityUtility.skipAccessControl())
125
return ssf.createServerSocket(port, backlog);
130
return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
132
public Object run() throws Exception
134
return ssf.createServerSocket(port, backlog);
138
catch (PrivilegedActionException e)
140
throw (IOException) e.getCause();
144
static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
145
final int port, final int backlog,
146
final InetAddress inetAddress)
149
if (SecurityUtility.skipAccessControl())
151
return ssf.createServerSocket(port, backlog, inetAddress);
156
return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
158
public Object run() throws Exception
160
return ssf.createServerSocket(port, backlog, inetAddress);
164
catch (PrivilegedActionException e)
166
throw (IOException) e.getCause();
b'\\ No newline at end of file'