Package org.cedj.geekseek.service.security.test.integration

Source Code of org.cedj.geekseek.service.security.test.integration.ControllableAuthenticator

package org.cedj.geekseek.service.security.test.integration;

import javax.enterprise.context.RequestScoped;

import org.picketlink.annotations.PicketLink;
import org.picketlink.authentication.BaseAuthenticator;
import org.picketlink.idm.model.sample.User;

@RequestScoped
@PicketLink
public class ControllableAuthenticator extends BaseAuthenticator {

    private boolean wasCalled = false;
    private boolean shouldFailAuth = false;

    @Override
    public void authenticate() {
        wasCalled = true;
        if(shouldFailAuth) {
            setStatus(AuthenticationStatus.FAILURE);
        } else {
            setStatus(AuthenticationStatus.SUCCESS);
            setAccount(new User());
        }
    }

    public boolean wasCalled() {
        return wasCalled;
    }

    public void setShouldFailAuth(boolean fail) {
        this.shouldFailAuth = fail;
    }

}
TOP

Related Classes of org.cedj.geekseek.service.security.test.integration.ControllableAuthenticator

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.