How to do Spring security with authentication token in java
<p>I am building an app with spring 4 and rest web services in java.So For all web services I want to send username,password with the URL for securing the web services.Username should be "ADMIN" and password should be "ADMIN123".After hitting the service it should send  an authentication token,that value I can use for that session.</p>

<p><strong>Service class</strong></p>

<pre><code>@Path("/users")
@Service
@Component
public class UserWebservice {

@Autowired
ApplicationContext appContext = new ClassPathXmlApplicationContext("spring/config/BeanLocations.xml");  
@Autowired
UserProfileBo userProfileBo = (UserProfileBo) appContext.getBean("userProfileBo");

@Path("/")
@GET
@Produces(MediaType.APPLICATION_JSON)
public ArrayList&lt;UserProfilePojo&gt; fetchUserProfile() {
    ArrayList&lt;UserProfilePojo&gt; userProfilePojo = userProfileBo.fetch();
    return userProfilePojo;
}
</code></pre>

<p><strong>web.xml</strong></p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;

&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;
  &lt;display-name&gt;ABC&lt;/display-name&gt;
 &lt;context-param&gt;
    &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
    &lt;param-value&gt;/WEB-INF/applicationContext*.xml&lt;/param-value&gt;
&lt;/context-param&gt;
&lt;listener&gt;
   &lt;listener-class&gt;
        org.springframework.web.context.ContextLoaderListener
   &lt;/listener-class&gt;
&lt;/listener&gt; 
    &lt;servlet&gt;
    &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
    &lt;servlet-class&gt;com.sun.jersey.spi.container.servlet.ServletContainer&lt;/servlet-class&gt;
    &lt;init-param&gt;
      &lt;param-name&gt;com.sun.jersey.config.property.packages&lt;/param-name&gt;
      &lt;param-value&gt;com.abc.webservices&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;init-param&gt;
      &lt;param-name&gt;com.sun.jersey.spi.container.ContainerResponseFilters&lt;/param-name&gt;
      &lt;param-value&gt;com.sun.jersey.api.container.filter.GZIPContentEncodingFilter&lt;/param-value&gt;
    &lt;/init-param&gt;
    &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
    &lt;servlet-name&gt;Jersey REST Service&lt;/servlet-name&gt;
    &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;  
&lt;/web-app&gt;
</code></pre>

<p>So while now I am hitting <code>http://localhost:8080/ABC/users</code> and getting response.
But I want username and password should be added with the URL header for security.</p>