Authenticator.java
830 Bytes
package pl.labno.bernard.seamTestInAction;
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.Credentials;
import org.jboss.seam.security.Identity;
@Name("authenticator")
public class Authenticator
{
@Logger private Log log;
@In Identity identity;
@In Credentials credentials;
public boolean authenticate()
{
log.info("authenticating {0}", credentials.getUsername());
if ("admin".equals(credentials.getUsername()))
{
identity.addRole("ADMIN");
return true;
} else if("member".equals(credentials.getUsername())) {
identity.addRole("MEMBER");
return true;
}
return false;
}
}