Package org.jboss.seam.security.examples.authorization

Source Code of org.jboss.seam.security.examples.authorization.AuthenticatorImpl

package org.jboss.seam.security.examples.authorization;

import javax.inject.Inject;

import org.jboss.seam.security.Authenticator;
import org.jboss.seam.security.BaseAuthenticator;
import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.UserImpl;

/**
*
* @author Shane Bryzak
*
*/
public class AuthenticatorImpl extends BaseAuthenticator implements Authenticator
{
   @Inject Identity identity;
   @Inject Credentials credentials;
  
   @Override
   public void authenticate()
   {
      if ("demo".equals(credentials.getUsername()))
      {
         identity.addRole("admin", "USERS", "GROUP");
      }     
     
      if ("user".equals(credentials.getUsername()))
      {
         identity.addGroup("USERS", "GROUP");
      }
     
      // Let any user log in
      setStatus(AuthenticationStatus.SUCCESS);
      setUser(new UserImpl(credentials.getUsername()));
   }
}
TOP

Related Classes of org.jboss.seam.security.examples.authorization.AuthenticatorImpl

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.