I would like to iterate through all available attributes in a ServletRequest
. But somehow when doing that, not all available attributes are shown. It seems this way because when requesting a specific attribute that wasn't shown in the enumeration, the value gets printed correctly.
Code for iterating attributes and for showing specific attribute
HttpServletRequest request = this.getHttpServletRequest();
Enumeration en = request.getAttributeNames();
while (en.hasMoreElements())
{
Object currentElem = en.nextElement();
System.out.println("currentElem.getClass(): " + currentElem.getClass());
System.out.println("currentElem.toString(): " + currentElem);
}
Object specificAttrValue = request.getAttribute("Shib-Identity-Provider");
System.out.println("\nspecific attr: " + specificAttrValue);
Output:
currentElem.getClass(): class java.lang.String
currentElem.toString(): corsFilter.FILTERED
currentElem.getClass(): class java.lang.String
currentElem.toString(): org.springframework.web.context.request.RequestContextListener.REQUEST_ATTRIBUTES
currentElem.getClass(): class java.lang.String
currentElem.toString(): __spring_security_scpf_applied
currentElem.getClass(): class java.lang.String
currentElem.toString(): __spring_security_session_mgmt_filter_applied
currentElem.getClass(): class java.lang.String
currentElem.toString(): org.springframework.security.web.FilterChainProxy.APPLIED
currentElem.getClass(): class java.lang.String
currentElem.toString(): __spring_security_filterSecurityInterceptor_filterAppliedspecific attr: https://idp.testshib.org/idp/shibboleth
Why does the iteration not show Shib-Identity-Provider as an available attribute?
How do I iterate through the actually available attributes that are "hidden"?
Note: The attributes I would like to access are being set by the Shibboleth Service Provider. The request first goes to an Apache server, then to Shibboleth, then to the testshib.org Identity Provider, back to Shibboleth and depending on the contents the request gets enriched by some attributes (these are the ones I need to access) and then it gets routed to the Tomcat servlet.
If I see this post which has the same problem: Retrieving Shibboleth attributes from AJP connector request
It looks like the getAttributeNames() of this container isn't well implemented for some reason and doesn't return all of the attributes
This links may help too:
https://stackoverflow.com/a/3533183/2575906 for the getAttributesNames implementation problem
https://stackoverflow.com/a/17663394/2575906 for the fact that it also could be a server-side mis-configuration on Shibboleth