[jboss-cvs] Picketlink SVN: r1222 - federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Wed Sep 14 16:10:47 EDT 2011


Author: anil.saldhana at jboss.com
Date: 2011-09-14 16:10:47 -0400 (Wed, 14 Sep 2011)
New Revision: 1222

Added:
   federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/ClassLoadingSecurityActions.java
Modified:
   federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/PicketLinkAuthenticator.java
Log:
PLFED-229: PicketLink Authenticator has issues due to custom username that does not change

Added: federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/ClassLoadingSecurityActions.java
===================================================================
--- federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/ClassLoadingSecurityActions.java	                        (rev 0)
+++ federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/ClassLoadingSecurityActions.java	2011-09-14 20:10:47 UTC (rev 1222)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.picketlink.identity.federation.bindings.tomcat;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Privileged Blocks for loading classes
+ * Redundant class added to some environment
+ * with PL1 and PL2 versions of code base
+ * @author Anil.Saldhana at redhat.com
+ * @since Sep 14, 2011
+ */
+class ClassLoadingSecurityActions
+{
+   static Class<?> loadClass(final Class<?> theClass, final String fqn)
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<Class<?>>()
+      {
+         public Class<?> run()
+         {
+            ClassLoader classLoader = theClass.getClassLoader();
+
+            Class<?> clazz = loadClass(classLoader, fqn);
+            if (clazz == null)
+            {
+               classLoader = Thread.currentThread().getContextClassLoader();
+               clazz = loadClass(classLoader, fqn);
+            }
+            return clazz;
+         }
+      });
+   }
+
+   static Class<?> loadClass(final ClassLoader cl, final String fqn)
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<Class<?>>()
+      {
+         public Class<?> run()
+         {
+            try
+            {
+               return cl.loadClass(fqn);
+            }
+            catch (ClassNotFoundException e)
+            {
+            }
+            return null;
+         }
+      });
+   }
+}
\ No newline at end of file

Modified: federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/PicketLinkAuthenticator.java
===================================================================
--- federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/PicketLinkAuthenticator.java	2011-09-13 22:52:14 UTC (rev 1221)
+++ federation/trunk/picketlink-bindings/src/main/java/org/picketlink/identity/federation/bindings/tomcat/PicketLinkAuthenticator.java	2011-09-14 20:10:47 UTC (rev 1222)
@@ -156,7 +156,7 @@
    {
       if (subjectInteraction == null)
       {
-         Class<?> clazz = SecurityActions.loadClass(getClass(), subjectInteractionClassName);
+         Class<?> clazz = ClassLoadingSecurityActions.loadClass(getClass(), subjectInteractionClassName);
          try
          {
             subjectInteraction = (SubjectSecurityInteraction) clazz.newInstance();



More information about the jboss-cvs-commits mailing list