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

get user attributes from previous authn in Shibboleth IDP 3 MFA flow

我正在尝试为 shibboleth idp 3 构建一个双因素身份验证流程。它设置了带有初始 ldap 身份验证的 MFA 流程,然后是基于外部身份验证流程的我的 2FA 流程。

如何从我的 servlet 中以前的 ldap 流获取用户数据?好像 request.getAttribute(ExternalAuthentication.PRINCIPAL_NAME_KEY) 等还没有设置。文档说 LDAP 属性作为身份验证过程的一部分返回并在 LDAPResponseContext 中公开。我如何访问我的 servlet 中的上下文?

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

我弄明白了,也许其他人觉得它有帮助:

密码流使用主体名称填充 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);
            }
        //...
}