Getting Shibboleth Attributes through Struts-1

2019-09-11 04:26发布

I'm trying to integrate Shibboleth authentication with an old Struts-1 application that I've inherited the maintenance of, but I cannot figure out how to acecss the Shibboleth attributes.

This is what I have tried:

public final class AuthenticateAction extends MappingDispatchAction {

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response)
            throws Exception {


        Enumeration attributeNames = request.getAttributeNames();
        while (attributeNames.hasMoreElements()) {
            String attributeNm = (String) attributeNames.nextElement();
            System.out.println("DEBUG: " + attributeNm);
        }

        String eppn = (String) request.getAttribute("eppn"); // <-- Null 

None of the Shibboleth attributes that I expect are printed out while looping through the attribute names in the code above.

How do I access the Shibboleth attributes?

1条回答
戒情不戒烟
2楼-- · 2019-09-11 04:46

Turns out that in my case, it was an issue with the server-side config.

After following the instructions here: https://wiki.shibboleth.net/confluence/display/SHIB2/NativeSPJavaInstall, I was able to get the attributes simply as:

String eppn = (String) request.getAttribute("eppn"); // <-- no longer null

查看更多
登录 后发表回答