Author: ron.sigal(a)jboss.com
Date: 2009-05-19 14:51:16 -0400 (Tue, 19 May 2009)
New Revision: 5276
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java
Log:
JBREM-1137: Wrapped call to new InitialContext() in PrivilegedExceptionAction.
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java
===================================================================
---
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java 2009-05-19
18:50:16 UTC (rev 5275)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/detection/jndi/JNDIDetector.java 2009-05-19
18:51:16 UTC (rev 5276)
@@ -504,7 +504,7 @@
env.put(Context.PROVIDER_URL, host + ":" + port);
env.put(Context.URL_PKG_PREFIXES, urlPackage);
- InitialContext initialContext = new InitialContext(env);
+ InitialContext initialContext = createContext(env);
try
{
context = initialContextLookup(initialContext, subContextName);
@@ -770,4 +770,27 @@
throw (NamingException) e.getCause();
}
}
+
+ static private InitialContext createContext(final Properties env) throws
NamingException
+ {
+ if (SecurityUtility.skipAccessControl())
+ {
+ return new InitialContext(env);
+ }
+
+ try
+ {
+ return (InitialContext) AccessController.doPrivileged( new
PrivilegedExceptionAction()
+ {
+ public Object run() throws Exception
+ {
+ return new InitialContext(env);
+ }
+ });
+ }
+ catch (PrivilegedActionException e)
+ {
+ throw (RuntimeException) e.getCause();
+ }
+ }
}
Show replies by date