从Shibboleth IDP 3 MFA流中的先前身份验证中获取用户属性

时间:2018-09-11 17:42:26

标签: java attributes single-sign-on shibboleth idp

我正在尝试为shibboleth idp 3构建一个两因素身份验证流程。它是通过具有初始ldap身份验证的MFA流程以及基于外部authn身份验证的2FA流程设置的。

如何从servlet中的先前ldap流获取用户数据?似乎尚未设置request.getAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY)等。文档说LDAP属性是在身份验证过程中返回的,并在 LDAPResponseContext 中公开。如何在servlet中访问上下文?

我还尝试使用属性解析器从AD用户简要表中释放特定值,但是我无法在servlet中找到这些值。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

我发现了这一点,也许其他人发现它有帮助:

密码流使用主体名称填充c14n上下文,对我来说足够了。要在servlet中获取主体名称:

protected void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException {
        try {
            String authenticationKey = ExternalAuthentication.startExternalAuthentication(request);

            // get userPrincipalName of previous authn
            final ProfileRequestContext profileRequestContext = ExternalAuthentication.getProfileRequestContext(authenticationKey, request);
            final SubjectCanonicalizationContext c14nContext = profileRequestContext.getSubcontext(SubjectCanonicalizationContext.class);
            if (c14nContext != null && c14nContext.getPrincipalName() != null) {
                usernameShib = c14nContext.getPrincipalName();
                //Subject subjectShib = c14nContext.getSubject();
                logger.info(usernameShib);
            }
        //...
}