Skip to content

Instantly share code, notes, and snippets.

@bleathem
Created March 24, 2011 05:09
Show Gist options
  • Save bleathem/884607 to your computer and use it in GitHub Desktop.
Save bleathem/884607 to your computer and use it in GitHub Desktop.
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"));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment