[jboss-cvs] JBossAS SVN: r63049 - in projects/security/security-jboss-sx/trunk: src/main/org/jboss/security/auth/spi and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue May 15 10:59:24 EDT 2007
Author: anil.saldhana at jboss.com
Date: 2007-05-15 10:59:23 -0400 (Tue, 15 May 2007)
New Revision: 63049
Added:
projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/plugins/TransactionManagerLocator.java
Modified:
projects/security/security-jboss-sx/trunk/pom.xml
projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/auth/spi/DatabaseServerLoginModule.java
Log:
remove jboss transaction dependency
Modified: projects/security/security-jboss-sx/trunk/pom.xml
===================================================================
--- projects/security/security-jboss-sx/trunk/pom.xml 2007-05-15 13:06:57 UTC (rev 63048)
+++ projects/security/security-jboss-sx/trunk/pom.xml 2007-05-15 14:59:23 UTC (rev 63049)
@@ -305,11 +305,6 @@
</dependency>
<dependency>
<groupId>jboss</groupId>
- <artifactId>jboss-transaction</artifactId>
- <version>5.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>jboss</groupId>
<artifactId>jnpserver</artifactId>
<version>5.0-SNAPSHOT</version>
</dependency>
Modified: projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/auth/spi/DatabaseServerLoginModule.java
===================================================================
--- projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/auth/spi/DatabaseServerLoginModule.java 2007-05-15 13:06:57 UTC (rev 63048)
+++ projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/auth/spi/DatabaseServerLoginModule.java 2007-05-15 14:59:23 UTC (rev 63049)
@@ -33,11 +33,15 @@
import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginException;
-import javax.security.auth.login.FailedLoginException;
+import javax.security.auth.login.FailedLoginException;
+import javax.transaction.SystemException;
import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
-import org.jboss.tm.TransactionDemarcationSupport;
+import org.jboss.security.plugins.TransactionManagerLocator;
+//import org.jboss.tm.TransactionDemarcationSupport;
+
/**
* A JDBC based login module that supports authentication and role mapping.
* It is based on two logical tables:
@@ -74,6 +78,10 @@
protected String rolesQuery = "select Role, RoleGroup from Roles where PrincipalID=?";
/** Whether to suspend resume transactions during database operations */
protected boolean suspendResume = true;
+
+ protected String TX_MGR_JNDI_NAME = "java:/TransactionManager";
+
+ protected TransactionManager tm = null;
/**
* Initialize this LoginModule.
@@ -109,6 +117,19 @@
log.trace("rolesQuery="+rolesQuery);
log.trace("suspendResume="+suspendResume);
}
+ //Get the Transaction Manager JNDI Name
+ String jname = (String) options.get("transactionManagerJndiName");
+ if(jname != null)
+ this.TX_MGR_JNDI_NAME = jname;
+
+ try
+ {
+ tm = this.getTransactionManager();
+ }
+ catch (NamingException e)
+ {
+ throw new RuntimeException("Unable to get Transaction Manager", e);
+ }
}
/** Get the expected password for the current username available via
@@ -129,7 +150,15 @@
Transaction tx = null;
if (suspendResume)
{
- tx = TransactionDemarcationSupport.suspendAnyTransaction();
+ //tx = TransactionDemarcationSupport.suspendAnyTransaction();
+ try
+ {
+ tx = tm.suspend();
+ }
+ catch (SystemException e)
+ {
+ throw new RuntimeException(e);
+ }
if (trace)
log.trace("suspendAnyTransaction");
}
@@ -200,7 +229,15 @@
}
if (suspendResume)
{
- TransactionDemarcationSupport.resumeAnyTransaction(tx);
+ //TransactionDemarcationSupport.resumeAnyTransaction(tx);
+ try
+ {
+ tm.resume(tx);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
if (log.isTraceEnabled())
log.trace("resumeAnyTransaction");
}
@@ -233,4 +270,10 @@
{
return rawPassword;
}
+
+ protected TransactionManager getTransactionManager() throws NamingException
+ {
+ TransactionManagerLocator tml = new TransactionManagerLocator();
+ return tml.getTM(this.TX_MGR_JNDI_NAME);
+ }
}
Added: projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/plugins/TransactionManagerLocator.java
===================================================================
--- projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/plugins/TransactionManagerLocator.java (rev 0)
+++ projects/security/security-jboss-sx/trunk/src/main/org/jboss/security/plugins/TransactionManagerLocator.java 2007-05-15 14:59:23 UTC (rev 63049)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt 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.security.plugins;
+
+import java.lang.reflect.Method;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.TransactionManager;
+
+//$Id$
+
+/**
+ * Locate a Transaction Manager
+ * @author Anil.Saldhana at redhat.com
+ * @since May 13, 2007
+ * @version $Revision$
+ */
+public class TransactionManagerLocator
+{
+ public TransactionManagerLocator()
+ {
+ }
+
+ public TransactionManager getTM(String jndiName) throws NamingException
+ {
+ TransactionManager tm = null;
+ InitialContext ctx = new InitialContext();
+ tm = (TransactionManager) ctx.lookup(jndiName);
+ if(tm == null)
+ try
+ {
+ tm = this.getJBossTM();
+ }
+ catch (Exception e)
+ {
+ }
+ return tm;
+ }
+
+ private TransactionManager getJBossTM() throws Exception
+ {
+ ClassLoader tcl = SubjectActions.getContextClassLoader();
+ Class clz = tcl.loadClass("org.jboss.transaction.TXManager");
+ Method m = clz.getMethod("getInstance", new Class[]{});
+ return (TransactionManager) m.invoke(null, new Object[0]);
+ }
+}
More information about the jboss-cvs-commits
mailing list