isUserInRole not working in 2.1
bradleydouglas Dec 4, 2008 7:25 AMHi,
We're having problems with the isUserInRole() EL routines not returning true when we've definately set the roles for the principle.
We're using our own login module within the JBoss security framework for authentication etc, therefore I've included this config frmo the 2.1 security doco into our components.xml:
<security:identity jaas-config-name="other"/>
Here is the code in our LoginModule that we're using to add the roles to our principle:
/** * Return the roles the user has. * @return the Group of roles * @exception LoginException thrown if anything goes wrong */ public Group[] getRoleSets() throws LoginException { if (logger.isTraceEnabled()) { logger.trace("getRoleSets(): entry"); } final Group rolesGroup = new SimpleGroup("Roles"); if (user != null) { if (logger.isDebugEnabled()) { logger.debug("getRoleSets(): adding USER role"); } rolesGroup.addMember(new SimplePrincipal("USER")); // always grant "USER" for (final UserRole role : user.getUserRoles()) { final String roleName = role.getRole().getName(); if (logger.isDebugEnabled()) { logger.debug("getRoleSets(): adding role [#0]", roleName); } rolesGroup.addMember(new SimplePrincipal(roleName)); } } if (logger.isTraceEnabled()) { logger.trace("getRoleSets(): exit"); } return new Group[]{rolesGroup}; }
Here is the log output form our admin user logging in:
2008-12-04 15:03:24,078 TRACE [com.synyati.spurwing.security.SpurwingLoginModule] getRoleSets(): entry
2008-12-04 15:03:24,078 DEBUG [com.synyati.spurwing.security.SpurwingLoginModule] getRoleSets(): adding USER role
2008-12-04 15:03:24,078 DEBUG [com.synyati.spurwing.security.SpurwingLoginModule] getRoleSets(): adding role [APP_ADMIN]
2008-12-04 15:03:24,078 TRACE [com.synyati.spurwing.security.SpurwingLoginModule] getRoleSets(): exit
In our xhtml code we have a h:commandButton with the following EL in the rendered but is not being displayed for that user.
rendered="#{isUserInRole['APP_ADMIN'] or isUserInRole['ORG_ADMIN']}"
This uesed to work in 2.0, so if anyone could please give me hint as to what is wrong, or where I could find more information regarding how to find out what is wrong now I'd really appreciate it, as we really need to upgrade to 2.1 to get the ability to render tags from our on taglib via Renderer.instance().render().
Any help greatly appreciated
Regards Brad D