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.security.AccessController;
26
import java.security.PrivilegedAction;
27
import java.security.PrivilegedActionException;
28
import java.security.PrivilegedExceptionAction;
31
import org.jboss.remoting.ServerInvoker;
32
import org.jboss.remoting.util.SecurityUtility;
35
* A CallbackErrorHandlerWrapper is used to wrap an MBean proxy that implements
36
* org.jboss.remoting.callback.CallbackErrorHandler. If necessary, each call
37
* will go through an AccessController.doPrivileged() call.
39
* @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
40
* @version $Revision: 1.1 $
42
* Copyright May 5, 2008
45
public class CallbackErrorHandlerWrapper implements CallbackErrorHandler
47
private CallbackErrorHandler proxy;
49
public CallbackErrorHandlerWrapper(CallbackErrorHandler proxy)
54
public void handleError(final Throwable ex) throws Throwable
56
if (SecurityUtility.skipAccessControl())
58
proxy.handleError(ex);
64
AccessController.doPrivileged( new PrivilegedExceptionAction()
66
public Object run() throws Exception
70
proxy.handleError(ex);
75
throw new Exception(ex);
80
catch (PrivilegedActionException e)
82
Throwable cause = e.getCause();
83
if (cause.getCause() == null)
85
throw cause.getCause();
89
public void setCallbackHandler(final ServerInvokerCallbackHandler serverInvokerCallbackHandler)
91
if (SecurityUtility.skipAccessControl())
93
proxy.setCallbackHandler(serverInvokerCallbackHandler);
97
AccessController.doPrivileged( new PrivilegedAction()
101
proxy.setCallbackHandler(serverInvokerCallbackHandler);
107
public void setConfig(final Map errorHandlerConfig)
109
if (SecurityUtility.skipAccessControl())
111
proxy.setConfig(errorHandlerConfig);
115
AccessController.doPrivileged( new PrivilegedAction()
119
proxy.setConfig(errorHandlerConfig);
125
public void setServerInvoker(final ServerInvoker owner)
127
if (SecurityUtility.skipAccessControl())
129
proxy.setServerInvoker(owner);
133
AccessController.doPrivileged( new PrivilegedAction()
137
proxy.setServerInvoker(owner);