Search in sources :

Example 1 with AuthenticationManager

use of com.autentia.tnt.manager.security.AuthenticationManager in project TNTConcept by autentia.

the class SpringUtilsForTesting method loadPrincipalInSecurityContext.

public static void loadPrincipalInSecurityContext(String username) {
    AuthenticationManager authManager = (AuthenticationManager) getSpringBean("userDetailsService");
    Principal principal = (Principal) authManager.loadUserByUsername(username);
    Authentication auth = new UsernamePasswordAuthenticationToken(principal, principal.getUser().getPassword(), principal.getAuthorities());
    SecurityContextHolder.getContext().setAuthentication(auth);
}
Also used : AuthenticationManager(com.autentia.tnt.manager.security.AuthenticationManager) Authentication(org.acegisecurity.Authentication) UsernamePasswordAuthenticationToken(org.acegisecurity.providers.UsernamePasswordAuthenticationToken) Principal(com.autentia.tnt.manager.security.Principal)

Aggregations

AuthenticationManager (com.autentia.tnt.manager.security.AuthenticationManager)1 Principal (com.autentia.tnt.manager.security.Principal)1 Authentication (org.acegisecurity.Authentication)1 UsernamePasswordAuthenticationToken (org.acegisecurity.providers.UsernamePasswordAuthenticationToken)1