Package org.jboss.seam.security.examples.simple

Source Code of org.jboss.seam.security.examples.simple.SimpleAuthenticator

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

import javax.inject.Inject;

import org.jboss.seam.security.Authenticator;
import org.jboss.seam.security.BaseAuthenticator;
import org.jboss.seam.security.Credentials;
import org.picketlink.idm.impl.api.PasswordCredential;
import org.picketlink.idm.impl.api.model.SimpleUser;

/**
* This is the simplest possible example of a custom authenticator.
*
* @author Shane Bryzak
*
*/
public class SimpleAuthenticator extends BaseAuthenticator implements Authenticator
{
   @Inject Credentials credentials;
  
   @Override
   public void authenticate()
   {
      if ("demo".equals(credentials.getUsername()) &&
            credentials.getCredential() instanceof PasswordCredential &&
            "demo".equals(((PasswordCredential) credentials.getCredential()).getValue()))
      {
         setStatus(AuthenticationStatus.SUCCESS);
         setUser(new SimpleUser("demo"));
      }
      else
      {
         setStatus(AuthenticationStatus.FAILURE);
      }
   }

}
TOP

Related Classes of org.jboss.seam.security.examples.simple.SimpleAuthenticator

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.