Here is my Authenticator Class:
| package edu.byu.cs.csl.dogma.server;
|
| import java.util.List;
| import java.util.Set;
|
| import javax.persistence.EntityManager;
|
| import org.jboss.seam.annotations.In;
| import org.jboss.seam.annotations.Logger;
| import org.jboss.seam.annotations.Name;
| import org.jboss.seam.log.Log;
| import org.jboss.seam.security.Identity;
|
| import edu.byu.cs.csl.dogma.server.model.Permission;
| import edu.byu.cs.csl.dogma.server.model.Users;
|
| @Name("authenticator")
| public class Authenticator {
| @Logger
| private Log log;
|
| @In(value="entityManager") EntityManager em;
|
| @SuppressWarnings("unchecked")
| public boolean authenticate() {
| log.info("authenticating #0", Identity.instance().getUsername());
| if(em == null){log.error("Could not authenticate because EntityManager
null."); return false;}
| List<Users> users = em.createQuery("select u from Users u where
username=:username and password=:password")
| .setParameter("username", Identity.instance().getUsername())
| .setParameter("password", Identity.instance().getPassword())
| .getResultList();
| if(users.size() == 0) {
| return false;
| } else {
| Users user = users.get(0);
| Set<Permission> permissions = user.getPermissions();
| for(Permission perm: permissions) {
| Identity.instance().addRole(perm.getDescription());
| }
| }
| return true;
| }
| }
|
And here is my components.xml
| <?xml version="1.0" encoding="UTF-8"?>
| <components
xmlns="http://jboss.com/products/seam/components"
|
xmlns:core="http://jboss.com/products/seam/core"
|
xmlns:drools="http://jboss.com/products/seam/drools"
|
xmlns:security="http://jboss.com/products/seam/security"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xsi:schemaLocation="http://jboss.com/products/seam/core
http://jboss.com/products/seam/core-1.2.xsd
|
http://jboss.com/products/seam/drools
http://jboss.com/products/seam/drools-1.2.xsd
|
http://jboss.com/products/seam/security
http://jboss.com/products/seam/security-1.2.xsd
|
http://jboss.com/products/seam/components
http://jboss.com/products/seam/components-1.2.xsd">
|
| <core:init debug="true" jndi-pattern="@jndiPattern@" />
|
| <core:manager concurrent-request-timeout="500"
| conversation-timeout="120000" conversation-id-parameter="cid"
| conversation-is-long-running-parameter="clr" />
|
| <core:pages no-conversation-view-id="/home.xhtml" />
|
| <core:managed-persistence-context name="entityManager"
| auto-create="true"
| persistence-unit-jndi-name="java:/dogma-serverEntityManagerFactory" />
|
| <!-- <core:ejb installed="@embeddedEjb@"/> -->
|
| <drools:rule-base name="securityRules">
| <drools:rule-files>
| <value>/security.drl</value>
| </drools:rule-files>
| </drools:rule-base>
|
| <security:identity
| authenticate-method="#{authenticator.authenticate}" />
|
| <!-- For use with jBPM pageflow or process management -->
| <!--
| <core:jbpm>
| <core:process-definitions></core:process-definitions>
| <core:pageflow-definitions></core:pageflow-definitions>
| </core:jbpm>
| -->
|
| </components>
|
Does any one see something wrong? I recompiled the Seam jars with java 6 and am now using
them so that isn't the issue. Were there configuration file changes that would
account for this?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4024329#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...