After a user creates their account, I want to log that user on automatically.
I have standard form logins being handled by Springs filter on /postlogin.
Just to illustrate @David's answer (simplified as much as possible):
@POST
@Path("login")
public Response login(@FormParam("login") String login, @FormParam("pass") String pass)
{
if (yourCheck(login, pass))
{
List authorities = new ArrayList();
authorities.add(new SimpleGrantedAuthority("ROLE_USER"));
Authentication auth = new UsernamePasswordAuthenticationToken(login, pass, authorities);
SecurityContextHolder.getContext().setAuthentication(auth);
// IMPORTANT: Do not pass any data in the response body
// show empty 200 page (suitable for REST clients)
return Response.ok().build();
// or redirect to your home page (for web UI)
return Response.temporaryRedirect(new URI("/homepage/")).build();
}
else
{
return Response.status(Status.UNAUTHORIZED).build();
}
}