Search in sources :

Example 11 with User

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);
}
Also used : SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) User(cern.modesti.user.User) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) GrantedAuthority(org.springframework.security.core.GrantedAuthority)

Aggregations

User (cern.modesti.user.User)11 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)3 Request (cern.modesti.request.Request)2 NotAuthorisedException (cern.modesti.workflow.task.NotAuthorisedException)2 TaskAction (cern.modesti.workflow.task.TaskAction)2 Resource (org.springframework.hateoas.Resource)2 ResponseEntity (org.springframework.http.ResponseEntity)2 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)2 Authentication (org.springframework.security.core.Authentication)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 RequestProvider (cern.modesti.plugin.RequestProvider)1 UnsupportedRequestException (cern.modesti.plugin.UnsupportedRequestException)1 Point (cern.modesti.point.Point)1 PointImpl (cern.modesti.point.PointImpl)1 RequestHistoryServiceImpl (cern.modesti.request.history.RequestHistoryServiceImpl)1 UserImpl (cern.modesti.user.UserImpl)1 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 Task (org.activiti.engine.task.Task)1 DateTime (org.joda.time.DateTime)1