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;
17  
18  import java.util.List;
19  import java.util.Map;
20  
21  import javax.jws.WebMethod;
22  import javax.jws.WebParam;
23  import javax.jws.WebService;
24  import javax.jws.soap.SOAPBinding;
25  import javax.servlet.http.HttpServletRequest;
26  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
27  
28  import org.kuali.rice.core.jaxb.AttributeSetAdapter;
29  import org.kuali.rice.core.jaxb.MapStringStringAdapter;
30  import org.kuali.rice.kim.bo.entity.dto.KimEntityDefaultInfo;
31  import org.kuali.rice.kim.bo.entity.dto.KimEntityInfo;
32  import org.kuali.rice.kim.bo.entity.dto.KimPrincipalInfo;
33  import org.kuali.rice.kim.bo.group.dto.GroupInfo;
34  import org.kuali.rice.kim.bo.reference.dto.AddressTypeInfo;
35  import org.kuali.rice.kim.bo.reference.dto.AffiliationTypeInfo;
36  import org.kuali.rice.kim.bo.reference.dto.CitizenshipStatusInfo;
37  import org.kuali.rice.kim.bo.reference.dto.EmailTypeInfo;
38  import org.kuali.rice.kim.bo.reference.dto.EmploymentStatusInfo;
39  import org.kuali.rice.kim.bo.reference.dto.EmploymentTypeInfo;
40  import org.kuali.rice.kim.bo.reference.dto.EntityNameTypeInfo;
41  import org.kuali.rice.kim.bo.reference.dto.EntityTypeInfo;
42  import org.kuali.rice.kim.bo.reference.dto.ExternalIdentifierTypeInfo;
43  import org.kuali.rice.kim.bo.reference.dto.PhoneTypeInfo;
44  import org.kuali.rice.kim.bo.role.dto.KimPermissionInfo;
45  import org.kuali.rice.kim.bo.role.dto.KimResponsibilityInfo;
46  import org.kuali.rice.kim.bo.role.dto.PermissionAssigneeInfo;
47  import org.kuali.rice.kim.bo.role.dto.ResponsibilityActionInfo;
48  import org.kuali.rice.kim.bo.types.dto.AttributeSet;
49  import org.kuali.rice.kim.util.KIMWebServiceConstants;
50  
51  /**
52   * This is the front end for the KIM module.  Clients of KIM should access this service from
53   * their applications.  If KIM is not running on the same machine (VM) as the application
54   * (as would be the case with a standalone Rice server), then this service should be implemented
55   * locally within the application and access the core KIM services
56   * (Authentication/Authorization/Identity/Group) via the service bus.
57   *
58   *  For efficiency, implementations of this interface should add appropriate caching of
59   *  the information retrieved from the core services for load and performance reasons.
60   *
61   *  Most of the methods on this interface are straight pass-thrus to methods on the four core services.
62   *
63   * @author Kuali Rice Team (rice.collab@kuali.org)
64   *
65   */
66  @WebService(name = KIMWebServiceConstants.IdentityManagementService.WEB_SERVICE_NAME, targetNamespace = KIMWebServiceConstants.MODULE_TARGET_NAMESPACE)
67  @SOAPBinding(style = SOAPBinding.Style.DOCUMENT, use = SOAPBinding.Use.LITERAL, parameterStyle = SOAPBinding.ParameterStyle.WRAPPED)
68  public interface IdentityManagementService {
69  
70  	// *******************************
71  	// IdentityService
72  	// *******************************
73  
74  	KimPrincipalInfo getPrincipal(@WebParam(name="principalId") String principalId);
75  	KimPrincipalInfo getPrincipalByPrincipalName(@WebParam(name="principalName") String principalName);
76  
77  	KimPrincipalInfo getPrincipalByPrincipalNameAndPassword(
78  			@WebParam(name="principalName") String principalName,
79  			@WebParam(name="password") String password
80  	);
81  
82  	KimEntityDefaultInfo getEntityDefaultInfo( @WebParam(name="entityId") String entityId );
83  	KimEntityDefaultInfo getEntityDefaultInfoByPrincipalId( @WebParam(name="principalId") String principalId );
84  	KimEntityDefaultInfo getEntityDefaultInfoByPrincipalName( @WebParam(name="principalName") String principalName );
85  
86  	List<? extends KimEntityDefaultInfo> lookupEntityDefaultInfo(
87  			@XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
88  			@WebParam(name="searchCriteria") Map<String,String> searchCriteria,
89  			@WebParam(name="unbounded") boolean unbounded
90  	);
91  
92  	int getMatchingEntityCount( @XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
93  			@WebParam(name="searchCriteria") Map<String,String> searchCriteria );
94  
95  	//KimEntityPrivacyPreferencesInfo getEntityPrivacyPreferences(String entityId);
96  
97  	KimEntityInfo getEntityInfo( @WebParam(name="entityId") String entityId );
98  	KimEntityInfo getEntityInfoByPrincipalId( @WebParam(name="principalId") String principalId );
99  	KimEntityInfo getEntityInfoByPrincipalName( @WebParam(name="principalName") String principalName );
100 
101 	List<KimEntityInfo> lookupEntityInfo(
102 			@XmlJavaTypeAdapter(value = MapStringStringAdapter.class)
103 			@WebParam(name = "searchCriteria") Map<String,String> searchCriteria,
104 			@WebParam(name="unbounded") boolean unbounded
105 	);
106 
107 	AddressTypeInfo getAddressType( @WebParam(name="code") String code );
108 	AffiliationTypeInfo getAffiliationType( @WebParam(name="code")String code );
109 	CitizenshipStatusInfo getCitizenshipStatus( @WebParam(name="code") String code );
110 	EmailTypeInfo getEmailType( @WebParam(name="code") String code );
111 	EmploymentStatusInfo getEmploymentStatus( @WebParam(name="code") String code );
112 	EmploymentTypeInfo getEmploymentType( @WebParam(name="code") String code );
113 	EntityNameTypeInfo getEntityNameType( @WebParam(name="code") String code );
114 	EntityTypeInfo getEntityType( @WebParam(name="code") String code );
115 	ExternalIdentifierTypeInfo getExternalIdentifierType( @WebParam(name="code") String code );
116 	PhoneTypeInfo getPhoneType( @WebParam(name="code") String code );
117 
118 	// *******************************
119 	// GroupService
120 	// *******************************
121 
122 	GroupInfo getGroup(@WebParam(name="groupId") String groupId);
123 
124     GroupInfo getGroupByName(
125     		@WebParam(name="namespaceCode") String namespaceCode,
126     		@WebParam(name="groupName") String groupName
127     );
128 
129     List<String> getParentGroupIds( @WebParam(name="groupId") String groupId);
130     List<String> getDirectParentGroupIds( @WebParam(name="groupId") String groupId);
131 
132     @WebMethod(operationName="getGroupIdsForPrincipal")
133     List<String> getGroupIdsForPrincipal( @WebParam(name="principalId") String principalId);
134 
135     @WebMethod(operationName="getGroupIdsForPrincipal2")
136     List<String> getGroupIdsForPrincipal(
137     		@WebParam(name="principalId") String principalId,
138     		@WebParam(name="namespaceCode") String namespaceCode
139     );
140 
141     @WebMethod(operationName="getGroupsForPrincipal")
142     List<? extends GroupInfo> getGroupsForPrincipal( @WebParam(name="principalId") String principalId);
143 
144     @WebMethod(operationName="getGroupsForPrincipal2")
145     List<? extends GroupInfo> getGroupsForPrincipal(
146     		@WebParam(name="principalId") String principalId,
147     		@WebParam(name="namespaceCode") String namespaceCode
148     );
149 
150     List<String> getMemberGroupIds( @WebParam(name="groupId") String groupId);
151     List<String> getDirectMemberGroupIds( @WebParam(name="groupId") String groupId);
152 
153     @WebMethod(operationName="isMemberOfGroup")
154 	boolean isMemberOfGroup(
155 			@WebParam(name="principalId") String principalId,
156 			@WebParam(name="groupId") String groupId
157 	);
158 
159     @WebMethod(operationName="isMemberOfGroup2")
160 	boolean isMemberOfGroup(
161 			@WebParam(name="principalId") String principalId,
162 			@WebParam(name="namespaceCode") String namespaceCode,
163 			@WebParam(name="groupName") String groupName
164 	);
165 
166 	boolean isGroupMemberOfGroup(
167 			@WebParam(name="potentialMemberGroupId") String potentialMemberGroupId,
168 			@WebParam(name="potentialParentId") String potentialParentId
169 	);
170 
171 	List<String> getGroupMemberPrincipalIds( @WebParam(name="groupId") String groupId);
172 	List<String> getDirectGroupMemberPrincipalIds( @WebParam(name="groupId") String groupId);
173 
174     boolean addGroupToGroup(
175     		@WebParam(name="childId") String childId,
176     		@WebParam(name="parentId") String parentId
177     );
178 
179     boolean removeGroupFromGroup(
180     		@WebParam(name="childId") String childId,
181     		@WebParam(name="parentId") String parentId
182     );
183 
184     boolean addPrincipalToGroup(
185     		@WebParam(name="principalId") String principalId,
186     		@WebParam(name="groupId") String groupId
187     );
188 
189     boolean removePrincipalFromGroup(
190     		@WebParam(name="principalId") String principalId,
191     		@WebParam(name="groupId") String groupId
192     );
193 
194     GroupInfo createGroup( @WebParam(name="groupInfo") GroupInfo groupInfo);
195     void removeAllGroupMembers( @WebParam(name="groupId") String groupId);
196 
197     GroupInfo updateGroup(
198     		@WebParam(name="groupId") String groupId,
199     		@WebParam(name="groupInfo") GroupInfo groupInfo
200     );
201 
202 	// *******************************
203 	// AuthenticationService
204 	// *******************************
205     @WebMethod(exclude=true)
206 	String getAuthenticatedPrincipalName( @WebParam(name="request") HttpServletRequest request);
207 
208 	// *******************************
209 	// AuthorizationService
210 	// *******************************
211 
212     // --------------------
213     // Authorization Checks
214     // --------------------
215 
216     boolean hasPermission(
217     		@WebParam(name="principalId") String principalId,
218     		@WebParam(name="namespaceCode") String namespaceCode,
219     		@WebParam(name="permissionName") String permissionName,
220     		@WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet permissionDetails
221     );
222 
223     boolean isAuthorized(
224     		@WebParam(name="principalId") String principalId,
225     		@WebParam(name="namespaceCode") String namespaceCode,
226     		@WebParam(name="permissionName") String permissionName,
227     		@WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet permissionDetails,
228     		@WebParam(name="qualification") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet qualification
229     );
230 
231     boolean hasPermissionByTemplateName(
232     		@WebParam(name="principalId") String principalId,
233     		@WebParam(name="namespaceCode") String namespaceCode,
234     		@WebParam(name="permissionTemplateName") String permissionTemplateName,
235     		@WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet permissionDetails
236     );
237 
238     boolean isAuthorizedByTemplateName(
239     		@WebParam(name="principalId") String principalId,
240     		@WebParam(name="namespaceCode") String namespaceCode,
241     		@WebParam(name="permissionTemplateName") String permissionTemplateName,
242     		@WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet permissionDetails,
243     		@WebParam(name="qualification") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet qualification
244     );
245 
246     /**
247      * Returns the matching permission objects for a principal.
248      */
249     List<? extends KimPermissionInfo> getAuthorizedPermissions(
250     		@WebParam(name="principalId") String principalId,
251     		@WebParam(name="namespaceCode") String namespaceCode,
252     		@WebParam(name="permissionName") String permissionName,
253     		@WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet permissionDetails,
254     		@WebParam(name="qualification") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet qualification
255     );
256 
257     List<? extends KimPermissionInfo> getAuthorizedPermissionsByTemplateName(
258     		@WebParam(name="principalId") String principalId,
259     		@WebParam(name="namespaceCode") String namespaceCode,
260     		@WebParam(name="permissionTemplateName") String permissionTemplateName,
261     		@WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet permissionDetails,
262     		@WebParam(name="qualification") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet qualification
263     );
264 
265     List<PermissionAssigneeInfo> getPermissionAssignees(
266     		@WebParam(name="namespaceCode") String namespaceCode,
267     		@WebParam(name="permissionName") String permissionName,
268     		@WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet permissionDetails,
269     		@WebParam(name="qualification") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet qualification
270     );
271 
272     List<PermissionAssigneeInfo> getPermissionAssigneesForTemplateName(
273     		@WebParam(name="namespaceCode") String namespaceCode,
274     		@WebParam(name="permissionTemplateName") String permissionTemplateName,
275     		@WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet permissionDetails,
276     		@WebParam(name="qualification") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet qualification
277     );
278 
279     // ----------------------
280     // Responsibility Methods
281     // ----------------------
282 
283     /**
284      * Get the responsibility object with the given ID.
285      */
286     KimResponsibilityInfo getResponsibility( @WebParam(name="responsibilityId") String responsibilityId);
287 
288  	/**
289  	 * Return the responsibility object for the given unique combination of namespace,
290  	 * component and responsibility name.
291  	 */
292     List<? extends KimResponsibilityInfo> getResponsibilitiesByName(
293     		@WebParam(name="namespaceCode") String namespaceCode,
294     		@WebParam(name="responsibilityName") String responsibilityName
295     );
296 
297     /**
298      * Check whether the principal has the given responsibility within the passed qualifier.
299      */
300     boolean hasResponsibility(
301     		@WebParam(name="principalId") String principalId,
302     		@WebParam(name="namespaceCode") String namespaceCode,
303     		@WebParam(name="responsibilityName") String responsibilityName,
304     		@WebParam(name="qualification") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet qualification,
305     		@WebParam(name="responsibilityDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet responsibilityDetails
306     );
307 
308     /**
309      * Check whether the principal has the given responsibility within the passed qualifier.
310      */
311     boolean hasResponsibilityByTemplateName(
312     		@WebParam(name="principalId") String principalId,
313     		@WebParam(name="namespaceCode") String namespaceCode,
314     		@WebParam(name="responsibilityTemplateName") String responsibilityTemplateName,
315     		@WebParam(name="qualification") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet qualification,
316     		@WebParam(name="responsibilityDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet responsibilityDetails
317     );
318 
319     List<ResponsibilityActionInfo> getResponsibilityActions(
320     		@WebParam(name="namespaceCode") String namespaceCode,
321     		@WebParam(name="responsibilityName") String responsibilityName,
322     		@WebParam(name="qualification") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet qualification,
323     		@WebParam(name="responsibilityDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet responsibilityDetails
324     );
325 
326     List<ResponsibilityActionInfo> getResponsibilityActionsByTemplateName(
327     		@WebParam(name="namespaceCode") String namespaceCode,
328     		@WebParam(name="responsibilityTemplateName") String responsibilityTemplateName,
329     		@WebParam(name="qualification") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet qualification,
330     		@WebParam(name="responsibilityDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet responsibilityDetails
331     );
332 
333     /**
334      * Returns true if there are any assigned permissions with the given template.
335      */
336     boolean isPermissionDefinedForTemplateName(
337     		@WebParam(name="namespaceCode") String namespaceCode,
338     		@WebParam(name="permissionTemplateName") String permissionTemplateName,
339     		@WebParam(name="permissionDetails") @XmlJavaTypeAdapter(value = AttributeSetAdapter.class) AttributeSet permissionDetails
340     );
341 
342 
343     // ----------------------
344     // Cache Flush Methods
345     // ----------------------
346 
347     void flushAllCaches();
348     void flushEntityPrincipalCaches();
349 	void flushGroupCaches();
350 	void flushPermissionCaches();
351 	void flushResponsibilityCaches();
352 
353 }