use of controllers.tenant.AclEntryForm in project coprhd-controller by CoprHD.
the class ACLUtils method validateAclEntries.
public static void validateAclEntries(String fieldName, List<AclEntryForm> aclEntries) {
for (int i = 0; i < aclEntries.size(); i++) {
AclEntryForm aclEntryForm = aclEntries.get(i);
if (aclEntryForm != null) {
String aclEntryPath = fieldName + "[" + i + "]";
String aclNamePath = aclEntryPath + ".aclName";
if (StringUtils.isBlank(aclEntryForm.aclName)) {
Validation.addError(aclNamePath, "security.accessControlList.aclName.required");
}
if (StringUtils.isBlank(aclEntryForm.access)) {
String fieldPath = aclEntryPath + ".access";
Validation.addError(fieldPath, "security.accessControlList.access.required");
}
if (StringUtils.isBlank(aclEntryForm.type)) {
String fieldPath = aclEntryPath + ".type";
Validation.addError(fieldPath, "security.accessControlList.type.required");
} else if (StringUtils.isNotBlank(aclEntryForm.aclName)) {
RoleAssignmentType type = RoleAssignmentType.valueOf(aclEntryForm.type);
if (RoleAssignmentType.GROUP.name().equals(aclEntryForm.type)) {
// All the required validations done in isValidPrincipal().
if (ACLUtils.isValidPrincipal(type, aclEntryForm.aclName) == false) {
Validation.addError(aclNamePath, "security.accessControlList.group.notvalid");
}
} else if (RoleAssignmentType.USER.name().equals(aclEntryForm.type)) {
if (LocalUser.isLocalUser(aclEntryForm.aclName)) {
Validation.addError(aclNamePath, "security.accessControlList.localuser.notpermitted");
} else if (validateDomain(aclEntryForm.aclName) == false) {
Validation.addError(aclNamePath, "security.accessControlList.domain.required");
} else if (validateAuthProviderDomain(aclEntryForm.aclName) == false) {
Validation.addError(aclNamePath, "security.accessControlList.domain.notfound");
} else if (ACLUtils.isValidPrincipal(type, aclEntryForm.aclName) == false) {
Validation.addError(aclNamePath, "security.accessControlList.user.notvalid");
}
}
}
}
}
}
use of controllers.tenant.AclEntryForm in project coprhd-controller by CoprHD.
the class ACLUtils method convertToAclEntryForms.
public static List<AclEntryForm> convertToAclEntryForms(List<ACLEntry> acls) {
List<AclEntryForm> aclEntries = Lists.newArrayList();
if (acls != null && acls.isEmpty() == false) {
for (ACLEntry acl : acls) {
for (String role : acl.getAces()) {
AclEntryForm entry = new AclEntryForm();
if (StringUtils.isNotBlank(acl.getGroup())) {
entry.type = RoleAssignmentType.GROUP.name();
entry.aclName = acl.getGroup();
} else if (StringUtils.isNotBlank(acl.getSubjectId())) {
entry.type = RoleAssignmentType.USER.name();
entry.aclName = acl.getSubjectId();
}
entry.access = role;
aclEntries.add(entry);
}
}
}
return aclEntries;
}
Aggregations