use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioning in project cu-kfs by CU-CommunityApps.
the class SecurityGroupTabValuesFinder method getKeyValues.
@Override
public List<KeyValue> getKeyValues() {
List<KeyValue> keyValues = new ArrayList<KeyValue>();
Long securityGroupID = null;
KualiForm form = KNSGlobalVariables.getKualiForm();
if ((form != null) && (form instanceof KualiDocumentFormBase)) {
Document doc = ((KualiDocumentFormBase) form).getDocument();
if (doc instanceof MaintenanceDocument) {
SecurityProvisioning securityProvisioning = (SecurityProvisioning) ((MaintenanceDocument) doc).getDocumentDataObject();
securityGroupID = securityProvisioning.getSecurityGroupId();
}
}
Collection<SecurityGroupTab> tabs;
if (securityGroupID != null) {
Map<String, Object> map = new HashMap<String, Object>();
map.put(KSRPropertyConstants.SECURITY_GROUP_ID, securityGroupID);
tabs = SpringContext.getBean(BusinessObjectService.class).findMatching(SecurityGroupTab.class, map);
for (SecurityGroupTab tab : tabs) {
keyValues.add(new ConcreteKeyValue(tab.getTabId().toString(), tab.getTabOrder() + " - " + tab.getTabName()));
}
}
return keyValues;
}
use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioning in project cu-kfs by CU-CommunityApps.
the class SecurityProvisioningMaintainable method prepareForSave.
/**
* Updates the security group IDs and provisioning IDs on the related
* provisioning-group and dependent-role objects accordingly.
*/
@Override
public void prepareForSave() {
super.prepareForSave();
SecurityProvisioning provisioning = (SecurityProvisioning) getDataObject();
for (SecurityProvisioningGroup provisioningGroup : provisioning.getSecurityProvisioningGroups()) {
provisioningGroup.setSecurityGroupId(provisioning.getSecurityGroupId());
if (CollectionUtils.isNotEmpty(provisioningGroup.getDependentRoles())) {
for (SecurityProvisioningGroupDependentRoles dependentRole : provisioningGroup.getDependentRoles()) {
dependentRole.setProvisioningId(provisioningGroup.getProvisioningId());
}
}
}
}
use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioning in project cu-kfs by CU-CommunityApps.
the class SecurityProvisioningGroupRule method dataDictionaryValidate.
@Override
protected boolean dataDictionaryValidate(MaintenanceDocument document) {
boolean success = true;
Map<String, SecurityProvisioningGroup> provisioningMap = new HashMap<String, SecurityProvisioningGroup>();
SecurityProvisioning securityProvisioning = (SecurityProvisioning) document.getDocumentDataObject();
GlobalVariables.getMessageMap().addToErrorPath(MaintenanceDocumentRuleBase.MAINTAINABLE_ERROR_PATH);
// Validate the SecurityProvisioningGroup and check it for duplicates
for (int i = 0; i < securityProvisioning.getSecurityProvisioningGroups().size(); i++) {
SecurityProvisioningGroup securityProvisioningGroup = securityProvisioning.getSecurityProvisioningGroups().get(i);
success &= validateSecurityProvisioningGroup(document, securityProvisioningGroup, i);
if (!securityProvisioningGroup.isActive()) {
continue;
}
success &= isDuplicateSecurityProvisioningGroup(document, securityProvisioningGroup, i);
if (StringUtils.isNotBlank(securityProvisioningGroup.getRoleId())) {
provisioningMap.put(securityProvisioningGroup.getRoleId(), securityProvisioningGroup);
}
// Validate the SecurityProvisioningGroup and check it for duplicates.
for (int j = 0; j < securityProvisioningGroup.getDependentRoles().size(); j++) {
success &= validateDependentRole(securityProvisioningGroup.getDependentRoles().get(j), i, j);
success &= isDependentRoleUniqueForGroup(document, securityProvisioningGroup.getDependentRoles().get(j), i, j);
success &= hasSecurityProvisioningGroup(document, securityProvisioningGroup.getDependentRoles().get(j), i, j);
}
}
if (success) {
// Loop through each SecurityProvisioningGroup to find a circular reference
for (int i = 0; i < securityProvisioning.getSecurityProvisioningGroups().size(); i++) {
SecurityProvisioningGroup securityProvisioningGroup = securityProvisioning.getSecurityProvisioningGroups().get(i);
if (!securityProvisioningGroup.isActive() || StringUtils.isBlank(securityProvisioningGroup.getRoleId())) {
continue;
}
Map<String, SecurityProvisioningGroup> provisioningMapTemp = new HashMap<String, SecurityProvisioningGroup>();
provisioningMapTemp.putAll(provisioningMap);
String roleStr = buildDependentString(securityProvisioningGroup.getRoleId(), provisioningMapTemp);
roleStr = StringUtils.strip(roleStr, ",");
int matches = StringUtils.countMatches(roleStr, "|" + securityProvisioningGroup.getRoleId() + "|");
if (matches > 1) {
success = false;
String errorPath = buildPropertyPath(buildIndexedProperty(KSRConstants.SECURITY_PROVISIONING_GROUPS, i), KSRPropertyConstants.SECURITY_PROVISIONING_GROUP_ROLE_NAME);
GlobalVariables.getMessageMap().putError(errorPath, KSRKeyConstants.ERROR_SECURITY_PROVISIONING_GROUP_CIRCULAR_REFERENCE, getRoleNameForErrorMessage(securityProvisioningGroup.getRole()));
}
}
}
GlobalVariables.getMessageMap().removeFromErrorPath(MaintenanceDocumentRuleBase.MAINTAINABLE_ERROR_PATH);
return super.dataDictionaryValidate(document) && success;
}
use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioning in project cu-kfs by CU-CommunityApps.
the class SecurityProvisioningGroupRule method isDependentRoleUniqueForGroup.
private boolean isDependentRoleUniqueForGroup(MaintenanceDocument document, SecurityProvisioningGroupDependentRoles dependentRole, int index, int indexRole) {
boolean success = true;
SecurityProvisioning securityProvisioning = (SecurityProvisioning) document.getDocumentDataObject();
List<SecurityProvisioningGroup> securityProvisioningGroupList = securityProvisioning.getSecurityProvisioningGroups();
SecurityProvisioningGroup securityProvisioningGroup = securityProvisioningGroupList.get(index);
for (int i = 0; i < securityProvisioningGroup.getDependentRoles().size(); i++) {
SecurityProvisioningGroupDependentRoles tempDependentRole = securityProvisioningGroup.getDependentRoles().get(i);
if (i == indexRole || StringUtils.isBlank(tempDependentRole.getRoleId())) {
continue;
}
if (StringUtils.equals(tempDependentRole.getRoleId(), dependentRole.getRoleId())) {
success = false;
String errorPath = (indexRole < 0 || index < 0) ? KSRPropertyConstants.PROVISIONING_ROLE_ID : buildPropertyPath(buildIndexedProperty(KSRConstants.SECURITY_PROVISIONING_GROUPS, index), buildIndexedProperty(KSRConstants.DEPENDENT_ROLES, indexRole), KSRPropertyConstants.PROVISIONING_ROLE_ID);
if ((indexRole == -1) || (indexRole > i)) {
GlobalVariables.getMessageMap().putError(errorPath, KSRKeyConstants.ERROR_SECURITY_PROVISIONING_GROUP_DEPENDENT_ROLE_UNIQUE, getRoleNameForErrorMessage(dependentRole.getRole()));
}
}
}
return success;
}
use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioning in project cu-kfs by CU-CommunityApps.
the class SecurityGroupMaintainable method createSecurityProvisioningEntryIfItDoesNotExist.
private void createSecurityProvisioningEntryIfItDoesNotExist(SecurityGroup securityGroup) {
Map<String, Object> hashMap = new HashMap<String, Object>();
hashMap.put(KSRPropertyConstants.SECURITY_GROUP_ID, securityGroup.getSecurityGroupId());
Collection<SecurityProvisioning> securityProvisioningDB = getBusinessObjectService().findMatching(SecurityProvisioning.class, hashMap);
// if record doesn't exist, create it
if (CollectionUtils.isEmpty(securityProvisioningDB)) {
SecurityProvisioning securityProvisioning = new SecurityProvisioning();
securityProvisioning.setSecurityGroupId(securityGroup.getSecurityGroupId());
getBusinessObjectService().save(securityProvisioning);
}
}
Aggregations