Search in sources :

Example 1 with IdentityManagementService

use of org.kuali.rice.kim.api.services.IdentityManagementService in project cu-kfs by CU-CommunityApps.

the class VendorDetailInquiryPresentationController method getConditionallyHiddenPropertyNames.

/**
 * Implement this method to hide fields based on specific data in the record being inquired into
 *
 * @return Set of property names that should be hidden
 */
@Override
public Set<String> getConditionallyHiddenPropertyNames(BusinessObject businessObject) {
    Set<String> retVal = new HashSet<String>();
    IdentityManagementService idService = SpringContext.getBean(IdentityManagementService.class);
    UserSession uSession = GlobalVariables.getUserSession();
    Map<String, String> permissionDetails = new HashMap<String, String>();
    permissionDetails.put(KewApiConstants.DOCUMENT_TYPE_NAME_DETAIL, "PVEN");
    boolean canViewAttachments = idService.isAuthorizedByTemplateName(uSession.getPrincipalId(), KRADConstants.KNS_NAMESPACE, KimConstants.PermissionTemplateNames.VIEW_NOTE_ATTACHMENT, permissionDetails, null);
    if (!canViewAttachments) {
        VendorDetail detail = (VendorDetail) businessObject;
        VendorService vendorService = SpringContext.getBean(VendorService.class);
        List<Note> boNotes = vendorService.getVendorNotes(detail);
        for (int i = 0; i < boNotes.size(); i++) retVal.add("boNotes[" + i + "].attachmentLink");
    }
    return retVal;
}
Also used : HashMap(java.util.HashMap) VendorDetail(org.kuali.kfs.vnd.businessobject.VendorDetail) VendorService(org.kuali.kfs.vnd.document.service.VendorService) IdentityManagementService(org.kuali.rice.kim.api.services.IdentityManagementService) UserSession(org.kuali.kfs.krad.UserSession) Note(org.kuali.kfs.krad.bo.Note) HashSet(java.util.HashSet)

Example 2 with IdentityManagementService

use of org.kuali.rice.kim.api.services.IdentityManagementService in project cu-kfs by CU-CommunityApps.

the class PurApRelatedViews method maskPONumberIfUnapproved.

/**
 * masks the po number if the po is unappoved yet.  If the document status is not FINAL then
 * check for permission for purapDocumentIdentifier field.  If NOT permitted to view the value
 * then mask the value with * and setting this value in poNumberMasked property.
 *
 * @param view
 */
protected void maskPONumberIfUnapproved(AbstractRelatedView view) {
    String poIDstr = "";
    if (ObjectUtils.isNotNull(view.getPurapDocumentIdentifier())) {
        poIDstr = view.getPurapDocumentIdentifier().toString();
    }
    if (PurapConstants.PurapDocTypeCodes.PO_DOCUMENT.equals(view.getDocumentTypeName())) {
        DocumentStatus documentStatus = KewApiServiceLocator.getWorkflowDocumentService().getDocumentStatus(view.getDocumentNumber());
        if (!(StringUtils.equals(documentStatus.getCode(), DocumentStatus.FINAL.getCode()))) {
            String principalId = GlobalVariables.getUserSession().getPrincipalId();
            String namespaceCode = KFSConstants.ParameterNamespaces.KNS;
            String permissionTemplateName = KimConstants.PermissionTemplateNames.FULL_UNMASK_FIELD;
            Map<String, String> roleQualifiers = new HashMap<String, String>();
            Map<String, String> permissionDetails = new HashMap<String, String>();
            permissionDetails.put(KimConstants.AttributeConstants.COMPONENT_NAME, PurchaseOrderDocument.class.getSimpleName());
            permissionDetails.put(KimConstants.AttributeConstants.PROPERTY_NAME, PurapPropertyConstants.PURAP_DOC_ID);
            IdentityManagementService identityManagementService = SpringContext.getBean(IdentityManagementService.class);
            Boolean isAuthorized = identityManagementService.isAuthorizedByTemplateName(principalId, namespaceCode, permissionTemplateName, permissionDetails, roleQualifiers);
            if (!isAuthorized) {
                // not authorized to see... so mask the po number string
                poIDstr = "";
                int strLength = SpringContext.getBean(DataDictionaryService.class).getAttributeMaxLength(PurApGenericAttributes.class.getName(), PurapPropertyConstants.PURAP_DOC_ID);
                for (int i = 0; i < strLength; i++) {
                    poIDstr = poIDstr.concat("*");
                }
            }
        }
    }
    view.setPoNumberMasked(poIDstr);
}
Also used : DocumentStatus(org.kuali.rice.kew.api.document.DocumentStatus) PurApGenericAttributes(org.kuali.kfs.module.purap.businessobject.PurApGenericAttributes) HashMap(java.util.HashMap) IdentityManagementService(org.kuali.rice.kim.api.services.IdentityManagementService) PurchaseOrderDocument(org.kuali.kfs.module.purap.document.PurchaseOrderDocument) DataDictionaryService(org.kuali.kfs.kns.service.DataDictionaryService)

Aggregations

HashMap (java.util.HashMap)2 IdentityManagementService (org.kuali.rice.kim.api.services.IdentityManagementService)2 HashSet (java.util.HashSet)1 DataDictionaryService (org.kuali.kfs.kns.service.DataDictionaryService)1 UserSession (org.kuali.kfs.krad.UserSession)1 Note (org.kuali.kfs.krad.bo.Note)1 PurApGenericAttributes (org.kuali.kfs.module.purap.businessobject.PurApGenericAttributes)1 PurchaseOrderDocument (org.kuali.kfs.module.purap.document.PurchaseOrderDocument)1 VendorDetail (org.kuali.kfs.vnd.businessobject.VendorDetail)1 VendorService (org.kuali.kfs.vnd.document.service.VendorService)1 DocumentStatus (org.kuali.rice.kew.api.document.DocumentStatus)1