Moving to Suppliers for accessing HttpServlet Objects

Prior to V5, the HttpServletRequest and HttpServletResponse objects for the current request were made available via two beans named shibboleth.HttpServletResponse and shibboleth.HttpServletResponse. In V4.3 these were deprecated, and in V5 they have been removed. This was necessary to avoid requiring us to actually implement the servlet interfaces, which is difficult to do when mutliple versions of the Servlet API are potentially supported by the surrounding libraries and container.

These objects are now accessed via Supplier beans named shibboleth.HttpServletResponseSupplier and shibboleth.HttpServletResponseSupplier. The changed names reflect the fact that scripts and other code making use of these beans has to be modified to insert a call to the Supplier.get() method to access the actual interfaces.

In V5, all use of the old beans must be replaced by use of the new beans. This is a formulaic change.

Spring Wiring

All objects which took a p:httpServletRequest property now take a p:httpServletRequestSupplier property hence

<bean id="MyCondition" class="org.opensaml.profile.logic.IPRangePredicate" p:httpServletRequest-ref="shibboleth.HttpServletRequest" p:ranges="#{ {'192.168.1.0/24', '192.168.2.0/28'} }" />

becomes

<bean id="MyCondition" class="org.opensaml.profile.logic.IPRangePredicate" p:httpServletRequestSupplier-ref="shibboleth.HttpServletRequestSupplier" p:ranges="#{ {'192.168.1.0/24', '192.168.2.0/28'} }" />

Scripting, Velocity

If the script previously passed shibboleth.HttpServletRequest as the custom parameter it should now have shibboleth.HttpServletRequestSupplier passed instead.

Inside the script the change consists of adding a call to get() in between the original reference to the bean and the servlet method called.

Hence the (contrived) example

<bean id="exampleCondition" parent="shibboleth.Conditions.Scripted" factory-method="inlineScript" p:customObject-ref="shibboleth.HttpServletRequest"> <constructor-arg> <value> <![CDATA[ // Default return value. var result= false; // Make HTTPServletRequest object known as "request". var request = custom; // Check the client's IP address. if (request.getRemoteAddr().startsWith("192.168.42.")) { activate = true; } result; ]]> </value> </constructor-arg> </bean>

becomes

Â