Index: security-jboss-sx/jbosssx/src/test/java/org/jboss/test/security/vault/SecurityVaultUnitTestCase.java
===================================================================
--- security-jboss-sx/jbosssx/src/test/java/org/jboss/test/security/vault/SecurityVaultUnitTestCase.java	(revision 520)
+++ security-jboss-sx/jbosssx/src/test/java/org/jboss/test/security/vault/SecurityVaultUnitTestCase.java	(working copy)
@@ -36,10 +36,12 @@
 import javax.crypto.SecretKeyFactory;
 import javax.crypto.spec.PBEKeySpec;
 import javax.crypto.spec.PBEParameterSpec;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.IOException;
+import java.lang.reflect.Field;
 import java.nio.channels.FileChannel;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -69,6 +71,31 @@
       assertTrue(vault instanceof PicketBoxSecurityVault);
       assertFalse(vault.isInitialized());
    }
+
+   @Test
+   public void testClassLoaderVault() throws Exception
+   {
+      //Back up the existing vault and reset it
+      Field field = SecurityVaultFactory.class.getDeclaredField("vault");
+      field.setAccessible(true);
+      Object existingVault = field.get(null);
+      try
+      {
+         field.set(null, null);
+         ClassLoader cl = SecurityVaultFactory.class.getClassLoader();
+         SecurityVault vault = SecurityVaultFactory.get(cl, TestVault.class.getName());
+         assertNotNull(vault);
+         assertTrue(vault instanceof TestVault);
+         assertFalse(vault.isInitialized());
+      }
+      finally
+      {
+         if (existingVault != null)
+         {
+            field.set(null, existingVault);
+         }
+      }
+   }
    
    @Test
    public void testHandshake() throws Exception
Index: security-jboss-sx/jbosssx/src/test/java/org/jboss/test/security/vault/TestVault.java
===================================================================
--- security-jboss-sx/jbosssx/src/test/java/org/jboss/test/security/vault/TestVault.java	(revision 0)
+++ security-jboss-sx/jbosssx/src/test/java/org/jboss/test/security/vault/TestVault.java	(working copy)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat, Inc., 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.jboss.test.security.vault;
+
+import org.picketbox.plugins.vault.PicketBoxSecurityVault;
+
+public class TestVault extends PicketBoxSecurityVault
+{
+}
\ No newline at end of file
Index: security-spi/spi/src/main/java/org/jboss/security/vault/SecurityActions.java
===================================================================
--- security-spi/spi/src/main/java/org/jboss/security/vault/SecurityActions.java	(revision 520)
+++ security-spi/spi/src/main/java/org/jboss/security/vault/SecurityActions.java	(working copy)
@@ -2,7 +2,7 @@
  * 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. 
+ * 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
@@ -44,7 +44,7 @@
                loadedClass = cl.loadClass(fqn);
             }
             catch (ClassNotFoundException e)
-            { 
+            {
             }
             if(loadedClass == null)
             {
@@ -53,12 +53,41 @@
                   loadedClass = Thread.currentThread().getContextClassLoader().loadClass(fqn);
                }
                catch (ClassNotFoundException e)
-               {   
-               } 
+               {
+               }
             }
             return loadedClass;
          }
       });
-      
+
    }
+
+   static Class<?> loadClass(final ClassLoader classLoader, final String fqn)
+   {
+      return AccessController.doPrivileged(new PrivilegedAction<Class<?>>()
+      {
+         public Class<?> run()
+         {
+            Class<?> loadedClass = null;
+            try
+            {
+               loadedClass = classLoader.loadClass(fqn);
+            }
+            catch (ClassNotFoundException e)
+            {
+            }
+            if(loadedClass == null)
+            {
+               try
+               {
+                  loadedClass = Thread.currentThread().getContextClassLoader().loadClass(fqn);
+               }
+               catch (ClassNotFoundException e)
+               {
+               }
+            }
+            return loadedClass;
+         }
+      });
+   }
 }
\ No newline at end of file
Index: security-spi/spi/src/main/java/org/jboss/security/vault/SecurityVaultFactory.java
===================================================================
--- security-spi/spi/src/main/java/org/jboss/security/vault/SecurityVaultFactory.java	(revision 520)
+++ security-spi/spi/src/main/java/org/jboss/security/vault/SecurityVaultFactory.java	(working copy)
@@ -2,7 +2,7 @@
  * 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. 
+ * 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
@@ -32,7 +32,7 @@
 {
    private static String defaultVault = "org.picketbox.plugins.vault.PicketBoxSecurityVault";
    private static SecurityVault vault= null;
-   
+
    /**
     * Get an instance of {@link SecurityVault}
     * Remember to initialize the vault by checking {@link SecurityVault#isInitialized()}
@@ -43,7 +43,7 @@
    {
       return get(defaultVault);
    }
-   
+
    /**
     * Get an instance of {@link SecurityVault}
     * Remember to initialize the vault by checking {@link SecurityVault#isInitialized()}
@@ -59,7 +59,7 @@
       }
       if(fqn == null)
          return get();
-      
+
       if(vault == null)
       {
          Class<?> vaultClass = SecurityActions.loadClass(SecurityVaultFactory.class,fqn);
@@ -76,4 +76,38 @@
       }
       return vault;
    }
+
+   /**
+    * Get an instance of {@link SecurityVault}
+    * Remember to initialize the vault by checking {@link SecurityVault#isInitialized()}
+    * @param classLoader the class loader to use loading the vault
+    * @param fqn fully qualified name of the vault implementation
+    * @return an instance of {@link SecurityVault}
+    * @throws SecurityVaultException
+    */
+   public static SecurityVault get(ClassLoader classLoader, String fqn) throws SecurityVaultException
+   {
+	      SecurityManager sm = System.getSecurityManager();
+	      if (sm != null) {
+	         sm.checkPermission(new RuntimePermission(SecurityVaultFactory.class.getName() + ".get"));
+	      }
+	      if(fqn == null)
+	         return get();
+
+	      if(vault == null)
+	      {
+	         Class<?> vaultClass = SecurityActions.loadClass(classLoader,fqn);
+	         if(vaultClass == null)
+	            throw new SecurityVaultException(PicketBoxMessages.MESSAGES.unableToLoadVaultMessage());
+	         try
+	         {
+	            vault = (SecurityVault) vaultClass.newInstance();
+	         }
+	         catch (Exception e)
+	         {
+	            throw new SecurityVaultException(PicketBoxMessages.MESSAGES.unableToCreateVaultMessage(), e);
+	         }
+	      }
+	      return vault;
+	   }
 }
\ No newline at end of file
