use of com.epam.ta.reportportal.database.entity.UserRoleDetails in project service-authorization by reportportal.
the class DatabaseUserDetailsService method loadUserByUsername.
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
UserRoleDetails userEntity = userRepository.aggregateUserProjects(username.toLowerCase());
if (null == userEntity || null == userEntity.getUser()) {
throw new UsernameNotFoundException("Username '" + username + "' not found");
}
String login = userEntity.getUser().getLogin();
String password = userEntity.getUser().getPassword() == null ? "" : userEntity.getUser().getPassword();
org.springframework.security.core.userdetails.User u = new org.springframework.security.core.userdetails.User(login, password, true, true, true, true, AuthUtils.AS_AUTHORITIES.apply(userEntity.getUser().getRole()));
return new ReportPortalUser(u, userEntity.getProjects().stream().collect(Collectors.toMap(UserRoleDetails.ProjectDetails::getProject, UserRoleDetails.ProjectDetails::getProjectRole)));
}
Aggregations