users@jersey.java.net

[Jersey] Interception of <security-constraint> in ContainerRequestFilter?

From: Martynas Jusevi?ius <martynas_at_graphity.org>
Date: Tue, 3 Sep 2013 11:02:39 +0200

Hey,

I have a <security-constraint> config in web.xml that asks for BASIC
authentication on /admin/* path (follows bellow).

The user is prompted to enter username/password, as expected, but
cannot login as the credentials are not defined anywhere. How can I
intercept this and do my own authentication, e.g. using
SecurityContext in ContainerRequestFilter? Can't figure out how/if
it's related to <security-constraint>.

<security-constraint>
<web-resource-collection>
   <web-resource-name>Administration</web-resource-name>
   <url-pattern>/admin/*</url-pattern>
   <http-method>GET</http-method>
   <http-method>POST</http-method>
   <http-method>HEAD</http-method>
   <http-method>PUT</http-method>
   <http-method>OPTIONS</http-method>
   <http-method>TRACE</http-method>
   <http-method>DELETE</http-method>
</web-resource-collection>
<auth-constraint>
   <role-name>admin</role-name>
</auth-constraint>
    </security-constraint>
    <login-config>
<auth-method>BASIC</auth-method>
<realm-name>jaxrs</realm-name>
    </login-config>
    <security-role>
<role-name>admin</role-name>
    </security-role>

Martynas
graphityhq.com