Author: anil.saldhana(a)jboss.com
Date: 2012-03-19 11:56:46 -0400 (Mon, 19 Mar 2012)
New Revision: 1522
Modified:
social/trunk/facebook/src/main/java/org/picketlink/social/facebook/FacebookProcessor.java
social/trunk/facebook/src/main/java/org/picketlink/social/facebook/SecurityActions.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/auth/OpenIDProcessor.java
social/trunk/openid/src/main/java/org/picketlink/social/openid/auth/SecurityActions.java
Log:
fix jboss detection
Modified:
social/trunk/facebook/src/main/java/org/picketlink/social/facebook/FacebookProcessor.java
===================================================================
---
social/trunk/facebook/src/main/java/org/picketlink/social/facebook/FacebookProcessor.java 2012-03-15
01:28:49 UTC (rev 1521)
+++
social/trunk/facebook/src/main/java/org/picketlink/social/facebook/FacebookProcessor.java 2012-03-19
15:56:46 UTC (rev 1522)
@@ -234,15 +234,9 @@
private boolean isJBossEnv()
{
- ClassLoader tcl = SecurityActions.getContextClassLoader();
- Class<?> clazz = null;
- try
- {
- clazz = tcl.loadClass("org.jboss.system.Service");
- }
- catch (ClassNotFoundException e)
- {
- }
+ Class<?> clazz = SecurityActions.loadClass(getClass(),
"org.jboss.as.web.WebServer");
+ if(clazz == null)
+ clazz = SecurityActions.loadClass(getClass(),
"org.jboss.system.Service");
if( clazz != null )
return true;
return false;
Modified:
social/trunk/facebook/src/main/java/org/picketlink/social/facebook/SecurityActions.java
===================================================================
---
social/trunk/facebook/src/main/java/org/picketlink/social/facebook/SecurityActions.java 2012-03-15
01:28:49 UTC (rev 1521)
+++
social/trunk/facebook/src/main/java/org/picketlink/social/facebook/SecurityActions.java 2012-03-19
15:56:46 UTC (rev 1522)
@@ -133,4 +133,33 @@
}
});
}
+
+ /**
+ * Using the caller class, try to load a class using its classloader. If unsuccessful,
use the TCCL
+ * @param theAskingClass
+ * @param fqn
+ * @return
+ */
+ static Class<?> loadClass(final Class<?> theAskingClass, final String
fqn)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<Class<?>>()
+ {
+ public Class<?> run()
+ {
+ try
+ {
+ ClassLoader tcl = theAskingClass.getClassLoader();
+ return tcl.loadClass(fqn);
+ }
+ catch (Exception e)
+ {
+ try {
+ return Thread.currentThread().getContextClassLoader().loadClass(fqn);
+ } catch (ClassNotFoundException e1) {
+ return null;
+ }
+ }
+ }
+ });
+ }
}
\ No newline at end of file
Modified:
social/trunk/openid/src/main/java/org/picketlink/social/openid/auth/OpenIDProcessor.java
===================================================================
---
social/trunk/openid/src/main/java/org/picketlink/social/openid/auth/OpenIDProcessor.java 2012-03-15
01:28:49 UTC (rev 1521)
+++
social/trunk/openid/src/main/java/org/picketlink/social/openid/auth/OpenIDProcessor.java 2012-03-19
15:56:46 UTC (rev 1522)
@@ -300,15 +300,9 @@
private boolean isJBossEnv()
{
- ClassLoader tcl = SecurityActions.getContextClassLoader();
- Class<?> clazz = null;
- try
- {
- clazz = tcl.loadClass("org.jboss.system.Service");
- }
- catch (ClassNotFoundException e)
- {
- }
+ Class<?> clazz = SecurityActions.loadClass(getClass(),
"org.jboss.as.web.WebServer");
+ if(clazz == null)
+ clazz = SecurityActions.loadClass(getClass(),
"org.jboss.system.Service");
if( clazz != null )
return true;
return false;
Modified:
social/trunk/openid/src/main/java/org/picketlink/social/openid/auth/SecurityActions.java
===================================================================
---
social/trunk/openid/src/main/java/org/picketlink/social/openid/auth/SecurityActions.java 2012-03-15
01:28:49 UTC (rev 1521)
+++
social/trunk/openid/src/main/java/org/picketlink/social/openid/auth/SecurityActions.java 2012-03-19
15:56:46 UTC (rev 1522)
@@ -117,5 +117,34 @@
}
});
}
+
+ /**
+ * Using the caller class, try to load a class using its classloader. If unsuccessful,
use the TCCL
+ * @param theAskingClass
+ * @param fqn
+ * @return
+ */
+ static Class<?> loadClass(final Class<?> theAskingClass, final String
fqn)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<Class<?>>()
+ {
+ public Class<?> run()
+ {
+ try
+ {
+ ClassLoader tcl = theAskingClass.getClassLoader();
+ return tcl.loadClass(fqn);
+ }
+ catch (Exception e)
+ {
+ try {
+ return Thread.currentThread().getContextClassLoader().loadClass(fqn);
+ } catch (ClassNotFoundException e1) {
+ return null;
+ }
+ }
+ }
+ });
+ }
}
\ No newline at end of file
Show replies by date