Search in sources :

Example 1 with SecurityRequestRole

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

the class SecurityRequestDocumentRule method isDocumentAttributesValid.

@Override
public boolean isDocumentAttributesValid(Document document, boolean validateRequired) {
    boolean success = true;
    SecurityRequestDocument securityRequestDocument = (SecurityRequestDocument) document;
    for (int i = 0; i < securityRequestDocument.getSecurityRequestRoles().size(); i++) {
        SecurityRequestRole securityRequestRole = securityRequestDocument.getSecurityRequestRoles().get(i);
        KimType tempTypeInfo = KimApiServiceLocator.getKimTypeInfoService().getKimType(securityRequestRole.getRoleInfo().getKimTypeId());
        if (!securityRequestRole.isActive()) {
            continue;
        } else if (!securityRequestRole.isQualifiedRole()) {
            continue;
        } else {
            String[] requiredQualifications = getRequiredQualificationsMap().get(tempTypeInfo.getServiceName());
            if (requiredQualifications != null && requiredQualifications.length > 0) {
                boolean qualsValid = true;
                boolean[] hasQuals = new boolean[requiredQualifications.length];
                for (SecurityRequestRoleQualification roleQualification : securityRequestRole.getRequestRoleQualifications()) {
                    Arrays.fill(hasQuals, false);
                    for (SecurityRequestRoleQualificationDetail qualDetail : roleQualification.getRoleQualificationDetails()) {
                        for (int j = requiredQualifications.length - 1; j >= 0; j--) {
                            if (requiredQualifications[j].equals(qualDetail.getAttributeName()) && StringUtils.isNotBlank(qualDetail.getAttributeValue())) {
                                hasQuals[j] = true;
                            }
                        }
                    }
                    for (boolean hasQual : hasQuals) {
                        qualsValid &= hasQual;
                    }
                }
                if (!qualsValid || securityRequestRole.getRequestRoleQualifications().size() == 0) {
                    success = false;
                    GlobalVariables.getMessageMap().putError(KSRPropertyConstants.SECURITY_REQUEST_DOC_REQUEST_ROLE + "[" + i + "].active", KSRKeyConstants.ERROR_SECURITY_REQUEST_DOC_QUALIFIER_MULTI_MISSING, new String[] { securityRequestRole.getRoleInfo().getName() });
                }
            } else if (securityRequestRole.getRequestRoleQualifications().size() == 0) {
                securityRequestRole.getRequestRoleQualifications().add(SpringContext.getBean(SecurityRequestDocumentService.class).buildRoleQualificationLine(securityRequestRole, null));
            }
        }
        for (int j = 0; j < securityRequestRole.getRequestRoleQualifications().size(); j++) {
            SecurityRequestRoleQualification requestRoleQualification = securityRequestRole.getRequestRoleQualifications().get(j);
            String typeId = securityRequestRole.getRoleInfo().getKimTypeId();
            KimType typeInfo = KimApiServiceLocator.getKimTypeInfoService().getKimType(typeId);
            String fieldKeyPrefix = KSRPropertyConstants.SECURITY_REQUEST_DOC_REQUEST_ROLE + "[" + i + "]." + KSRPropertyConstants.SECURITY_REQUEST_DOC_ROLE_QUAL + "[" + j + "].";
            success &= validateQualification(typeInfo, requestRoleQualification, fieldKeyPrefix);
        }
    }
    return super.isDocumentAttributesValid(document, validateRequired) && success;
}
Also used : KimType(org.kuali.kfs.kim.impl.type.KimType) SecurityRequestRoleQualificationDetail(edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualificationDetail) SecurityRequestRoleQualification(edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification) SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Example 2 with SecurityRequestRole

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

the class SecurityRequestDocumentAction method approve.

public ActionForward approve(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    final SecurityRequestDocumentForm documentForm = (SecurityRequestDocumentForm) form;
    StringBuilder annotation = new StringBuilder();
    final SecurityRequestDocument document = (SecurityRequestDocument) documentForm.getDocument();
    if (documentForm.getMethodToCall().indexOf("approve") > -1) {
        final String principalId = GlobalVariables.getUserSession().getPerson().getPrincipalId();
        for (final SecurityRequestRole securityRequestRole : document.getSecurityRequestRoles()) {
            LOG.info("approve() Checking if " + principalId + " has access");
            if (canApproveRequestForRole(securityRequestRole, principalId, document)) {
                annotation.append(securityRequestRole.getRoleInfo().getNamespaceCode()).append(" - ").append(securityRequestRole.getRoleInfo().getName()).append("\n");
            }
        }
    }
    documentForm.setAnnotation(annotation.toString());
    return super.approve(mapping, form, request, response);
}
Also used : SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Example 3 with SecurityRequestRole

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

the class SecurityRequestDocumentServiceImpl method prepareSecurityRequestDocument.

public void prepareSecurityRequestDocument(SecurityRequestDocument document) {
    if (document.getDocumentHeader().getWorkflowDocument().isSaved()) {
        for (SecurityRequestRole requestRole : document.getSecurityRequestRoles()) {
            SecurityRequestRoleQualification newRequestRoleQualification = buildRoleQualificationLine(requestRole, null);
            requestRole.setNewRequestRoleQualification(newRequestRoleQualification);
        }
    }
}
Also used : SecurityRequestRoleQualification(edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification) SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole)

Example 4 with SecurityRequestRole

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

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

the class SecurityRequestDerivedRoleTypeServiceImpl method getRoleMembersFromDerivedRole.

@Override
public List<RoleMembership> getRoleMembersFromDerivedRole(String namespaceCode, String roleName, Map<String, String> qualification) {
    final List<RoleMembership> members = new ArrayList<RoleMembership>();
    LOG.info("getRoleMembersFromDerivedRole() Generating role membership for role: " + roleName + " with qualification " + qualification);
    String documentNumber = qualification.get(AttributeConstants.DOCUMENT_NUMBER);
    SecurityRequestDocument document = null;
    try {
        document = (SecurityRequestDocument) KRADServiceLocatorWeb.getDocumentService().getByDocumentHeaderId(documentNumber);
    } catch (WorkflowException e) {
        LOG.error("getRoleMembersFromDerivedRole() Unable to retrieve security request document: " + documentNumber, e);
        throw new RuntimeException("Unable to retrieve security request document: " + documentNumber, e);
    }
    for (final SecurityRequestRole requestRole : document.getSecurityRequestRoles()) {
        members.addAll(getRoleMembersFromDerivedRole(roleName, document, requestRole));
    }
    LOG.info("getRoleMembersFromDerivedRole() Returning " + members.size() + " members");
    return members;
}
Also used : WorkflowException(org.kuali.kfs.kew.api.exception.WorkflowException) ArrayList(java.util.ArrayList) RoleMembership(org.kuali.kfs.kim.api.role.RoleMembership) SecurityRequestRole(edu.cornell.kfs.ksr.businessobject.SecurityRequestRole) SecurityRequestDocument(edu.cornell.kfs.ksr.document.SecurityRequestDocument)

Aggregations

SecurityRequestRole (edu.cornell.kfs.ksr.businessobject.SecurityRequestRole)9 SecurityRequestDocument (edu.cornell.kfs.ksr.document.SecurityRequestDocument)6 SecurityRequestRoleQualification (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualification)3 ArrayList (java.util.ArrayList)3 SecurityProvisioningGroup (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroup)2 SecurityGroupTab (edu.cornell.kfs.ksr.businessobject.SecurityGroupTab)1 SecurityProvisioningGroupDependentRoles (edu.cornell.kfs.ksr.businessobject.SecurityProvisioningGroupDependentRoles)1 SecurityRequestRoleQualificationDetail (edu.cornell.kfs.ksr.businessobject.SecurityRequestRoleQualificationDetail)1 AddQualificationLineEvent (edu.cornell.kfs.ksr.document.validation.impl.AddQualificationLineEvent)1 SecurityRequestDocumentService (edu.cornell.kfs.ksr.service.SecurityRequestDocumentService)1 HashMap (java.util.HashMap)1 List (java.util.List)1 WorkflowException (org.kuali.kfs.kew.api.exception.WorkflowException)1 RoleMembership (org.kuali.kfs.kim.api.role.RoleMembership)1 KimType (org.kuali.kfs.kim.impl.type.KimType)1