3
* JBoss, Home of Professional Open Source
4
* Copyright 2005, JBoss Inc., and individual contributors as indicated
5
* by the @authors tag. See the copyright.txt in the distribution for a
6
* full listing of individual contributors.
8
* This is free software; you can redistribute it and/or modify it
9
* under the terms of the GNU Lesser General Public License as
10
* published by the Free Software Foundation; either version 2.1 of
11
* the License, or (at your option) any later version.
13
* This software is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* Lesser General Public License for more details.
18
* You should have received a copy of the GNU Lesser General Public
19
* License along with this software; if not, write to the Free
20
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
21
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
23
package org.jboss.remoting.network;
25
import java.security.AccessController;
26
import java.security.PrivilegedAction;
27
import java.security.PrivilegedActionException;
28
import java.security.PrivilegedExceptionAction;
30
import javax.management.ListenerNotFoundException;
31
import javax.management.MBeanNotificationInfo;
32
import javax.management.MBeanServer;
33
import javax.management.NotificationFilter;
34
import javax.management.NotificationListener;
35
import javax.management.ObjectName;
37
import org.jboss.remoting.detection.ServerInvokerMetadata;
38
import org.jboss.remoting.ident.Identity;
39
import org.jboss.remoting.util.SecurityUtility;
43
* A NetworkRegistryWrapper is used to wrap an MBean proxy that implements
44
* org.jboss.remoting.network.NetworkRegistryWrapper. If necessary, each call
45
* will go through an AccessController.doPrivileged() call.
47
* @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
48
* @version $Revision: 1.1 $
50
* Copyright May 6, 2008
53
public class NetworkRegistryWrapper implements NetworkRegistryMBean
55
private NetworkRegistryMBean proxy;
57
public NetworkRegistryWrapper(NetworkRegistryMBean proxy)
62
public void addServer(final Identity identity, final ServerInvokerMetadata[] invokers)
64
if (SecurityUtility.skipAccessControl())
66
proxy.addServer(identity, invokers);
70
AccessController.doPrivileged( new PrivilegedAction()
74
proxy.addServer(identity, invokers);
80
public void changeDomain(final String newDomain)
82
if (SecurityUtility.skipAccessControl())
84
proxy.changeDomain(newDomain);
88
AccessController.doPrivileged( new PrivilegedAction()
92
proxy.changeDomain(newDomain);
98
public NetworkInstance[] getServers()
100
if (SecurityUtility.skipAccessControl())
102
return proxy.getServers();
105
return (NetworkInstance[]) AccessController.doPrivileged( new PrivilegedAction()
109
return proxy.getServers();
114
public boolean hasServer(final Identity identity)
116
if (SecurityUtility.skipAccessControl())
118
return proxy.hasServer(identity);
121
return ((Boolean) AccessController.doPrivileged( new PrivilegedAction()
125
return new Boolean(proxy.hasServer(identity));
130
public NetworkInstance[] queryServers(final NetworkFilter filter)
132
if (SecurityUtility.skipAccessControl())
134
return proxy.queryServers(filter);
137
return (NetworkInstance[]) AccessController.doPrivileged( new PrivilegedAction()
141
return proxy.queryServers(filter);
146
public void removeServer(final Identity identity)
148
if (SecurityUtility.skipAccessControl())
150
proxy.removeServer(identity);
154
AccessController.doPrivileged( new PrivilegedAction()
158
proxy.removeServer(identity);
164
public void updateServer(final Identity identity, final ServerInvokerMetadata[] invokers)
166
if (SecurityUtility.skipAccessControl())
168
proxy.updateServer(identity, invokers);
172
AccessController.doPrivileged( new PrivilegedAction()
176
proxy.updateServer(identity, invokers);
182
public void addNotificationListener(final NotificationListener listener,
183
final NotificationFilter filter,
184
final Object handback)
185
throws IllegalArgumentException
187
if (SecurityUtility.skipAccessControl())
189
proxy.addNotificationListener(listener, filter, handback);
195
AccessController.doPrivileged( new PrivilegedExceptionAction()
197
public Object run() throws IllegalArgumentException
199
proxy.addNotificationListener(listener, filter, handback);
204
catch (PrivilegedActionException e)
206
throw (IllegalArgumentException) e.getCause();
210
public MBeanNotificationInfo[] getNotificationInfo()
212
if (SecurityUtility.skipAccessControl())
214
return proxy.getNotificationInfo();
217
return (MBeanNotificationInfo[]) AccessController.doPrivileged( new PrivilegedAction()
221
return proxy.getNotificationInfo();
226
public void removeNotificationListener(final NotificationListener listener)
227
throws ListenerNotFoundException
229
if (SecurityUtility.skipAccessControl())
231
proxy.removeNotificationListener(listener);
237
AccessController.doPrivileged( new PrivilegedExceptionAction()
239
public Object run() throws ListenerNotFoundException
241
proxy.removeNotificationListener(listener);
246
catch (PrivilegedActionException e)
248
throw (ListenerNotFoundException) e.getCause();
252
public void postDeregister()
254
if (SecurityUtility.skipAccessControl())
256
proxy.postDeregister();
260
AccessController.doPrivileged( new PrivilegedAction()
264
proxy.postDeregister();
270
public void postRegister(final Boolean registrationDone)
272
if (SecurityUtility.skipAccessControl())
274
proxy.postRegister(registrationDone);
278
AccessController.doPrivileged( new PrivilegedAction()
282
proxy.postRegister(registrationDone);
288
public void preDeregister() throws Exception
290
if (SecurityUtility.skipAccessControl())
292
proxy.preDeregister();
298
AccessController.doPrivileged( new PrivilegedExceptionAction()
300
public Object run() throws Exception
302
proxy.preDeregister();
307
catch (PrivilegedActionException e)
309
throw (Exception) e.getCause();
313
public ObjectName preRegister(final MBeanServer server, final ObjectName name)
316
if (SecurityUtility.skipAccessControl())
318
return proxy.preRegister(server, name);
323
return (ObjectName) AccessController.doPrivileged( new PrivilegedExceptionAction()
325
public Object run() throws Exception
327
return proxy.preRegister(server, name);
331
catch (PrivilegedActionException e)
333
throw (Exception) e.getCause();
b'\\ No newline at end of file'