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

« back to all changes in this revision

Viewing changes to src/org/jboss/remoting/callback/CallbackErrorHandlerWrapper.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
 
/*
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.
7
 
*
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.
12
 
*
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.
17
 
*
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.
22
 
*/
23
 
package org.jboss.remoting.callback;
24
 
 
25
 
import java.security.AccessController;
26
 
import java.security.PrivilegedAction;
27
 
import java.security.PrivilegedActionException;
28
 
import java.security.PrivilegedExceptionAction;
29
 
import java.util.Map;
30
 
 
31
 
import org.jboss.remoting.ServerInvoker;
32
 
import org.jboss.remoting.util.SecurityUtility;
33
 
 
34
 
/**
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.
38
 
 * 
39
 
 * @author <a href="ron.sigal@jboss.com">Ron Sigal</a>
40
 
 * @version $Revision: 1.1 $
41
 
 * <p>
42
 
 * Copyright May 5, 2008
43
 
 * </p>
44
 
 */
45
 
public class CallbackErrorHandlerWrapper implements CallbackErrorHandler
46
 
{
47
 
   private CallbackErrorHandler proxy;
48
 
   
49
 
   public CallbackErrorHandlerWrapper(CallbackErrorHandler proxy)
50
 
   {
51
 
      this.proxy = proxy;
52
 
   }
53
 
   
54
 
   public void handleError(final Throwable ex) throws Throwable
55
 
   {
56
 
      if (SecurityUtility.skipAccessControl())
57
 
      {
58
 
         proxy.handleError(ex);
59
 
         return;
60
 
      }
61
 
      
62
 
      try
63
 
      {
64
 
         AccessController.doPrivileged( new PrivilegedExceptionAction()
65
 
         {
66
 
            public Object run() throws Exception
67
 
            {
68
 
               try
69
 
               {
70
 
                  proxy.handleError(ex);
71
 
                  return null;
72
 
               }
73
 
               catch (Throwable e)
74
 
               {
75
 
                  throw new Exception(ex);
76
 
               }
77
 
            }
78
 
         });
79
 
      }
80
 
      catch (PrivilegedActionException e)
81
 
      {
82
 
         Throwable cause = e.getCause();
83
 
         if (cause.getCause() == null)
84
 
            throw cause;
85
 
         throw cause.getCause();
86
 
      }
87
 
   }
88
 
 
89
 
   public void setCallbackHandler(final ServerInvokerCallbackHandler serverInvokerCallbackHandler)
90
 
   {
91
 
      if (SecurityUtility.skipAccessControl())
92
 
      {
93
 
          proxy.setCallbackHandler(serverInvokerCallbackHandler);
94
 
          return;
95
 
      }
96
 
 
97
 
      AccessController.doPrivileged( new PrivilegedAction()
98
 
      {
99
 
         public Object run()
100
 
         {
101
 
            proxy.setCallbackHandler(serverInvokerCallbackHandler);
102
 
            return null;
103
 
         }
104
 
      });
105
 
   }
106
 
 
107
 
   public void setConfig(final Map errorHandlerConfig)
108
 
   {
109
 
      if (SecurityUtility.skipAccessControl())
110
 
      {
111
 
          proxy.setConfig(errorHandlerConfig);
112
 
          return;
113
 
      }
114
 
 
115
 
      AccessController.doPrivileged( new PrivilegedAction()
116
 
      {
117
 
         public Object run()
118
 
         {
119
 
            proxy.setConfig(errorHandlerConfig);
120
 
            return null;
121
 
         }
122
 
      });
123
 
   }
124
 
 
125
 
   public void setServerInvoker(final ServerInvoker owner)
126
 
   {
127
 
      if (SecurityUtility.skipAccessControl())
128
 
      {
129
 
          proxy.setServerInvoker(owner);
130
 
          return;
131
 
      }
132
 
 
133
 
      AccessController.doPrivileged( new PrivilegedAction()
134
 
      {
135
 
         public Object run()
136
 
         {
137
 
            proxy.setServerInvoker(owner);
138
 
            return null;
139
 
         }
140
 
      });
141
 
   }
142
 
 
143
 
}
144