3

PicketLink 'picketlink-authentication-jsf' クイックスタートに示されているように、PickeLink 2.6.0 (EAR、Wildfly 8.1.0) で JSF 認証を実装しようとしています。@PicketLink アノテーションでマークされた認証を提供しましたが、Identity.login() は常に FAILED を返します。これは私のJSFフォームです:

    <h:form>
        <h:panelGrid styleClass="full">
            <h:inputText value="#{loginCredentials.userId}" required="true"
                pt:placeholder="Username" />
            <h:inputSecret value="#{loginCredentials.password}" required="true"
                pt:placeholder="Password" />
            <h:commandButton value="Login" action="#{loginAction.login()}" />
        </h:panelGrid>
    </h:form>

これは、WAR モジュールの LoginAction Bean です。

import java.util.logging.Logger;
import javax.enterprise.context.RequestScoped;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import org.picketlink.Identity;
import org.picketlink.Identity.AuthenticationResult;
import org.picketlink.credential.DefaultLoginCredentials;

@RequestScoped
@Named
public class LoginAction {

    @Inject
    private Identity identity;
    @Inject
    private DefaultLoginCredentials credentials;

    protected Logger log = Logger.getLogger(this.getClass().getSimpleName());

    public void login() {
        this.log.info(String.format("%s => %s", this.credentials.getUserId(), this.credentials.getPassword()));  // Does get printed!
        AuthenticationResult result = this.identity.login();
        this.log.info(result.toString());

        if (AuthenticationResult.FAILED.equals(result)) {
            FacesContext.getCurrentInstance().addMessage(
                    null,
                    new FacesMessage(FacesMessage.SEVERITY_ERROR,
                            "Authentication was unsuccessful.  Please check your username and password "
                                    + "before trying again.", ""));
        }
    }
}

そして、EJB モジュールの私のオーセンティケータ:

import java.util.logging.Logger;    
import javax.inject.Inject;    
import org.picketlink.annotations.PicketLink;
import org.picketlink.authentication.BaseAuthenticator;
import org.picketlink.credential.DefaultLoginCredentials;

@PicketLink
public class Authenticator extends BaseAuthenticator {

    @Inject
    private DefaultLoginCredentials credentials;
    @Inject
    private ApplicationAuthenticator applicationAuthenticator;

    protected Logger log = Logger.getLogger(this.getClass().getSimpleName());

    @Override
    public void authenticate() {
        this.log.info("authenticate"); // Not printed!
        this.log.info(String.format("%s => %s", this.credentials.getUserId(), this.credentials.getPassword()));

        ProcessResult auth = this.applicationAuthenticator.authUser(
                this.credentials.getUserId(), this.credentials.getPassword());
        this.log.info(auth.toString());

        if (auth.getResult()) {
            this.setStatus(AuthenticationStatus.SUCCESS);
            this.log.info(AuthenticationStatus.SUCCESS.toString());
        } else {
            this.setStatus(AuthenticationStatus.FAILURE);
            this.log.info(AuthenticationStatus.FAILURE.toString());
        }
    }

}

Authenticator がまったく呼び出されていないように見えます。これは私がログから得たものです:

12:25:00,093 INFO  [LoginAction] (LoginAction.java:27) defaultuser => defaultpass
12:25:00,105 INFO  [idm] (DefaultPartitionManager.java:165) PLIDM001000: Bootstrapping PicketLink IDM Partition Manager
12:25:00,107 INFO  [store] (AbstractIdentityStore.java:50) PLIDM001001: Initializing Identity Store [class org.picketlink.idm.file.internal.FileIdentityStore]
12:25:00,110 WARN  [file] (FileDataSource.java:173) PLIDM001101: Working directory [C:\Users\JPANGA~1\AppData\Local\Temp\pl-idm] is marked to be always created. All your existing data will be lost.
12:25:00,165 INFO  [file] (FileDataSource.java:180) PLIDM001100: Using working directory [C:\Users\JPANGA~1\AppData\Local\Temp\pl-idm].
12:25:00,252 INFO  [LoginAction] (LoginAction.java:29) FAILED

PicketLinks jar は $EAR_ROOT/lib にあります。

http://docs.jboss.org/picketlink/2/latest/reference/html-single/でドキュメントを読みましたが、何も欠けていないようです。Authenticator を機能させられないのはなぜですか?

4

1 に答える 1