[jboss-user] [JBoss Portal] - Re: Dashboard configuration - drag and drop
diparc
do-not-reply at jboss.com
Sun Feb 22 19:20:59 EST 2009
Thanks Sambit & Vivek!
I wrote a servlet filter like you suggested and I am creating the user when the user is not found, also creating the role when not found, and assigning role to user using the membership module -
however, I am getting an exception when it tries to create the user in the portal database -
anonymous wrote :
| org.hibernate.HibernateException: Unable to locate current JTA transaction
| org.hibernate.context.JTASessionContext.currentSession(JTASessionContext.java:61) org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:544) org.jboss.portal.identity.db.HibernateUserModuleImpl.getCurrentSession(HibernateUserModuleImpl.java:298) org.jboss.portal.identity.db.HibernateUserModuleImpl.createUser(HibernateUserModuleImpl.java:166)
| JBossPortalAuthorizationFilter.createUserAndAssignPortalRole(JBossPortalAuthorizationFilter.java:83)
|
seems like i need to start and end hibernate transactions -
I am using methods in UserModule, RoleModule and MembershipModule only to achieve this-
you mentioned about the TransactionManager, I am not using that -
can you please advise what i need to do here -
here is the code snippet from doFilter() -
|
| ...
| ...
| //create user and assign roles if user is not defined in portal db
| try {
| createUserAndAssignPortalRole(userName);
| filterChain.doFilter(httpRequest, response);
| }
| catch (IllegalArgumentException e) {
| this.filterConfig.getServletContext().log("Invalid user: " + userName);
| e.printStackTrace();
| denyAccess(userName, httpResponse);
| return;
| }
| }
|
| private void createUserAndAssignPortalRole(String userName) throws IllegalArgumentException, ServletException {
|
| try {
| if(!isUserInPortalDB(userName)) {
| this.filterConfig.getServletContext().log("user not found in portal db, creating user: " + userName);
| User user = getUserModule().createUser(userName, ""); //not storing user passwords in database
| getMembershipModule().assignRoles(user, getRequiredRoleSet());
| }
| }
| catch (IdentityException e) {
| this.filterConfig.getServletContext().log("could not assign portal role to user: " + userName);
| throw new ServletException(e);
| }
| }
|
thanks once again for your help,
D
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4212102#4212102
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4212102
More information about the jboss-user
mailing list