1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kim.document.authorization; |
17 | |
|
18 | |
import java.util.HashMap; |
19 | |
import java.util.HashSet; |
20 | |
import java.util.Map; |
21 | |
import java.util.Set; |
22 | |
|
23 | |
import org.kuali.rice.kim.bo.Person; |
24 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentGroup; |
25 | |
import org.kuali.rice.kim.bo.ui.PersonDocumentRole; |
26 | |
import org.kuali.rice.kim.document.IdentityManagementPersonDocument; |
27 | |
import org.kuali.rice.kim.util.KimConstants; |
28 | |
import org.kuali.rice.krad.document.Document; |
29 | |
import org.kuali.rice.krad.document.authorization.TransactionalDocumentAuthorizerBase; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 0 | public class IdentityManagementKimDocumentAuthorizer extends TransactionalDocumentAuthorizerBase { |
38 | |
|
39 | |
public Map<String,Set<String>> getUnpopulateableGroups(Document document, Person user) { |
40 | 0 | Map<String,Set<String>> unpopulateableGroups = new HashMap<String,Set<String>>(); |
41 | 0 | for (PersonDocumentGroup personDocumentGroup : ((IdentityManagementPersonDocument)document).getGroups()) { |
42 | 0 | Map<String,String> collectionOrFieldLevelPermissionDetails = new HashMap<String,String>(); |
43 | 0 | collectionOrFieldLevelPermissionDetails.put(KimConstants.AttributeConstants.NAMESPACE_CODE, personDocumentGroup.getNamespaceCode()); |
44 | 0 | collectionOrFieldLevelPermissionDetails.put(KimConstants.AttributeConstants.GROUP_NAME, personDocumentGroup.getGroupName()); |
45 | 0 | if (!isAuthorizedByTemplate(document, KimConstants.NAMESPACE_CODE, KimConstants.PermissionTemplateNames.POPULATE_GROUP, user.getPrincipalId(), collectionOrFieldLevelPermissionDetails, null)) { |
46 | 0 | if (!unpopulateableGroups.containsKey(personDocumentGroup.getNamespaceCode())) { |
47 | 0 | unpopulateableGroups.put(personDocumentGroup.getNamespaceCode(), new HashSet<String>()); |
48 | |
} |
49 | 0 | unpopulateableGroups.get(personDocumentGroup.getNamespaceCode()).add(personDocumentGroup.getGroupName()); |
50 | |
} |
51 | 0 | } |
52 | 0 | return unpopulateableGroups; |
53 | |
} |
54 | |
|
55 | |
public Map<String,Set<String>> getUnassignableRoles(Document document, Person user) { |
56 | 0 | Map<String,Set<String>> unassignableRoles = new HashMap<String,Set<String>>(); |
57 | 0 | for (PersonDocumentRole personDocumentRole : ((IdentityManagementPersonDocument)document).getRoles()) { |
58 | 0 | Map<String,String> collectionOrFieldLevelPermissionDetails = new HashMap<String,String>(); |
59 | 0 | collectionOrFieldLevelPermissionDetails.put(KimConstants.AttributeConstants.NAMESPACE_CODE, personDocumentRole.getNamespaceCode()); |
60 | 0 | collectionOrFieldLevelPermissionDetails.put(KimConstants.AttributeConstants.ROLE_NAME, personDocumentRole.getRoleName()); |
61 | 0 | if (!isAuthorizedByTemplate(document, KimConstants.NAMESPACE_CODE, KimConstants.PermissionTemplateNames.ASSIGN_ROLE, user.getPrincipalId(), collectionOrFieldLevelPermissionDetails, null)) { |
62 | 0 | if (!unassignableRoles.containsKey(personDocumentRole.getNamespaceCode())) { |
63 | 0 | unassignableRoles.put(personDocumentRole.getNamespaceCode(), new HashSet<String>()); |
64 | |
} |
65 | 0 | unassignableRoles.get(personDocumentRole.getNamespaceCode()).add(personDocumentRole.getRoleName()); |
66 | |
} |
67 | 0 | } |
68 | 0 | return unassignableRoles; |
69 | |
} |
70 | |
} |