The map key to DelegatingAuthenticationEntryPoint will be a reference to the RequestMatcher instead of a String (the String way of creating a RequestMatcher cannot match on the path). More specifically...write a RequestMatcher that matches based upon the logic you want. You will also need an entry point for your Restful service (my example implies returning a 401, but you can do whatever you want). Below is psedocode:
Code:
public class UrlRequestMatcher implements RequestMatcher {
// see DefaultFilterInvocationSecurityMetadataSource
// for example on how to use UrlMatcher
private UrlMatcher matcher;
... implement the method for RequestMatcher
}
public class Http401EntryPoint implements AuthenticationEntryPoint {
... implement the methods
}
Wire it up. Below is psedo config:
Code:
<sec:http ... entry-point-ref="entryPoint">
...
</sec:http>
<bean id="entryPoint" class="org.springframework.security.web.authentication.DelegatingAuthenticationEntryPoint">
<constructor-arg>
<map>
<!-- add as many entries as you need -->
<entry>
<key>
<bean class="org.example.UrlRequestMatcher"/>
</key>
<bean class="org.example.Http401EntryPoint"/>
</entry>
</map>
</constructor-arg>
<property name="defaultEntryPoint">
<!-- if its not a restful url do regular login -->
<bean class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint" p:loginFormUrl="/login"/>
</property>
</bean>
Cheers,