View Javadoc
1   /*
2    * Copyright 2008-2009 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.rice.kim.service.impl;
17  
18  import java.util.HashMap;
19  import java.util.Map;
20  
21  import org.apache.log4j.Logger;
22  import org.kuali.rice.kim.api.identity.IdentityService;
23  import org.kuali.rice.kim.api.identity.entity.Entity;
24  import org.kuali.rice.kim.api.identity.entity.EntityDefault;
25  import org.kuali.rice.kim.api.identity.principal.Principal;
26  import org.kuali.rice.kim.api.permission.PermissionService;
27  import org.kuali.rice.kim.api.services.IdentityManagementService;
28  import org.kuali.rice.kim.api.services.KimApiServiceLocator;
29  
30  @Deprecated
31  public class IdentityManagementServiceImpl implements IdentityManagementService {
32  	private static final Logger LOG = Logger.getLogger( IdentityManagementServiceImpl.class );
33  
34  	protected PermissionService permissionService;
35  	protected IdentityService identityService;
36  
37      // AUTHORIZATION SERVICE
38      @Override
39      public boolean hasPermission(String principalId, String namespaceCode, String permissionName) {
40      	return getPermissionService().hasPermission(principalId, namespaceCode, permissionName );
41      }
42  
43      @Override
44      public boolean isAuthorized(String principalId, String namespaceCode, String permissionName, Map<String, String> qualification ) {
45      	if ( qualification == null || qualification.isEmpty() ) {
46      		return hasPermission( principalId, namespaceCode, permissionName );
47      	}
48          return getPermissionService().isAuthorized(principalId, namespaceCode, permissionName, qualification);
49      }
50  
51      @Override
52      public boolean hasPermissionByTemplateName(String principalId, String namespaceCode, String permissionTemplateName, Map<String, String> permissionDetails) {
53  		return getPermissionService().hasPermissionByTemplate(principalId, namespaceCode, permissionTemplateName, permissionDetails);
54      }
55  
56      @Override
57      public boolean isAuthorizedByTemplateName(String principalId, String namespaceCode, String permissionTemplateName, Map<String, String> permissionDetails, Map<String, String> qualification ) {
58      	if ( qualification == null || qualification.isEmpty() ) {
59      		return hasPermissionByTemplateName( principalId, namespaceCode, permissionTemplateName, new HashMap<String, String>(permissionDetails) );
60      	}
61      	return getPermissionService().isAuthorizedByTemplate( principalId, namespaceCode, permissionTemplateName, new HashMap<String, String>(permissionDetails), new HashMap<String, String>(qualification) );
62      }
63  
64      // IDENTITY SERVICE
65      @Override
66  	public Principal getPrincipal(String principalId) {
67  		return getIdentityService().getPrincipal(principalId);
68  	}
69  
70      @Override
71      public Principal getPrincipalByPrincipalName(String principalName) {
72  		return getIdentityService().getPrincipalByPrincipalName(principalName);
73      }
74  
75      @Override
76      public EntityDefault getEntityDefaultInfo(String entityId) {
77  		return getIdentityService().getEntityDefault(entityId);
78      }
79  
80      @Override
81      public EntityDefault getEntityDefaultInfoByPrincipalId(
82      		String principalId) {
83      	return getIdentityService().getEntityDefaultByPrincipalId(principalId);
84      }
85  
86      @Override
87      public EntityDefault getEntityDefaultInfoByPrincipalName(
88      		String principalName) {
89      	return getIdentityService().getEntityDefaultByPrincipalName(principalName);
90      }
91  
92      @Override
93      public Entity getEntityByPrincipalId(String principalId) {
94          return getIdentityService().getEntityByPrincipalId(principalId);
95      }
96  
97      	// OTHER METHODS
98  
99  	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 }