OpenAM:无法使用自定义身份验证模块

时间:2015-06-15 07:08:20

标签: openam

我按照example开发了自定义身份验证模块并安装到顶级域。 OpenAM 11.0.0。

enter image description here

然后我打开我的auth模块的测试页面。 enter image description here

登录失败并显示错误" 登录/密码组合无效。"

但是,如果我在看到此错误消息后打开/openam,则表示我已登录。

enter image description here

以下是process

AMLoginModule代码
public int process(Callback[] callbacks, int state) throws LoginException
{

    if (debug.messageEnabled())
    {
        debug.message("Authentication module process() is called. state: " + state);
    }


    switch (state)
    {

        case STATE_BEGIN:
        // No time wasted here - simply modify the UI and
        // proceed to next state
        substituteUIStrings();
        return STATE_AUTH;

        case STATE_AUTH:
        return ISAuthConstants.LOGIN_SUCCEED;

        case STATE_ERROR:
        return STATE_ERROR;
        default:
        throw new AuthLoginException("invalid state");

    }

}

您可以看到接受任何用户名/密码。调试日志显示模块被正确调用。

[root@a3652f4b6f0f debug]# tail /openam/openam/debug/em 
em:06/15/2015 06:58:20:462 AM UTC: Thread[http-bio-8080-exec-4,5,main]
Authentication module process() is called. state: 1
em:06/15/2015 06:58:20:540 AM UTC: Thread[http-bio-8080-exec-4,5,main]
Authentication module process() is called. state: 2
em:06/15/2015 06:58:27:501 AM UTC: Thread[http-bio-8080-exec-4,5,main]
Authentication module init() is called
em:06/15/2015 06:58:27:507 AM UTC: Thread[http-bio-8080-exec-4,5,main]
Authentication module process() is called. state: 1
em:06/15/2015 06:58:27:625 AM UTC: Thread[http-bio-8080-exec-4,5,main]
Authentication module process() is called. state: 2

请为什么我会看到错误" 登录/密码组合无效。"在测试登录页面?

1 个答案:

答案 0 :(得分:0)

问题是您没有登录用户个人资料。您需要在数据存储区中拥有传递给SampleAuthPrincipal("username")构造函数的用户名。

@Override
public Principal getPrincipal() {
    return new SampleAuthPrincipal("username");
}

这可以解决您的问题。