These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: HibernateLoginModule in JBoss Portal
PostPosted: Tue Mar 22, 2005 6:50 am 
Newbie

Joined: Tue Mar 22, 2005 6:39 am
Posts: 1
Location: Essen, Germany
Hi,

I'm using JBoss 4.0.0 and the new AOP feature for integration puposes.
I guess it works with Hibernate3, not sure...

Anyway, what I want to do is to perform a login to JBoss Portal programatically in an aspect.

What I found out, is that JBoss Portal uses an JAAS LoginModule, called HibernateLoginModule. It's methods login() and commit() are called from JBoss' class HibernateContext (at least I think so).

Now I tried in my aspect to do the same things that must happen in HibernateContext to perform the login like this


Code:
HashMap sharedState = new HashMap();
sharedState.put("javax.security.auth.login.name", portalUserName);
sharedState.put("javax.security.auth.login.password",  Tools.md5AsHexString(portalPass));
HashMap options = new HashMap();
options.put("password-stacking", "useFirstPass");
options.put("unauthenticatedIdentity", "guest");
options.put("hashAlgorithm", "MD5");
options.put("hasEncoding", "HEX");
options.put("factoryJNDIName", "java:/portal/SessionFactory");
options.put("principalsQuery", "SELECT u.password FROM UserImpl AS u WHERE u.userName=:username");
options.put("rolesQuery", "SELECT g.name FROM UserImpl AS u LEFT JOIN u.roles AS g WHERE u.userName=:username");
options.put("additionalRole", "Authenticated");
HibernateLoginModule hlm = new HibernateLoginModule();
hlm.initialize(new Subject(), null, sharedState, options);
boolean log = hlm.login();
System.out.println("Login-result is: " + log);
hlm.commit();


When I execute the code, the last line throws the following exception:

23:17:33,682 INFO [STDOUT] javax.security.auth.login.LoginException:
javax.tran
saction.NotSupportedException: Transaction already active, cannot nest
transacti
ons.
23:17:33,698 INFO [STDOUT] at
org.jboss.portal.core.security.jaas.Hibernate
LoginModule.getRoleSets(HibernateLoginModule.java:196)
23:17:33,698 INFO [STDOUT] at
org.jboss.security.auth.spi.AbstractServerLog
inModule.commit(AbstractServerLoginModule.java:187)
23:17:33,698 INFO [STDOUT] at
integrate.IntegratingLoginAspect.invoke(Integ
ratingLoginAspect.java:150)
23:17:33,698 INFO [STDOUT] at
rmibean.ConnectHyperdocBean_login_N3488153054
972647034_OptimizedMethodInvocation.invokeNext(ConnectHyperdocBean_login_N348815
3054972647034_OptimizedMethodInvocation.java)
23:17:33,698 INFO [STDOUT] at
rmibean.ConnectHyperdocBean.login(ConnectHype
rdocBean.java)
23:17:33,698 INFO [STDOUT] at
sun.reflect.NativeMethodAccessorImpl.invoke0(
Native Method)
23:17:33,698 INFO [STDOUT] at
sun.reflect.NativeMethodAccessorImpl.invoke(N
ativeMethodAccessorImpl.java:39)
23:17:33,698 INFO [STDOUT] at
sun.reflect.DelegatingMethodAccessorImpl.invo
ke(DelegatingMethodAccessorImpl.java:25)
23:17:33,698 INFO [STDOUT] at
java.lang.reflect.Method.invoke(Method.java:5
85)
23:17:33,698 INFO [STDOUT] at
org.jboss.invocation.Invocation.performCall(I
nvocation.java:345)
23:17:33,698 INFO [STDOUT] at
org.jboss.ejb.StatelessSessionContainer$Conta
inerInterceptor.invoke(StatelessSessionContainer.java:214)
23:17:33,698 INFO [STDOUT] at
org.jboss.resource.connectionmanager.CachedCo
nnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)
23:17:33,698 INFO [STDOUT] at
org.jboss.ejb.plugins.StatelessSessionInstanc
eInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
23:17:33,698 INFO [STDOUT] at
org.jboss.webservice.server.ServiceEndpointIn
terceptor.invoke(ServiceEndpointInterceptor.java:51)
23:17:33,698 INFO [STDOUT] at
org.jboss.ejb.plugins.CallValidationIntercept
or.invoke(CallValidationInterceptor.java:48)
23:17:33,698 INFO [STDOUT] at
org.jboss.ejb.plugins.AbstractTxInterceptor.i
nvokeNext(AbstractTxInterceptor.java:105)
23:17:33,698 INFO [STDOUT] at
org.jboss.ejb.plugins.TxInterceptorCMT.runWit
hTransactions(TxInterceptorCMT.java:316)
23:17:33,698 INFO [STDOUT] at
org.jboss.ejb.plugins.TxInterceptorCMT.invoke
(TxInterceptorCMT.java:149)
23:17:33,698 INFO [STDOUT] at
org.jboss.ejb.plugins.SecurityInterceptor.inv
oke(SecurityInterceptor.java:128)
23:17:33,698 INFO [STDOUT] at
org.jboss.ejb.plugins.LogInterceptor.invoke(L
ogInterceptor.java:191)
23:17:33,698 INFO [STDOUT] at
org.jboss.ejb.plugins.ProxyFactoryFinderInter
ceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
23:17:33,698 INFO [STDOUT] at
org.jboss.ejb.SessionContainer.internalInvoke
(SessionContainer.java:624)
23:17:33,698 INFO [STDOUT] at
org.jboss.ejb.Container.invoke(Container.java
:854)
23:17:33,698 INFO [STDOUT] at
sun.reflect.NativeMethodAccessorImpl.invoke0(
Native Method)
23:17:33,698 INFO [STDOUT] at
sun.reflect.NativeMethodAccessorImpl.invoke(N
ativeMethodAccessorImpl.java:39)
23:17:33,698 INFO [STDOUT] at
sun.reflect.DelegatingMethodAccessorImpl.invo
ke(DelegatingMethodAccessorImpl.java:25)
23:17:33,698 INFO [STDOUT] at
java.lang.reflect.Method.invoke(Method.java:5
85)
23:17:33,698 INFO [STDOUT] at
org.jboss.mx.interceptor.ReflectedDispatcher.
invoke(ReflectedDispatcher.java:141)
23:17:33,698 INFO [STDOUT] at
org.jboss.mx.server.Invocation.dispatch(Invoc
ation.java:80)
23:17:33,698 INFO [STDOUT] at
org.jboss.mx.server.Invocation.invoke(Invocat
ion.java:72)
23:17:33,698 INFO [STDOUT] at
org.jboss.mx.server.AbstractMBeanInvoker.invo
ke(AbstractMBeanInvoker.java:242)
23:17:33,698 INFO [STDOUT] at
org.jboss.mx.server.MBeanServerImpl.invoke(MB
eanServerImpl.java:642)
23:17:33,698 INFO [STDOUT] at
org.jboss.invocation.jrmp.server.JRMPInvoker$
MBeanServerAction.invoke(JRMPInvoker.java:775)
23:17:33,698 INFO [STDOUT] at
org.jboss.invocation.jrmp.server.JRMPInvoker.
invoke(JRMPInvoker.java:382)
23:17:33,698 INFO [STDOUT] at
sun.reflect.NativeMethodAccessorImpl.invoke0(
Native Method)
23:17:33,698 INFO [STDOUT] at
sun.reflect.NativeMethodAccessorImpl.invoke(N
ativeMethodAccessorImpl.java:39)
23:17:33,698 INFO [STDOUT] at
sun.reflect.DelegatingMethodAccessorImpl.invo
ke(DelegatingMethodAccessorImpl.java:25)
23:17:33,698 INFO [STDOUT] at
java.lang.reflect.Method.invoke(Method.java:5
85)
23:17:33,698 INFO [STDOUT] at
sun.rmi.server.UnicastServerRef.dispatch(Unic
astServerRef.java:294)
23:17:33,698 INFO [STDOUT] at
sun.rmi.transport.Transport$1.run(Transport.j
ava:153)
23:17:33,698 INFO [STDOUT] at
java.security.AccessController.doPrivileged(N
ative Method)
23:17:33,698 INFO [STDOUT] at
sun.rmi.transport.Transport.serviceCall(Trans
port.java:149)
23:17:33,698 INFO [STDOUT] at
sun.rmi.transport.tcp.TCPTransport.handleMess
ages(TCPTransport.java:460)
23:17:33,698 INFO [STDOUT] at
sun.rmi.transport.tcp.TCPTransport$Connection
Handler.run(TCPTransport.java:701)
23:17:33,698 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)


In fact I never started a transaction in my aspect by myself and I was told that each method that starts a transaction is used to commit it as well.
Can anybody tell me, what I have to do to perform the login correctly. All I need is that this commit-method will return true

Thank you
regards from Germany
OLLI


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 23, 2005 3:22 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
No idea. You probably want to ask one the JBoss forums, or ask the portal folks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.