Search in sources :

Example 1 with SecurityProvisioning

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;
}
Also used : ConcreteKeyValue(org.kuali.kfs.core.api.util.ConcreteKeyValue) SecurityGroupTab(edu.cornell.kfs.ksr.businessobject.SecurityGroupTab) ConcreteKeyValue(org.kuali.kfs.core.api.util.ConcreteKeyValue) KeyValue(org.kuali.kfs.core.api.util.KeyValue) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MaintenanceDocument(org.kuali.kfs.kns.document.MaintenanceDocument) Document(org.kuali.kfs.krad.document.Document) SecurityProvisioning(edu.cornell.kfs.ksr.businessobject.SecurityProvisioning) KualiDocumentFormBase(org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase) KualiForm(org.kuali.kfs.kns.web.struts.form.KualiForm)

Example 2 with SecurityProvisioning

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());
            }
        }
    }
}
Also used : SecurityProvisioningGroup(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup) SecurityProvisioningGroupDependentRoles(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles) SecurityProvisioning(edu.cornell.kfs.ksr.businessobject.SecurityProvisioning)

Example 3 with SecurityProvisioning

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;
}
Also used : SecurityProvisioningGroup(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup) HashMap(java.util.HashMap) SecurityProvisioning(edu.cornell.kfs.ksr.businessobject.SecurityProvisioning)

Example 4 with SecurityProvisioning

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;
}
Also used : SecurityProvisioningGroup(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup) SecurityProvisioningGroupDependentRoles(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles) SecurityProvisioning(edu.cornell.kfs.ksr.businessobject.SecurityProvisioning)

Example 5 with SecurityProvisioning

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);
    }
}
Also used : HashMap(java.util.HashMap) SecurityProvisioning(edu.cornell.kfs.ksr.businessobject.SecurityProvisioning)

Aggregations

SecurityProvisioning (edu.cornell.kfs.ksr.businessobject.SecurityProvisioning)8 SecurityProvisioningGroup (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup)6 HashMap (java.util.HashMap)3 SecurityProvisioningGroupDependentRoles (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles)2 SecurityGroupTab (edu.cornell.kfs.ksr.businessobject.SecurityGroupTab)1 ArrayList (java.util.ArrayList)1 ConcreteKeyValue (org.kuali.kfs.core.api.util.ConcreteKeyValue)1 KeyValue (org.kuali.kfs.core.api.util.KeyValue)1 KimTypeService (org.kuali.kfs.kim.framework.type.KimTypeService)1 RoleLite (org.kuali.kfs.kim.impl.role.RoleLite)1 KimType (org.kuali.kfs.kim.impl.type.KimType)1 MaintenanceDocument (org.kuali.kfs.kns.document.MaintenanceDocument)1 KualiDocumentFormBase (org.kuali.kfs.kns.web.struts.form.KualiDocumentFormBase)1 KualiForm (org.kuali.kfs.kns.web.struts.form.KualiForm)1 Document (org.kuali.kfs.krad.document.Document)1