use of org.apache.ranger.plugin.model.RangerRole in project ranger by apache.
the class RolePredicateUtil method addPredicateForPartialRoleName.
private Predicate addPredicateForPartialRoleName(final String roleNamePartial, List<Predicate> predicates) {
if (StringUtils.isEmpty(roleNamePartial)) {
return null;
}
Predicate ret = new Predicate() {
@Override
public boolean evaluate(Object object) {
if (object == null) {
return false;
}
boolean ret = false;
if (object instanceof RangerRole) {
RangerRole role = (RangerRole) object;
ret = StringUtils.containsIgnoreCase(role.getName(), roleNamePartial);
if (!ret) {
List<RangerRole.RoleMember> roles = role.getRoles();
for (RangerRole.RoleMember member : roles) {
ret = StringUtils.containsIgnoreCase(role.getName(), roleNamePartial);
if (ret) {
break;
}
}
}
}
return ret;
}
};
if (predicates != null) {
predicates.add(ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerRole in project ranger by apache.
the class RolePredicateUtil method addPredicateForRoleId.
private Predicate addPredicateForRoleId(final String roleId, List<Predicate> predicates) {
if (StringUtils.isEmpty(roleId)) {
return null;
}
Predicate ret = new Predicate() {
@Override
public boolean evaluate(Object object) {
if (object == null) {
return false;
}
boolean ret = false;
if (object instanceof RangerRole) {
RangerRole role = (RangerRole) object;
ret = StringUtils.equals(roleId, role.getId().toString());
}
return ret;
}
};
if (predicates != null) {
predicates.add(ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerRole in project ranger by apache.
the class RolePredicateUtil method addPredicateForPartialUserName.
private Predicate addPredicateForPartialUserName(final String userNamePartial, List<Predicate> predicates) {
if (StringUtils.isEmpty(userNamePartial)) {
return null;
}
Predicate ret = new Predicate() {
@Override
public boolean evaluate(Object object) {
if (object == null) {
return false;
}
boolean ret = false;
if (object instanceof RangerRole) {
RangerRole role = (RangerRole) object;
List<RangerRole.RoleMember> users = role.getUsers();
for (RangerRole.RoleMember member : users) {
ret = StringUtils.containsIgnoreCase(member.getName(), userNamePartial);
if (ret) {
break;
}
}
}
return ret;
}
};
if (predicates != null) {
predicates.add(ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerRole in project ranger by apache.
the class RolePredicateUtil method addPredicateForGroupName.
private Predicate addPredicateForGroupName(final String groupName, List<Predicate> predicates) {
if (StringUtils.isEmpty(groupName)) {
return null;
}
Predicate ret = new Predicate() {
@Override
public boolean evaluate(Object object) {
if (object == null) {
return false;
}
boolean ret = false;
if (object instanceof RangerRole) {
RangerRole role = (RangerRole) object;
List<RangerRole.RoleMember> groups = role.getGroups();
for (RangerRole.RoleMember member : groups) {
ret = StringUtils.equals(member.getName(), groupName);
if (ret) {
break;
}
}
}
return ret;
}
};
if (predicates != null) {
predicates.add(ret);
}
return ret;
}
use of org.apache.ranger.plugin.model.RangerRole in project ranger by apache.
the class RangerRolesUtil method addContainedRoles.
private void addContainedRoles(Set<RangerRole> allRoles, Set<RangerRole> roles, RangerRole role) {
List<RangerRole.RoleMember> roleMembers = role.getRoles();
for (RangerRole.RoleMember roleMember : roleMembers) {
RangerRole containedRole = getContainedRole(roles, roleMember.getName());
if (containedRole != null && !allRoles.contains(containedRole)) {
allRoles.add(containedRole);
addContainedRoles(allRoles, roles, containedRole);
}
}
}
Aggregations