Getting Shibboleth Attributes through Struts-1

安稳与你 提交于 2019-12-11 17:57:01

问题


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:


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



来源:https://stackoverflow.com/questions/17577547/getting-shibboleth-attributes-through-struts-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!