Search in sources :

Example 11 with SecurityProvisioningGroup

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

the class SecurityProvisioningGroupRule method validateSecurityProvisioningGroup.

@SuppressWarnings("deprecation")
private boolean validateSecurityProvisioningGroup(MaintenanceDocument document, SecurityProvisioningGroup securityProvisioningGroup, int index) {
    boolean success = true;
    RoleLite role = StringUtils.isBlank(securityProvisioningGroup.getRoleId()) ? null : getRoleService().getRoleWithoutMembers(securityProvisioningGroup.getRoleId());
    if (role != null) {
        KimType kimType = getKimTypeInfoService().getKimType(role.getKimTypeId());
        KimTypeService kimTypeService = getKimTypeService(kimType);
        if (kimTypeService != null && kimTypeService instanceof org.kuali.kfs.kns.kim.role.DerivedRoleTypeServiceBase) {
            success = false;
            String errorPath = (index < 0) ? KSRPropertyConstants.SECURITY_PROVISIONING_GROUP_ROLE_NAME : buildPropertyPath(buildIndexedProperty(KSRConstants.SECURITY_PROVISIONING_GROUPS, index), KSRPropertyConstants.SECURITY_PROVISIONING_GROUP_ROLE_NAME);
            GlobalVariables.getMessageMap().putError(errorPath, KSRKeyConstants.ERROR_SECURITY_PROVISIONING_GROUP_ROLE_DERIVED, getRoleNameForErrorMessage(securityProvisioningGroup.getRole()));
        }
    }
    if (success) {
        // check second against last.
        if (StringUtils.isNotBlank(securityProvisioningGroup.getDistributedAuthorizerRoleId())) {
            if (StringUtils.isNotBlank(securityProvisioningGroup.getAdditionalAuthorizerRoleId())) {
                if (securityProvisioningGroup.getDistributedAuthorizerRoleId().equals(securityProvisioningGroup.getAdditionalAuthorizerRoleId())) {
                    success = false;
                    String errorPath = (index < 0) ? KSRPropertyConstants.SECURITY_PROVISIONING_GROUP_ADD_AUTH_ROLE_ID : buildPropertyPath(buildIndexedProperty(KSRConstants.SECURITY_PROVISIONING_GROUPS, index), KSRPropertyConstants.SECURITY_PROVISIONING_GROUP_ADD_AUTH_ROLE_ID);
                    GlobalVariables.getMessageMap().putError(errorPath, KSRKeyConstants.ERROR_SECURITY_PROVISIONING_GROUP_AUTH_UNIQUE, new String[] { KSRConstants.SECURITY_PROVISIONING_GROUP_ADD_AUTH_LBL, KSRConstants.SECURITY_PROVISIONING_GROUP_DIST_AUTH_LBL, KSRConstants.SECURITY_PROVISIONING_GROUP_CENT_AUTH_LBL });
                }
            }
            if (StringUtils.isNotBlank(securityProvisioningGroup.getCentralAuthorizerRoleId())) {
                if (securityProvisioningGroup.getDistributedAuthorizerRoleId().equals(securityProvisioningGroup.getCentralAuthorizerRoleId())) {
                    success = false;
                    String errorPath = (index < 0) ? KSRPropertyConstants.SECURITY_PROVISIONING_GROUP_CENT_AUTH_ROLE_ID : buildPropertyPath(buildIndexedProperty(KSRConstants.SECURITY_PROVISIONING_GROUPS, index), KSRPropertyConstants.SECURITY_PROVISIONING_GROUP_CENT_AUTH_ROLE_ID);
                    GlobalVariables.getMessageMap().putError(errorPath, KSRKeyConstants.ERROR_SECURITY_PROVISIONING_GROUP_AUTH_UNIQUE, new String[] { KSRConstants.SECURITY_PROVISIONING_GROUP_CENT_AUTH_LBL, KSRConstants.SECURITY_PROVISIONING_GROUP_DIST_AUTH_LBL, KSRConstants.SECURITY_PROVISIONING_GROUP_ADD_AUTH_LBL });
                }
            }
        }
        if (StringUtils.isNotBlank(securityProvisioningGroup.getAdditionalAuthorizerRoleId())) {
            if (StringUtils.isNotBlank(securityProvisioningGroup.getCentralAuthorizerRoleId())) {
                if (securityProvisioningGroup.getAdditionalAuthorizerRoleId().equals(securityProvisioningGroup.getCentralAuthorizerRoleId())) {
                    success = false;
                    String errorPath = (index < 0) ? KSRPropertyConstants.SECURITY_PROVISIONING_GROUP_CENT_AUTH_ROLE_ID : buildPropertyPath(buildIndexedProperty(KSRConstants.SECURITY_PROVISIONING_GROUPS, index), KSRPropertyConstants.SECURITY_PROVISIONING_GROUP_CENT_AUTH_ROLE_ID);
                    GlobalVariables.getMessageMap().putError(errorPath, KSRKeyConstants.ERROR_SECURITY_PROVISIONING_GROUP_AUTH_UNIQUE, new String[] { KSRConstants.SECURITY_PROVISIONING_GROUP_CENT_AUTH_LBL, KSRConstants.SECURITY_PROVISIONING_GROUP_DIST_AUTH_LBL, KSRConstants.SECURITY_PROVISIONING_GROUP_ADD_AUTH_LBL });
                }
            }
        }
    }
    SecurityProvisioning securityProvisioning = (SecurityProvisioning) document.getDocumentDataObject();
    List<SecurityProvisioningGroup> securityProvisioningGroupList = securityProvisioning.getSecurityProvisioningGroups();
    for (int i = 0; i < securityProvisioningGroupList.size(); i++) {
        if (i == index) {
            continue;
        }
        if (securityProvisioningGroup.getTabId() == null) {
            break;
        }
        if (securityProvisioningGroup.getTabId().equals(securityProvisioningGroupList.get(i).getTabId())) {
            if (securityProvisioningGroup.getRoleTabOrder() != null && securityProvisioningGroup.getRoleTabOrder().equals(securityProvisioningGroupList.get(i).getRoleTabOrder())) {
                success = false;
                String errorPath = (index < 0) ? KSRPropertyConstants.PROVISIONING_ROLE_TAB_ORDER : buildPropertyPath(buildIndexedProperty(KSRConstants.SECURITY_PROVISIONING_GROUPS, index), KSRPropertyConstants.PROVISIONING_ROLE_TAB_ORDER);
                GlobalVariables.getMessageMap().putError(errorPath, KSRKeyConstants.ERROR_SECURITY_PROVISIONING_GROUP_TAB_ORDER_UNIQUE, getRoleNameForErrorMessage(securityProvisioningGroup.getRole()));
            }
        }
    }
    return success;
}
Also used : KimType(org.kuali.kfs.kim.impl.type.KimType) SecurityProvisioning(edu.cornell.kfs.ksr.businessobject.SecurityProvisioning) SecurityProvisioningGroup(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup) KimTypeService(org.kuali.kfs.kim.framework.type.KimTypeService) RoleLite(org.kuali.kfs.kim.impl.role.RoleLite)

Example 12 with SecurityProvisioningGroup

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

the class SecurityRequestDocumentRule method processCustomRouteDocumentBusinessRules.

@Override
protected boolean processCustomRouteDocumentBusinessRules(Document document) {
    boolean success = true;
    SecurityRequestDocument securityRequestDocument = (SecurityRequestDocument) document;
    if (!isDocumentChanged(securityRequestDocument)) {
        success = false;
        String input = KRADConstants.DOCUMENT_PROPERTY_NAME + "." + KRADConstants.DOCUMENT_HEADER_PROPERTY_NAME;
        GlobalVariables.getMessageMap().putError(input, KSRKeyConstants.ERROR_SECURITY_REQUEST_DOC_CHANGE_MISSING);
    } else {
        List<SecurityRequestRole> activeRoles = new ArrayList<SecurityRequestRole>();
        Map<String, String> indexes = new HashMap<String, String>();
        for (int i = 0; i < securityRequestDocument.getSecurityRequestRoles().size(); i++) {
            SecurityRequestRole securityRequestRole = securityRequestDocument.getSecurityRequestRoles().get(i);
            indexes.put(securityRequestRole.getRoleId(), Integer.toString(i));
            if (securityRequestRole.isActive()) {
                activeRoles.add(securityRequestRole);
            }
        }
        for (int i = 0; i < activeRoles.size(); i++) {
            List<String> rolesNeeded = new ArrayList<String>();
            SecurityRequestRole securityRequestRole = activeRoles.get(i);
            Map<String, Object> hashMap = new HashMap<String, Object>();
            hashMap.put(KSRPropertyConstants.PROVISIONING_ROLE_ID, securityRequestRole.getRoleId());
            hashMap.put(KSRPropertyConstants.SECURITY_GROUP_ID, securityRequestDocument.getSecurityGroupId());
            hashMap.put(KSRPropertyConstants.SECURITY_GROUP_ACTIVE_INDICATOR, Boolean.TRUE);
            List<SecurityProvisioningGroup> objList = (List<SecurityProvisioningGroup>) KRADServiceLocator.getBusinessObjectService().findMatching(SecurityProvisioningGroup.class, hashMap);
            SecurityProvisioningGroup securityProvisioningGroup = null;
            if ((objList != null) && (objList.size() != 0)) {
                securityProvisioningGroup = objList.get(0);
            }
            if (securityProvisioningGroup != null) {
                for (int j = 0; j < securityProvisioningGroup.getDependentRoles().size(); j++) {
                    SecurityProvisioningGroupDependentRoles dependentRole = securityProvisioningGroup.getDependentRoles().get(j);
                    if (!dependentRole.isActive()) {
                        continue;
                    }
                    boolean found = false;
                    for (int k = 0; k < activeRoles.size(); k++) {
                        if (activeRoles.get(k).getRoleId().equals(dependentRole.getRoleId())) {
                            found = true;
                        }
                    }
                    if (!found) {
                        String index = indexes.get(dependentRole.getRoleId());
                        String input = KSRPropertyConstants.SECURITY_REQUEST_DOC_REQUEST_ROLE + "[" + index + "].active";
                        GlobalVariables.getMessageMap().putError(input, KSRKeyConstants.ERROR_SECURITY_REQUEST_DOC_DEPENDENT_ROLE_MISSING, new String[] { securityRequestRole.getRoleInfo().getName(), dependentRole.getRole().getName() });
                        rolesNeeded.add(dependentRole.getRole().getName());
                        success = false;
                    }
                }
            }
        }
    }
    return super.processCustomRouteDocumentBusinessRules(document) && success;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SecurityProvisioningGroupDependentRoles(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles) SecurityProvisioningGroup(edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup) SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole) ArrayList(java.util.ArrayList) List(java.util.List) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

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