// ============================================================
// Copyright (C) 2009 Kuzumeji Hacker. All rights reserved.
// ____ GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 ____
// ___________ http://www.gnu.org/licenses/gpl.html ___________
// File: $$Id: FinderService.java 1669 2009-11-08 11:43:31Z kuzumeji $$
// ============================================================
package kuzumeji.service;
import static org.jboss.seam.ScopeType.SESSION;
import java.util.List;
import javax.persistence.EntityManager;
import kuzumeji.entity.idm.User;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
@Name("authenticator")
public class AuthenticatorAction {
    @In
    EntityManager em;
    @Out(required = false, scope = SESSION)
    private User user;
    public boolean authenticate() {
        List results = em.createQuery("select u from User u where u.username=#{identity.username}").getResultList();
        if (results.size() == 0) {
            return false;
        } else {
            user = (User) results.get(0);
            return true;
        }
    }
}
