[jboss-cvs] JBossAS SVN: r110882 - in projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers: fungal and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Mar 10 10:58:48 EST 2011


Author: jesper.pedersen
Date: 2011-03-10 10:58:48 -0500 (Thu, 10 Mar 2011)
New Revision: 110882

Modified:
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java
Log:
[JBJCA-519] Security domain isn't applied correctly

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java	2011-03-10 15:18:09 UTC (rev 110881)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractDsDeployer.java	2011-03-10 15:58:48 UTC (rev 110882)
@@ -50,6 +50,7 @@
 import javax.transaction.TransactionManager;
 
 import org.jboss.logging.Logger;
+import org.jboss.security.SubjectFactory;
 
 /**
  * An abstract deployer implementation for datasources
@@ -260,8 +261,21 @@
       PoolConfiguration pc = createPoolConfiguration(ds.getPool(), ds.getTimeOut(), ds.getValidation());
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, false);
+      PoolStrategy strategy = PoolStrategy.ONE_POOL;
 
+      // Security
+      String securityDomain = null;
+      if (ds.getSecurity() != null)
+      {
+         if (ds.getSecurity().getSecurityDomain() != null)
+         {
+            strategy = PoolStrategy.POOL_BY_SUBJECT;
+            securityDomain = ds.getSecurity().getSecurityDomain();
+         }
+      }
+
+      Pool pool = pf.create(strategy, mcf, pc, false);
+
       // Connection manager properties
       Integer allocationRetry = null;
       Long allocationRetryWaitMillis = null;
@@ -276,7 +290,8 @@
       TransactionSupportLevel tsl = TransactionSupportLevel.LocalTransaction;
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       ConnectionManager cm = 
-         cmf.createTransactional(tsl, pool, null, null, allocationRetry, allocationRetryWaitMillis,
+         cmf.createTransactional(tsl, pool, getSubjectFactory(securityDomain), securityDomain,
+                                 allocationRetry, allocationRetryWaitMillis,
                                  getTransactionManager(), null, null, null, null, null);
 
       cm.setJndiName(jndiName);
@@ -338,8 +353,21 @@
          noTxSeparatePool = ds.getXaPool().isNoTxSeparatePool();
 
       PoolFactory pf = new PoolFactory();
-      Pool pool = pf.create(PoolStrategy.ONE_POOL, mcf, pc, noTxSeparatePool.booleanValue());
+      PoolStrategy strategy = PoolStrategy.ONE_POOL;
 
+      // Security
+      String securityDomain = null;
+      if (ds.getSecurity() != null)
+      {
+         if (ds.getSecurity().getSecurityDomain() != null)
+         {
+            strategy = PoolStrategy.POOL_BY_SUBJECT;
+            securityDomain = ds.getSecurity().getSecurityDomain();
+         }
+      }
+
+      Pool pool = pf.create(strategy, mcf, pc, noTxSeparatePool.booleanValue());
+
       // Connection manager properties
       Integer allocationRetry = null;
       Long allocationRetryWaitMillis = null;
@@ -368,7 +396,7 @@
       TransactionSupportLevel tsl = TransactionSupportLevel.XATransaction;
       ConnectionManagerFactory cmf = new ConnectionManagerFactory();
       ConnectionManager cm =
-         cmf.createTransactional(tsl, pool, null, null,
+         cmf.createTransactional(tsl, pool, getSubjectFactory(securityDomain), securityDomain,
                                  allocationRetry, allocationRetryWaitMillis,
                                  getTransactionManager(), interleaving, 
                                  xaResourceTimeout, isSameRMOverride, wrapXAResource, padXid);
@@ -501,4 +529,12 @@
     */
    protected abstract Object initAndInject(String className, List<? extends ConfigProperty> configs, ClassLoader cl)
       throws DeployException;
+
+   /**
+    * Get a subject factory
+    * @param securityDomain The security domain
+    * @return The subject factory; must return <code>null</code> if security domain isn't defined
+    * @exception DeployException Thrown if the security domain can't be resolved
+    */
+   protected abstract SubjectFactory getSubjectFactory(String securityDomain) throws DeployException;
 }

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java	2011-03-10 15:18:09 UTC (rev 110881)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/DsXmlDeployer.java	2011-03-10 15:58:48 UTC (rev 110882)
@@ -39,6 +39,7 @@
 import java.util.Set;
 
 import org.jboss.logging.Logger;
+import org.jboss.security.SubjectFactory;
 
 import com.github.fungal.api.Kernel;
 import com.github.fungal.api.util.Injection;
@@ -299,4 +300,25 @@
          throw new RuntimeException(t.getMessage(), t);
       }
    }
+
+   @Override
+   protected SubjectFactory getSubjectFactory(String securityDomain) 
+      throws org.jboss.jca.deployers.common.DeployException
+   {
+      log.tracef("getSubjectFactory(%s)", securityDomain);
+
+      if (securityDomain == null || securityDomain.trim().equals(""))
+         return null;
+
+      try
+      {
+         return kernel.getBean(securityDomain, SubjectFactory.class);
+      }
+      catch (Throwable t)
+      {
+         throw new 
+            org.jboss.jca.deployers.common.DeployException("Error during loookup of security domain: " +
+                                                           securityDomain, t);
+      }
+   }
 }



More information about the jboss-cvs-commits mailing list