[jboss-user] [JCA/JBoss] - Re: one data source with multiple database users

2008-07-15 Thread diemon
I hope so too. Well, the connection poolling is up to Hibernate and JBoss. I've 
only changed the connection provision. According to what Oracle shows, the 
session looks to be kept between web requests. getConnection method is invoked 
many times. It looks like the connection pool managed by JBoss works good.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4164546#4164546

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4164546
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JCA/JBoss] - Re: one data source with multiple database users

2008-07-14 Thread diemon
The problem was in establishing database connections with different credentials 
in Seam components. I solved the problem in a very simple way. I've used 
hibernate configuration option hibernate.connection.provider_class where in 
getConnection method one can simply return new connection from data source with 
any username/password.

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4164194#4164194

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4164194
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JCA/JBoss] - Re: one data source with multiple database users

2008-05-23 Thread diemon
Let me put my problem in other words. User is authenticated and logged in 
authenticator.authenticate method as configured in components.xml. After 
checking request certificate (no user logging form in present), the 
org.jboss.seam.security.Identity object is filled with usrename and some other 
stuff. As we are in a bean method -'authenticate', which contains entity 
manager, it's clear that we have an established database connection. I need to 
switch database user and open connection from one of connection sub-pools 
created for 'Subjects' (PoolBySubject). When I use my own login module and 
switch the db connection credentials there is another connection opened but if 
another user was logged in, he is disconnected (no concurrent connections are 
opened).

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4152894#4152894

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4152894
___
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user


[jboss-user] [JCA/JBoss] - one data source with multiple database users

2008-05-19 Thread diemon
Hello
I have problem with configuring JBoss 4.2.1+Seam 2.0.1+Oracle 10 to use one 
data source with multiple users. I have configured *-ds.xml file with

  | 
  | 
  |   myDatasource
  | jdbc:oracle:thin:@server:1521:db
  | oracle.jdbc.driver.OracleDriver
  | MyRealm
  | 
  | 
  | 
and added to login-config.xml:

  | 
  |   
  | user
  | pass
  | jboss.jca:service=LocalTxCM,name=myDatasource
  |   
  | 
  | 
my login module code is as follows:

  | import java.security.AccessController;
  | import java.security.Principal;
  | import java.security.PrivilegedAction;
  | import java.security.acl.Group;
  | import java.util.Map;
  | 
  | import javax.management.MBeanServer;
  | import javax.management.MBeanServerFactory;
  | import javax.management.MalformedObjectNameException;
  | import javax.management.ObjectName;
  | import javax.resource.spi.ManagedConnectionFactory;
  | import javax.resource.spi.security.PasswordCredential;
  | import javax.security.auth.Subject;
  | import javax.security.auth.callback.CallbackHandler;
  | import javax.security.auth.login.LoginException;
  | 
  | import org.jboss.mx.util.MBeanServerLocator;
  | import org.jboss.seam.security.Identity;
  | import org.jboss.security.SecurityAssociation;
  | import org.jboss.security.SimplePrincipal;
  | import org.jboss.security.auth.spi.AbstractServerLoginModule;
  | 
  | public class MyLoginModule extends AbstractServerLoginModule {
  | 
  | private static final org.apache.log4j.Logger log = 
org.apache.log4j.Logger
  | .getLogger(my.login.module.MyLoginModule.class);
  | 
  | /* used at jboss startup */
  | private static boolean sysMode = true;
  | 
  | private String sysUserName;
  | private String sysPassword;
  | private String userName;
  | private String password;
  | 
  | private MBeanServer server;
  | private ObjectName managedConnectionFactoryName;
  | private ManagedConnectionFactory mcf;
  | 
  | public SkorLoginModule() {}
  | 
  | @Override
  | public void initialize(Subject subject, CallbackHandler handler, Map 
sharedState, Map options) {
  | 
  | super.initialize(subject, callbackHandler, sharedState, 
options);
  | 
  | String name = (String) 
options.get("managedConnectionFactoryName");
  | try {
  | managedConnectionFactoryName = new ObjectName(name);
  | } catch (MalformedObjectNameException mone) {
  | throw new IllegalArgumentException("Malformed 
ObjectName: " + name);
  | }
  | 
  | sysUserName = (String)options.get("sysUserName");
  | if (sysUserName == null) {
  | throw new IllegalArgumentException("Must supply a 
system user name!");
  | }
  | userName = (String)options.get("sysUserName");
  | 
  | sysPassword = (String)options.get("sysPassword");
  | if (sysPassword == null) {
  | throw new IllegalArgumentException("Must supply a 
system user password!");
  | }
  | password = (String)options.get("sysPassword");
  | 
  | server = MBeanServerLocator.locateJBoss();
  | getMcf();
  | }
  | 
  | @Override
  | public boolean login() throws LoginException {
  | 
  | setUserNameAndPassword();
  | log.info("login(): userName=" + userName + ", sysMode=" + 
sysMode);
  | 
  | Principal principal = new SimplePrincipal(userName);
  | 
  | PasswordCredential credential = new 
  | PasswordCredential(userName, password.toCharArray());
  | credential.setManagedConnectionFactory(getMcf());
  | 
  | subject.getPrincipals().add(principal);
  | subject.getPrivateCredentials().add(credential);
  | 
  | super.loginOk = true;
  | return true;
  | }
  | 
  | protected ManagedConnectionFactory getMcf() {
  | 
  | if (mcf == null) {
  | try {
  | mcf = 
(ManagedConnectionFactory)server.getAttribute(managedConnectionFactoryName, 
"ManagedConnectionFactory");
  | } catch (Exception e) {
  | throw new IllegalArgumentException("Managed 
Connection Factory not found: " + managedConnectionFactoryName);
  | }
  | }
  | return mcf;
  | }
  | 
  | @Override
  | protected Principal getIdentity() {
  | 
  | setUserNameAndPassword();
  | log.info("getIdentity(): userName=" + userName + ", sysMode=" + 
sysMode);
  | 
  | return new SimplePrincipal(userName);
  | }
  | 
  | @Override
  | protected Group[] getRoleSets() throws LoginException {
  | return new Group[] {};
  | }
  | 
  | private void setUserNameAndPassword() {
  |