Author: ron.sigal(a)jboss.com
Date: 2010-07-03 09:31:46 -0400 (Sat, 03 Jul 2010)
New Revision: 5882
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBREM-1231: Wrapped all state changing calls to InvokerRegistry in PrivilegedAction.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java 2010-07-03
13:29:11 UTC (rev 5881)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java 2010-07-03
13:31:46 UTC (rev 5882)
@@ -22,6 +22,10 @@
package org.jboss.remoting;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.security.PrivilegedActionException;
+import java.security.PrivilegedExceptionAction;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -96,16 +100,29 @@
* @param config - any configuration needed for server
* @return true if alive, false if not
*/
- public static boolean checkConnection(InvokerLocator locator, Map config) throws
Throwable
+ public static boolean checkConnection(final InvokerLocator locator, Map config) throws
Throwable
{
boolean pingWorked = false;
- Map configMap = createPingConfig(config, null);
+ final Map configMap = createPingConfig(config, null);
int pingTimeout = Integer.parseInt((String) configMap.get(ServerInvoker.TIMEOUT));
ClientInvoker innerClientInvoker = null;
try
- {
- innerClientInvoker = InvokerRegistry.createClientInvoker(locator, configMap);
+ {
+ try
+ {
+ innerClientInvoker = (ClientInvoker) AccessController.doPrivileged( new
PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return InvokerRegistry.createClientInvoker(locator, configMap);
+ }
+ });
+ }
+ catch (PrivilegedActionException pae)
+ {
+ throw pae.getException();
+ }
if (!innerClientInvoker.isConnected())
{
@@ -126,7 +143,14 @@
{
if (innerClientInvoker != null)
{
- InvokerRegistry.destroyClientInvoker(locator, configMap);
+ AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ InvokerRegistry.destroyClientInvoker(locator, configMap);
+ return null;
+ }
+ });
}
}
@@ -737,7 +761,20 @@
try
{
- clientInvoker = InvokerRegistry.createClientInvoker(locator, configMap);
+ try
+ {
+ clientInvoker = (ClientInvoker) AccessController.doPrivileged( new
PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return InvokerRegistry.createClientInvoker(locator, configMap);
+ }
+ });
+ }
+ catch (PrivilegedActionException pae)
+ {
+ throw pae.getException();
+ }
}
catch (Exception e)
{
@@ -849,7 +886,14 @@
if (clientInvoker != null)
{
- InvokerRegistry.destroyClientInvoker(locator, configMap);
+ AccessController.doPrivileged( new PrivilegedAction()
+ {
+ public Object run()
+ {
+ InvokerRegistry.destroyClientInvoker(locator, configMap);
+ return null;
+ }
+ });
}
TimerUtil.unschedule(this);