How can I get the principal name, session and ideally check if the principal is authenticated with the Spring Security context inside a CXF JAX-RS webservice method receiving a call from an Android client? This is the code I am currently working with. I have commented where and what I am trying to get.
Android code to call webservice:
httpclient.getCredentialsProvider().setCredentials(
new AuthScope("192.168.1.101", 80),
new UsernamePasswordCredentials("joesmith", "mypasswd"));
HttpGet httpget = new HttpGet(WEBSERVICE_URL+"/makePayload");
httpget.setHeader("User-Agent", userAgent);
httpget.setHeader("Content-Type", "application/xml");
HttpResponse response;
try {
response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
... parse xml from response
}
CXF, Spring webservice code:
@GET
@Path("/getPayload")
@Produces("application/XML")
public Response makePayload(@Context Request request){
//Get user principal name
//Get session?
//Get Spring security context?
Payload payload = new Payload();
payload.setUsersOnline(new Long(200));
return Response.ok().entity(payload).build();
}