use of org.eclipse.vorto.repository.domain.IRole in project vorto by eclipse.
the class RemoveRoleAccessPolicy method execute.
@Override
public void execute(ModelInfo model, IUserContext user, Map<String, Object> context) {
IModelPolicyManager policyManager = repositoryFactory.getPolicyManager(user.getWorkspaceId(), user.getAuthentication());
IRole role = roleToRemove.get();
LOGGER.info("Removing full access of model to " + role.getName() + " for " + model.getId());
Collection<PolicyEntry> policies = policyManager.getPolicyEntries(model.getId());
for (PolicyEntry policy : policies) {
if (policy.getPrincipalId().equals(role.getName()) && policy.getPrincipalType() == PrincipalType.Role) {
policyManager.removePolicyEntry(model.getId(), policy);
break;
}
}
}
use of org.eclipse.vorto.repository.domain.IRole in project vorto by eclipse.
the class UserDBAuthoritiesExtractor method getGrantedAuthorities.
protected List<GrantedAuthority> getGrantedAuthorities(Map<String, Object> map, String userAttr) {
String username = (String) map.get(userAttr);
User user = userService.getUser(username);
if (user == null) {
return Collections.emptyList();
}
Set<IRole> allRoles = getAllRoles(user);
if (allRoles.isEmpty()) {
allRoles.add(roleService.findAnyByName("user").orElseThrow(() -> new IllegalStateException("Role 'user' is not present.")));
}
return SpringUserUtils.toAuthorityList(allRoles);
}
Aggregations