use of edu.hawaii.its.groupings.access.UhCasAttributes in project uhgroupings by uhawaii-system-its-ti-iam.
the class WithMockUserSecurityContextFactory method createSecurityContext.
@Override
public SecurityContext createSecurityContext(WithMockUhUser uhUser) {
Set<GrantedAuthority> authorities = new LinkedHashSet<>();
for (String role : uhUser.roles()) {
authorities.add(new SimpleGrantedAuthority(role));
}
User user = new User(uhUser.username(), uhUser.uhUuid(), authorities);
Map<String, String> attrsMap = new HashMap<>();
attrsMap.put("cn", uhUser.name());
UhAttributes attributes = new UhCasAttributes(attrsMap);
user.setAttributes(attributes);
final Authentication auth = new UsernamePasswordAuthenticationToken(user, "pw", user.getAuthorities());
SecurityContext context = SecurityContextHolder.createEmptyContext();
context.setAuthentication(auth);
return context;
}
use of edu.hawaii.its.groupings.access.UhCasAttributes in project uhgroupings by uhawaii-system-its-ti-iam.
the class WithMockAdminSecurityContextFactory method createSecurityContext.
@Override
public SecurityContext createSecurityContext(WithMockUhAdmin uhUser) {
Set<GrantedAuthority> authorities = new LinkedHashSet<>();
for (String role : uhUser.roles()) {
authorities.add(new SimpleGrantedAuthority(role));
}
User user = new User(uhUser.username(), uhUser.uhuuid(), authorities);
Map<String, String> attrsMap = new HashMap<>();
attrsMap.put("cn", uhUser.name());
UhAttributes attributes = new UhCasAttributes(attrsMap);
user.setAttributes(attributes);
final Authentication auth = new UsernamePasswordAuthenticationToken(user, "pw", user.getAuthorities());
SecurityContext context = SecurityContextHolder.createEmptyContext();
context.setAuthentication(auth);
return context;
}
Aggregations