use of com.thinkbiganalytics.security.rest.model.ActionGroup in project kylo by Teradata.
the class SecurityModelTransform method applyAccessControl.
public void applyAccessControl(AccessControlled domain, EntityAccessControl restModel) {
if (domain.getAllowedActions() != null && domain.getAllowedActions().getAvailableActions() != null) {
ActionGroup allowed = toActionGroup(null).apply(domain.getAllowedActions());
restModel.setAllowedActions(allowed);
}
if (domain.getRoleMemberships() != null) {
Map<String, RoleMembership> roleAssignmentMap = new HashMap<>();
domain.getRoleMemberships().stream().forEach(membership -> {
String systemRoleName = membership.getRole().getSystemName();
String name = membership.getRole().getTitle();
String desc = membership.getRole().getDescription();
membership.getMembers().stream().forEach(member -> {
roleAssignmentMap.putIfAbsent(systemRoleName, new RoleMembership(systemRoleName, name, desc));
RoleMembership accessRoleAssignment = roleAssignmentMap.get(systemRoleName);
if (member instanceof UsernamePrincipal) {
accessRoleAssignment.addUser(member.getName());
} else {
accessRoleAssignment.addGroup(member.getName());
}
});
});
restModel.setRoleMemberships(Lists.newArrayList(roleAssignmentMap.values()));
}
Principal owner = domain.getOwner();
Optional<User> userPrincipal = userService.getUser(owner.getName());
if (userPrincipal.isPresent()) {
restModel.setOwner(userPrincipal.get());
}
}
use of com.thinkbiganalytics.security.rest.model.ActionGroup in project kylo by Teradata.
the class SecurityModelTransform method addHierarchy.
//
// public void addAction(PermissionsChange change, com.thinkbiganalytics.security.action.Action domainAction) {
// ActionGroup actionSet = new ActionGroup("");
// addHierarchy(actionSet, domainAction.getHierarchy().iterator());
// }
private void addHierarchy(ActionGroup actionSet, Iterator<com.thinkbiganalytics.security.action.Action> itr) {
if (itr.hasNext()) {
com.thinkbiganalytics.security.action.Action domainAction = itr.next();
Action subAction = actionSet.getAction(domainAction.getSystemName()).map(sa -> sa).orElseGet(() -> {
Action newAction = new Action(domainAction.getSystemName());
actionSet.addAction(newAction);
return newAction;
});
addHierarchy(subAction, itr);
}
}
use of com.thinkbiganalytics.security.rest.model.ActionGroup in project kylo by Teradata.
the class EntityLevelAccessIT method grantServiceActionToAnalysts.
private void grantServiceActionToAnalysts(Action action) {
LOG.debug("EntityLevelAccessIT.grantServiceActionToAnalysts");
runAs(ADMIN);
ActionGroup actions = new ActionGroup(SERVICES);
actions.addAction(action);
PermissionsChange permissionsChange = new PermissionsChange(PermissionsChange.ChangeType.REPLACE, actions);
permissionsChange.addGroup(GROUP_ANALYSTS);
permissionsChange.union(getServicePermissions(GROUP_ANALYSTS));
setServicePermissions(permissionsChange);
}
use of com.thinkbiganalytics.security.rest.model.ActionGroup in project kylo by Teradata.
the class EntityLevelAccessIT method resetServicePermissionsForAnalysts.
private void resetServicePermissionsForAnalysts() {
LOG.debug("EntityLevelAccessIT.resetServicePermissionsForAnalysts");
runAs(ADMIN);
ActionGroup actions = new ActionGroup(SERVICES);
PermissionsChange permissionsChange = new PermissionsChange(PermissionsChange.ChangeType.REPLACE, actions);
permissionsChange.addGroup(GROUP_ANALYSTS);
setServicePermissions(permissionsChange);
}
Aggregations