[jboss-user] [JBoss Seam] - SeamLoginModule

koriel do-not-reply at jboss.com
Sun Feb 11 15:31:58 EST 2007


Hi all. I want to use the SeamLoginModule that uses JAAS in SEAM 1.1.5 and I've read the docs and I try to do it like it says to run an example but it doesn't work... 

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:security="http://jboss.com/products/seam/security"
  |             xmlns:drools="http://jboss.com/products/seam/drools"
  |             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  |             xsi:schemaLocation=
  |                 "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-1.1.xsd 
  |                  http://jboss.com/products/seam/components http://jboss.com/products/seam/components-1.1.xsd">
  | 
  |      <component name="org.jboss.seam.core.init">
  |         <property name="jndiPattern">new_uai/#{ejbName}/local</property>
  |     </component>
  |    
  |     <!-- 120 second conversation timeout -->
  |     <core:manager conversation-timeout="120000"/>
  |     
  |     <security:identity authenticate-method="#{authenticator.authenticate}"/>
  | 
  |    
  |     
  | </components>
  | 

My authenticator method 

  | package uai.security;
  | 
  | import java.util.Set;
  | 
  | import javax.ejb.Stateless;
  | import javax.persistence.EntityManager;
  | import javax.persistence.NoResultException;
  | 
  | import org.jboss.seam.annotations.In;
  | import org.jboss.seam.annotations.Name;
  | import org.jboss.seam.core.FacesMessages;
  | 
  | import uai.entities.User;
  | import uai.entities.UserRole;
  | 
  | @Name("authenticator")
  | public class Authenticator {
  | 
  | 	@In
  | 	EntityManager entityManager;
  | 
  | 	public boolean authenticate(String username, String password,
  | 			Set<String> roles) {
  | 		try {
  | 			User user = (User) entityManager
  | 					.createQuery(
  | 							"from User where username = :username and password = :password")
  | 					.setParameter("username", username).setParameter(
  | 							"password", password).getSingleResult();
  | 			if (user.getRoles() != null) {
  | 				for (UserRole mr : user.getRoles())
  | 					roles.add(mr.getRoles());
  | 			}
  | 			return true;
  | 		} catch (NoResultException ex) {
  | 			FacesMessages.instance().add("Invalid username/password");
  | 			return false;
  | 		}
  | 	}
  | 	
  | 	public boolean testme() {
  | 		System.out.println("hi there");
  | 		return true;
  | 	}
  | 
  | }
  | 

and my login form 


  | 	<h:form>
  | 				
  | 				<div><h:outputLabel for="name" value="Username" /> <h:inputText
  | 					id="name" value="#{identity.username}" /></div>
  | 
  | 				<div><h:outputLabel for="password" value="Password" /> <h:inputSecret
  | 					id="password" value="#{identity.password}" /></div>
  | 				<div><h:commandButton value="Login" action="#{identity.login}" /></div>
  | 
  | 
  | 
  | 			
  | 				<div><h:messages layout="table" styleClass="cntError" /></div>
  | 			</h:form>
  | 

Now when I run this the only thing I get is a Conversion Error but the submit never goes to the authenticator bean....

any ideas?

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

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4014640



More information about the jboss-user mailing list