title: Jersey 2.x Security context does not work?
body: <p>While i am trying to create java jersey application authentication roles does not work for me.</p>
  
  <p>Java code :-</p>
  
  <pre><code>package org.student.resource;
  import javax.annotation.security.PermitAll;
  import javax.annotation.security.RolesAllowed;
  import javax.ws.rs.GET;
  import javax.ws.rs.POST;
  import javax.ws.rs.Path;
  import javax.ws.rs.ext.Provider;
  
  @Path("/resource")
  @PermitAll 
  public class Resource {
  @GET
  public String get(){
      return "GET";
  }
  
  @RolesAllowed("admin")
  @POST
  public String post(){
      return "Post content.";
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Deployment descriptor :-</p>
  
  <pre><code>&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://xmlns.jcp.org/xml/ns/javaee"
  xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
  id="WebApp_ID" version="3.1"&gt;
  &lt;display-name&gt;JerseyAuthentication&lt;/display-name&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;Application&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.glassfish.jersey.servlet.ServletContainer&lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Application&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
          &lt;web-resource-name&gt;Resource&lt;/web-resource-name&gt;
          &lt;url-pattern&gt;/resource/*&lt;/url-pattern&gt;
          &lt;http-method&gt;GET&lt;/http-method&gt;
      &lt;/web-resource-collection&gt;
  &lt;/security-constraint&gt;
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;login.html&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
   &lt;/web-app&gt;
  </code></pre>
  
  <p>Headers :-</p>
  
  <pre><code>Cache-Control →private
  Content-Language →en
  Content-Length →1010
  Content-Type →text/html;charset=utf-8
  Date →Sat, 19 Sep 2015 08:14:18 GMT
  Expires →Thu, 01 Jan 1970 05:30:00 IST
  Server →Apache-Coyote/1.1
  </code></pre>
  
  <p>Kindly some help me to do this.i want to know assign roles to resources.</p>