Search in sources :

Example 1 with SecurityProvisioningGroup

use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDerivedRoleTypeServiceImpl method getProvisioningGroupForRequest.

protected SecurityProvisioningGroup getProvisioningGroupForRequest(Long securityGroupId, SecurityRequestRole requestRole) {
    SecurityProvisioningGroup provisioningGroup = null;
    Map<String, Object> provisioningSearch = new HashMap<String, Object>();
    provisioningSearch.put(KSRPropertyConstants.SECURITY_GROUP_ID, securityGroupId);
    provisioningSearch.put(KSRPropertyConstants.PROVISIONING_ROLE_ID, requestRole.getRoleId());
    provisioningSearch.put(KRADPropertyConstants.ACTIVE, Boolean.TRUE);
    List<SecurityProvisioningGroup> provisioningGroups = (List<SecurityProvisioningGroup>) KRADServiceLocator.getBusinessObjectService().findMatching(SecurityProvisioningGroup.class, provisioningSearch);
    if ((provisioningGroups != null) && !provisioningGroups.isEmpty()) {
        provisioningGroup = provisioningGroups.get(0);
    }
    return provisioningGroup;
}
Also used : SecurityProvisioningGroup(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List)

Example 2 with SecurityProvisioningGroup

use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDocumentAction method buildTabRoleIndexes.

@SuppressWarnings({ "rawtypes", "unchecked" })
protected List<SecurityRequestDocumentForm.TabRoleIndexes> buildTabRoleIndexes(final SecurityRequestDocument document) {
    final List<SecurityRequestDocumentForm.TabRoleIndexes> tabRoleIndexes = new ArrayList<SecurityRequestDocumentForm.TabRoleIndexes>();
    List sortPropertyNames = new ArrayList();
    sortPropertyNames.add(KSRPropertyConstants.SECURITY_REQUEST_DOCUMENT_TAB_ORDER);
    List<SecurityGroupTab> securityGroupTabs = document.getSecurityGroup().getSecurityGroupTabs().stream().collect(Collectors.toCollection(ArrayList::new));
    Collections.sort(securityGroupTabs, new BeanPropertyComparator(sortPropertyNames));
    for (SecurityGroupTab groupTab : securityGroupTabs) {
        SecurityRequestDocumentForm.TabRoleIndexes tabIndexes = new SecurityRequestDocumentForm.TabRoleIndexes();
        tabIndexes.setTabId(groupTab.getTabId());
        tabIndexes.setTabName(groupTab.getTabName());
        sortPropertyNames = new ArrayList();
        sortPropertyNames.add(KSRPropertyConstants.SECURITY_REQUEST_DOCUMENT_ROLE_TAB_ORDER);
        List<SecurityProvisioningGroup> provisioningGroups = groupTab.getSecurityProvisioningGroups().stream().collect(Collectors.toCollection(ArrayList::new));
        Collections.sort(provisioningGroups, new BeanPropertyComparator(sortPropertyNames));
        List<Integer> requestRoleIndexes = new ArrayList<Integer>();
        for (SecurityProvisioningGroup provisioningGroup : provisioningGroups) {
            if (provisioningGroup.isActive()) {
                int roleIndex = findSecurityRequestRoleIndex(document, provisioningGroup.getRoleId());
                if (roleIndex == -1) {
                    LOG.warn("buildTabRoleIndexes, Unable to find security request role record for role id '" + provisioningGroup.getRoleId() + "' on document '" + document.getDocumentNumber() + "'; this role will be omitted from the document");
                } else {
                    requestRoleIndexes.add(new Integer(roleIndex));
                }
            }
        }
        if (requestRoleIndexes.size() > 0) {
            tabIndexes.setRoleRequestIndexes(requestRoleIndexes);
            tabRoleIndexes.add(tabIndexes);
        }
    }
    return tabRoleIndexes;
}
Also used : SecurityGroupTab(edu.cornell.kfs.ksr.businessobject.SecurityGroupTab) BeanPropertyComparator(org.kuali.kfs.krad.util.BeanPropertyComparator) ArrayList(java.util.ArrayList) SecurityProvisioningGroup(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with SecurityProvisioningGroup

use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup in project cu-kfs by CU-CommunityApps.

the class SecurityRequestDocumentServiceImpl method buildSecurityRequestRoles.

protected void buildSecurityRequestRoles(SecurityRequestDocument document) {
    List<SecurityRequestRole> requestRoles = new ArrayList<SecurityRequestRole>();
    long roleRequestId = 1;
    for (SecurityGroupTab groupTab : document.getSecurityGroup().getSecurityGroupTabs()) {
        if (groupTab.isActive()) {
            for (SecurityProvisioningGroup provisioningGroup : groupTab.getSecurityProvisioningGroups()) {
                if (provisioningGroup.isActive()) {
                    SecurityRequestRole requestRole = new SecurityRequestRole();
                    requestRole.setDocumentNumber(document.getDocumentNumber());
                    requestRole.setRoleId(provisioningGroup.getRoleId());
                    requestRole.setRoleRequestId(Long.valueOf(roleRequestId));
                    buildSecurityRequestRoleQualifications(requestRole, document.getPrincipalId());
                    roleRequestId++;
                    requestRoles.add(requestRole);
                }
            }
        }
    }
    document.setSecurityRequestRoles(requestRoles);
}
Also used : SecurityProvisioningGroup(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup) SecurityGroupTab(edu.cornell.kfs.ksr.businessobject.SecurityGroupTab) ArrayList(java.util.ArrayList) SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole)

Example 4 with SecurityProvisioningGroup

use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup 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 5 with SecurityProvisioningGroup

use of edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup 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)

Aggregations

SecurityProvisioningGroup (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup)12 SecurityProvisioning (edu.cornell.kfs.ksr.businessobject.SecurityProvisioning)6 SecurityProvisioningGroupDependentRoles (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)3 List (java.util.List)3 SecurityGroupTab (edu.cornell.kfs.ksr.businessobject.SecurityGroupTab)2 SecurityRequestRole (edu.cornell.kfs.ksr.businessobject.SecurityRequestRole)2 SecurityRequestDocument (edu.cornell.kfs.ksr.document.SecurityRequestDocument)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 BeanPropertyComparator (org.kuali.kfs.krad.util.BeanPropertyComparator)1