001/*
002 * Copyright 2009 The Kuali Foundation
003 * 
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 * 
008 * http://www.opensource.org/licenses/ecl2.php
009 * 
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016package org.kuali.ole.pdp.service.impl;
017
018import org.kuali.ole.pdp.PdpConstants;
019import org.kuali.ole.pdp.service.PdpAuthorizationService;
020import org.kuali.ole.sys.OLEConstants;
021import org.kuali.ole.sys.context.SpringContext;
022import org.kuali.rice.kim.api.services.IdentityManagementService;
023
024public class PdpAuthorizationServiceImpl implements PdpAuthorizationService {
025
026    private IdentityManagementService identityManagementService;
027    
028    /**
029     * @see org.kuali.ole.pdp.service.PdpAuthorizationService#hasCancelPayment(java.lang.String)
030     */
031    @Override
032    public boolean hasCancelPaymentPermission(String principalId) {
033        return getIdentityManagementService().isAuthorized(principalId, OLEConstants.CoreModuleNamespaces.PDP, PdpConstants.PermissionNames.CANCEL_PAYMENT, null);
034    }
035
036    /**
037     * @see org.kuali.ole.pdp.service.PdpAuthorizationService#hasFormat(java.lang.String, java.lang.String)
038     */
039    @Override
040    public boolean hasFormatPermission(String principalId) {
041        return getIdentityManagementService().isAuthorized(principalId, OLEConstants.CoreModuleNamespaces.PDP, PdpConstants.PermissionNames.FORMAT, null);
042    }
043
044    /**
045     * @see org.kuali.ole.pdp.service.PdpAuthorizationService#hasHoldPayment(java.lang.String)
046     */
047    @Override
048    public boolean hasHoldPaymentPermission(String principalId) {
049        return getIdentityManagementService().isAuthorized(principalId, OLEConstants.CoreModuleNamespaces.PDP, PdpConstants.PermissionNames.HOLD_PAYMENT_REMOVE_NON_TAX_PAYMENT_HOLD, null);
050    }
051
052    /**
053     * @see org.kuali.ole.pdp.service.PdpAuthorizationService#hasRemoveFormatLock(java.lang.String, java.lang.String)
054     */
055    @Override
056    public boolean hasRemoveFormatLockPermission(String principalId) {
057        return getIdentityManagementService().isAuthorized(principalId, OLEConstants.CoreModuleNamespaces.PDP, PdpConstants.PermissionNames.REMOVE_FORMAT_LOCK, null);
058    }
059
060
061    /**
062     * @see org.kuali.ole.pdp.service.PdpAuthorizationService#hasRemovePaymentTaxHold(java.lang.String)
063     */
064    @Override
065    public boolean hasRemovePaymentTaxHoldPermission(String principalId) {
066        return getIdentityManagementService().isAuthorized(principalId, OLEConstants.CoreModuleNamespaces.PDP, PdpConstants.PermissionNames.REMOVE_PAYMENT_TAX_HOLD, null);
067    }
068
069    /**
070     * @see org.kuali.ole.pdp.service.PdpAuthorizationService#hasSetAsImmediatePay(java.lang.String, java.lang.String)
071     */
072    @Override
073    public boolean hasSetAsImmediatePayPermission(String principalId) {
074        return getIdentityManagementService().isAuthorized(principalId, OLEConstants.CoreModuleNamespaces.PDP, PdpConstants.PermissionNames.SET_AS_IMMEDIATE_PAY, null);
075    }
076
077    public IdentityManagementService getIdentityManagementService() {
078        if ( identityManagementService == null ) {
079            identityManagementService = SpringContext.getBean(IdentityManagementService.class);
080        }
081        return identityManagementService;
082    }
083
084}