Simulate login from spring web mvc controller
code as below: [code="java"] List grantedAuthorities = new ArrayList(); grantedAuthorities.add(new GrantedAuthorityImpl("USER")); UsernamePasswordAuthenticationToken uat = new UsernamePasswordAuthenticationToken( "john", "admin", grantedAuthorities); uat.setDetails(user); SecurityContext context = SecurityContextHolder.getContext(); Authentication userAuth = authenticationManager.authenticate(uat); context.setAuthentication(userAuth); [/code]