use of cern.modesti.user.UserImpl in project modesti by jlsalmon.
the class LdapUserDetailsMapper method mapUserFromContext.
@Override
public UserDetails mapUserFromContext(DirContextOperations context, String username, Collection<? extends GrantedAuthority> grantedAuthorities) {
UserImpl user = new UserImpl();
user.setEmployeeId(Integer.valueOf(context.getStringAttribute("employeeID")));
user.setUsername(context.getStringAttribute("cn"));
user.setFirstName(context.getStringAttribute("givenName"));
user.setLastName(context.getStringAttribute("sn"));
user.setEmail(context.getStringAttribute("mail"));
for (GrantedAuthority authority : grantedAuthorities) {
user.getAuthorities().add(new SimpleGrantedAuthority(authority.getAuthority()));
}
return user;
}
use of cern.modesti.user.UserImpl in project modesti by jlsalmon.
the class MockUserServiceImpl method loadMockUsers.
private void loadMockUsers() throws IOException {
for (Resource resource : resolver.getResources("classpath*:mock-users.txt")) {
BufferedReader reader = new BufferedReader(new InputStreamReader(resource.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
if (line.isEmpty() || line.startsWith("#")) {
continue;
}
String[] props = line.split(" ");
List<SimpleGrantedAuthority> roles = Arrays.stream(props[4].split(",")).map(SimpleGrantedAuthority::new).collect(Collectors.toList());
User user = new UserImpl(users.size() + 1, props[0], props[1], props[2], props[3], roles);
boolean store = true;
for (User existingUser : users) {
if (existingUser.getUsername().equals(user.getUsername())) {
store = false;
}
}
if (store) {
addMockUser(user);
}
}
}
}
Aggregations