~ubuntu-branches/ubuntu/oneiric/libjboss-remoting-java/oneiric

« back to all changes in this revision

Viewing changes to src/main/org/jboss/remoting/security/ServerSocketFactoryWrapper.java

  • Committer: Package Import Robot
  • Author(s): Torsten Werner
  • Date: 2011-09-09 14:01:03 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: package-import@ubuntu.com-20110909140103-hqokx61534tas9rg
Tags: 2.5.3.SP1-1
* Newer but not newest upstream release. Do not build samples.
* Change debian/watch to upstream's svn repo.
* Add patch to fix compile error caused by tomcat update.
  (Closes: #628303)
* Switch to source format 3.0.
* Switch to debhelper level 7.
* Remove useless Depends.
* Update Standards-Version: 3.9.2.
* Update README.source.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
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.
 
6
*
 
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.
 
11
*
 
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.
 
16
*
 
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.
 
21
*/
 
22
package org.jboss.remoting.security;
 
23
 
 
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;
 
30
 
 
31
import javax.net.ServerSocketFactory;
 
32
 
 
33
import org.jboss.remoting.util.SecurityUtility;
 
34
 
 
35
/**
 
36
 * @author <a href="mailto:tom.elrod@jboss.com">Tom Elrod</a>
 
37
 */
 
38
public class ServerSocketFactoryWrapper extends ServerSocketFactory
 
39
{
 
40
   private ServerSocketFactoryMBean serverSocketFactory = null;
 
41
 
 
42
   public ServerSocketFactoryWrapper(ServerSocketFactoryMBean serverSocketFactory)
 
43
   {
 
44
      this.serverSocketFactory = serverSocketFactory;
 
45
   }
 
46
 
 
47
   public ServerSocket createServerSocket(final int i) throws IOException
 
48
   {
 
49
      return createServerSocket(serverSocketFactory, i);
 
50
   }
 
51
 
 
52
   public ServerSocket createServerSocket(final int i, final int i1) throws IOException
 
53
   {
 
54
      return createServerSocket(serverSocketFactory, i, i1);
 
55
   }
 
56
 
 
57
   public ServerSocket createServerSocket(final int i, final int i1, final InetAddress inetAddress) throws IOException
 
58
   {
 
59
      return createServerSocket(serverSocketFactory, i, i1, inetAddress);
 
60
   }
 
61
 
 
62
   public ServerSocket createServerSocket() throws IOException
 
63
   {
 
64
      return createServerSocket(serverSocketFactory);
 
65
   }
 
66
 
 
67
   public ServerSocketFactoryMBean getDelegate()
 
68
   {
 
69
      return serverSocketFactory;
 
70
   }
 
71
   
 
72
   static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf) throws IOException
 
73
   {
 
74
      if (SecurityUtility.skipAccessControl())
 
75
      {
 
76
         return ssf.createServerSocket();
 
77
      }
 
78
 
 
79
      try
 
80
      {
 
81
         return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
 
82
         {
 
83
            public Object run() throws IOException
 
84
            {
 
85
               return ssf.createServerSocket();
 
86
            }
 
87
         });
 
88
      }
 
89
      catch (PrivilegedActionException e)
 
90
      {
 
91
         throw (IOException) e.getCause();
 
92
      }
 
93
   }
 
94
   
 
95
   static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
 
96
                                                 final int port) throws IOException
 
97
   {
 
98
      if (SecurityUtility.skipAccessControl())
 
99
      {
 
100
         return ssf.createServerSocket(port);
 
101
      }
 
102
      
 
103
      try
 
104
      {
 
105
          return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
 
106
          {
 
107
             public Object run() throws Exception
 
108
             {
 
109
                 return ssf.createServerSocket(port);
 
110
             }
 
111
          });
 
112
      }
 
113
      catch (PrivilegedActionException e)
 
114
      {
 
115
          throw (IOException) e.getCause();
 
116
      }
 
117
   }
 
118
   
 
119
   static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
 
120
                                                 final int port, final int backlog)
 
121
   throws IOException
 
122
   {
 
123
      if (SecurityUtility.skipAccessControl())
 
124
      {
 
125
         return ssf.createServerSocket(port, backlog);
 
126
      }
 
127
 
 
128
      try
 
129
      {
 
130
         return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
 
131
         {
 
132
            public Object run() throws Exception
 
133
            {
 
134
               return ssf.createServerSocket(port, backlog);
 
135
            }
 
136
         });
 
137
      }
 
138
      catch (PrivilegedActionException e)
 
139
      {
 
140
         throw (IOException) e.getCause();
 
141
      }
 
142
   }
 
143
   
 
144
   static private ServerSocket createServerSocket(final ServerSocketFactoryMBean ssf,
 
145
                                                 final int port, final int backlog,
 
146
                                                 final InetAddress inetAddress)
 
147
   throws IOException
 
148
   {
 
149
      if (SecurityUtility.skipAccessControl())
 
150
      {
 
151
         return ssf.createServerSocket(port, backlog, inetAddress);
 
152
      }
 
153
 
 
154
      try
 
155
      {
 
156
         return (ServerSocket)AccessController.doPrivileged( new PrivilegedExceptionAction()
 
157
         {
 
158
            public Object run() throws Exception
 
159
            {
 
160
               return ssf.createServerSocket(port, backlog, inetAddress);
 
161
            }
 
162
         });
 
163
      }
 
164
      catch (PrivilegedActionException e)
 
165
      {
 
166
         throw (IOException) e.getCause();
 
167
      }
 
168
   }
 
169
}
 
 
b'\\ No newline at end of file'