use of cern.modesti.user.User in project modesti by jlsalmon.
the class LdapUserDetailsMapper method doMapFromContext.
@Override
protected User doMapFromContext(DirContextOperations context) {
List<GrantedAuthority> authorities = new ArrayList<>();
if (context.attributeExists("memberOf")) {
for (Object attr : context.getObjectAttributes("memberOf")) {
String group = (String) attr;
if (group.contains("e-groups")) {
group = group.split(",")[0].split("=")[1];
authorities.add(new SimpleGrantedAuthority(group.toLowerCase()));
}
}
}
return (User) mapUserFromContext(context, context.getStringAttribute("cn"), authorities);
}
Aggregations