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.callback;
25
import java.io.IOException;
26
import java.io.Serializable;
27
import java.security.AccessController;
28
import java.security.PrivilegedAction;
29
import java.security.PrivilegedActionException;
30
import java.security.PrivilegedExceptionAction;
33
import org.jboss.remoting.SerializableStore;
34
import org.jboss.remoting.util.SecurityUtility;
37
* A CallbackStoreWrapper is used to wrap an MBean proxy that implements
38
* org.jboss.remoting.SerializableStore. If necessary, each call will go
39
* through an AccessController.doPrivileged() call.
41
* @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
42
* @version $Revision: 1.1 $
44
* Copyright May 5, 2008
47
public class CallbackStoreWrapper implements SerializableStore
49
private SerializableStore proxy;
52
public CallbackStoreWrapper(SerializableStore proxy)
57
public void add(final Serializable object) throws IOException
59
if (SecurityUtility.skipAccessControl())
67
AccessController.doPrivileged( new PrivilegedExceptionAction()
69
public Object run() throws IOException
76
catch (PrivilegedActionException e)
78
throw (IOException) e.getCause();
82
public void create() throws Exception
84
if (SecurityUtility.skipAccessControl())
92
AccessController.doPrivileged( new PrivilegedExceptionAction()
94
public Object run() throws Exception
101
catch (PrivilegedActionException e)
103
throw (Exception) e.getCause();
107
public void destroy()
109
if (SecurityUtility.skipAccessControl())
115
AccessController.doPrivileged( new PrivilegedAction()
125
public Object getNext() throws IOException
127
if (SecurityUtility.skipAccessControl())
129
return proxy.getNext();
134
return AccessController.doPrivileged( new PrivilegedExceptionAction()
136
public Object run() throws IOException
138
return proxy.getNext();
142
catch (PrivilegedActionException e)
144
throw (IOException) e.getCause();
148
public boolean getPurgeOnShutdown()
150
if (SecurityUtility.skipAccessControl())
152
return proxy.getPurgeOnShutdown();
155
return ((Boolean) AccessController.doPrivileged( new PrivilegedAction()
159
return new Boolean(proxy.getPurgeOnShutdown());
164
public void purgeFiles()
166
if (SecurityUtility.skipAccessControl())
172
AccessController.doPrivileged( new PrivilegedAction()
182
public void setConfig(final Map config)
184
if (SecurityUtility.skipAccessControl())
186
proxy.setConfig(config);
190
AccessController.doPrivileged( new PrivilegedAction()
194
proxy.setConfig(config);
200
public void setPurgeOnShutdown(final boolean purgeOnShutdown)
202
if (SecurityUtility.skipAccessControl())
204
proxy.setPurgeOnShutdown(purgeOnShutdown);
208
AccessController.doPrivileged( new PrivilegedAction()
212
proxy.setPurgeOnShutdown(purgeOnShutdown);
220
if (SecurityUtility.skipAccessControl())
225
return ((Integer) AccessController.doPrivileged( new PrivilegedAction()
229
return new Integer(proxy.size());
234
public void start() throws Exception
236
if (SecurityUtility.skipAccessControl())
244
AccessController.doPrivileged( new PrivilegedExceptionAction()
246
public Object run() throws Exception
253
catch (PrivilegedActionException e)
255
throw (Exception) e.getCause();
261
if (SecurityUtility.skipAccessControl())
267
AccessController.doPrivileged( new PrivilegedAction()
b'\\ No newline at end of file'