Usefull and thus noted:
In one of my current workprojects I had a registrationform the user filled. After formvalidation, I wanted to login the user automatically. This can be achieved in Spring / Acegi quite easy:
User user = createUser(); final RememberMeAuthenticationToken auth = new RememberMeAuthenticationToken(webKey, userAccount.getUser(), userAccount.getUser().getAuthorities()); auth.setAuthenticated(true); SecurityContextHolder.getContext().setAuthentication(auth);
Also logging user out (after database new creattion or session invalidation):
SecurityContextHolder.getContext().setAuthentication(null);

