Search in sources :

Example 1 with UserMap

use of org.springframework.security.userdetails.memory.UserMap in project gocd by gocd.

the class FileAuthenticationProvider method retrieveUser.

protected UserDetails retrieveUser(String username, UsernamePasswordAuthenticationToken authentication) throws AuthenticationException {
    final String passwordFilePath = goConfigService.security().passwordFileConfig().path();
    try {
        UserMap userMap = UserMapEditor.addUsersFromProperties(new UserMap(), addDummyRoleToPropertiesIfRequired(stripShaFromPasswordsIfRequired(loadPasswordFile(passwordFilePath))));
        final UserDetails details = userMap.getUser(username);
        return userStrippedOfAnyAuthoritiesSpecifiedInFile(username, details);
    } catch (IOException e) {
        throw new UsernameNotFoundException("Trying to authenticate user " + username + " but could not open file: " + passwordFilePath);
    }
}
Also used : UsernameNotFoundException(org.springframework.security.userdetails.UsernameNotFoundException) UserMap(org.springframework.security.userdetails.memory.UserMap) UserDetails(org.springframework.security.userdetails.UserDetails) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 UserDetails (org.springframework.security.userdetails.UserDetails)1 UsernameNotFoundException (org.springframework.security.userdetails.UsernameNotFoundException)1 UserMap (org.springframework.security.userdetails.memory.UserMap)1