[jboss-cvs] jboss-seam/examples/portal/src/org/jboss/seam/example/hibernate ...
Shane Bryzak
sbryzak at redhat.com
Sun Feb 18 21:08:57 EST 2007
User: sbryzak2
Date: 07/02/18 21:08:57
Added: examples/portal/src/org/jboss/seam/example/hibernate
Authenticator.java
Removed: examples/portal/src/org/jboss/seam/example/hibernate
LoginAction.java
Log:
use security api
Revision Changes Path
1.1 date: 2007/02/19 02:08:57; author: sbryzak2; state: Exp;jboss-seam/examples/portal/src/org/jboss/seam/example/hibernate/Authenticator.java
Index: Authenticator.java
===================================================================
package org.jboss.seam.example.hibernate;
import static org.jboss.seam.ScopeType.EVENT;
import static org.jboss.seam.ScopeType.SESSION;
import java.util.List;
import javax.ejb.Remove;
import org.hibernate.Session;
import org.jboss.seam.annotations.Destroy;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.security.Identity;
@Scope(EVENT)
@Name("authenticator")
public class Authenticator
{
@In Identity identity;
@In(create = true) Session bookingDatabase;
@Out(required=false, scope = SESSION)
private User user;
public boolean authenticate()
{
List results = bookingDatabase.createQuery(
"select u from User u where u.username=:username and u.password=:password")
.setParameter("username", identity.getUsername())
.setParameter("password", identity.getPassword())
.list();
if ( results.size()==0 )
{
return false;
}
else
{
user = (User) results.get(0);
return true;
}
}
@Remove @Destroy
public void destroy() {}
}
More information about the jboss-cvs-commits
mailing list