001/*
002 * Copyright 2008-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.rice.kim.service.impl;
017
018import java.util.HashMap;
019import java.util.Map;
020
021import org.apache.log4j.Logger;
022import org.kuali.rice.kim.api.identity.IdentityService;
023import org.kuali.rice.kim.api.identity.entity.Entity;
024import org.kuali.rice.kim.api.identity.entity.EntityDefault;
025import org.kuali.rice.kim.api.identity.principal.Principal;
026import org.kuali.rice.kim.api.permission.PermissionService;
027import org.kuali.rice.kim.api.services.IdentityManagementService;
028import org.kuali.rice.kim.api.services.KimApiServiceLocator;
029
030@Deprecated
031public class IdentityManagementServiceImpl implements IdentityManagementService {
032        private static final Logger LOG = Logger.getLogger( IdentityManagementServiceImpl.class );
033
034        protected PermissionService permissionService;
035        protected IdentityService identityService;
036
037    // AUTHORIZATION SERVICE
038    @Override
039    public boolean hasPermission(String principalId, String namespaceCode, String permissionName) {
040        return getPermissionService().hasPermission(principalId, namespaceCode, permissionName );
041    }
042
043    @Override
044    public boolean isAuthorized(String principalId, String namespaceCode, String permissionName, Map<String, String> qualification ) {
045        if ( qualification == null || qualification.isEmpty() ) {
046                return hasPermission( principalId, namespaceCode, permissionName );
047        }
048        return getPermissionService().isAuthorized(principalId, namespaceCode, permissionName, qualification);
049    }
050
051    @Override
052    public boolean hasPermissionByTemplateName(String principalId, String namespaceCode, String permissionTemplateName, Map<String, String> permissionDetails) {
053                return getPermissionService().hasPermissionByTemplate(principalId, namespaceCode, permissionTemplateName, permissionDetails);
054    }
055
056    @Override
057    public boolean isAuthorizedByTemplateName(String principalId, String namespaceCode, String permissionTemplateName, Map<String, String> permissionDetails, Map<String, String> qualification ) {
058        if ( qualification == null || qualification.isEmpty() ) {
059                return hasPermissionByTemplateName( principalId, namespaceCode, permissionTemplateName, new HashMap<String, String>(permissionDetails) );
060        }
061        return getPermissionService().isAuthorizedByTemplate( principalId, namespaceCode, permissionTemplateName, new HashMap<String, String>(permissionDetails), new HashMap<String, String>(qualification) );
062    }
063
064    // IDENTITY SERVICE
065    @Override
066        public Principal getPrincipal(String principalId) {
067                return getIdentityService().getPrincipal(principalId);
068        }
069
070    @Override
071    public Principal getPrincipalByPrincipalName(String principalName) {
072                return getIdentityService().getPrincipalByPrincipalName(principalName);
073    }
074
075    @Override
076    public EntityDefault getEntityDefaultInfo(String entityId) {
077                return getIdentityService().getEntityDefault(entityId);
078    }
079
080    @Override
081    public EntityDefault getEntityDefaultInfoByPrincipalId(
082                String principalId) {
083        return getIdentityService().getEntityDefaultByPrincipalId(principalId);
084    }
085
086    @Override
087    public EntityDefault getEntityDefaultInfoByPrincipalName(
088                String principalName) {
089        return getIdentityService().getEntityDefaultByPrincipalName(principalName);
090    }
091
092    @Override
093    public Entity getEntityByPrincipalId(String principalId) {
094        return getIdentityService().getEntityByPrincipalId(principalId);
095    }
096
097        // OTHER METHODS
098
099        public IdentityService getIdentityService() {
100                if ( identityService == null ) {
101                        identityService = KimApiServiceLocator.getIdentityService();
102                }
103                return identityService;
104        }
105
106        public PermissionService getPermissionService() {
107                if ( permissionService == null ) {
108                        permissionService = KimApiServiceLocator.getPermissionService();
109                }
110                return permissionService;
111        }
112}