use of org.obiba.mica.security.Roles in project mica2 by obiba.
the class CurrentSessionResource method get.
@GET
public Mica.SessionDto get() {
Subject subject = SecurityUtils.getSubject();
Mica.SessionDto.Builder builder = //
Mica.SessionDto.newBuilder().setUsername(subject.getPrincipal().toString());
//
List<String> roles = //
Arrays.asList(Roles.MICA_ADMIN, Roles.MICA_REVIEWER, Roles.MICA_EDITOR, Roles.MICA_DAO, Roles.MICA_USER);
boolean[] result = subject.hasRoles(roles);
IntStream.range(0, result.length).filter(i -> result[i]).forEach(i -> builder.addRoles(roles.get(i)));
return builder.build();
}
Aggregations