1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.kim.permission; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.kim.api.permission.Permission; |
20 | |
import org.kuali.rice.kim.framework.permission.PermissionTypeService; |
21 | |
import org.kuali.rice.kns.kim.type.DataDictionaryTypeServiceBase; |
22 | |
|
23 | |
import java.util.ArrayList; |
24 | |
import java.util.Collections; |
25 | |
import java.util.List; |
26 | |
import java.util.Map; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
@Deprecated |
32 | 0 | public class PermissionTypeServiceBase extends DataDictionaryTypeServiceBase implements PermissionTypeService { |
33 | |
|
34 | |
@Override |
35 | |
public final List<Permission> getMatchingPermissions(Map<String, String> requestedDetails, List<Permission> permissionsList) { |
36 | 0 | requestedDetails = translateInputAttributes(requestedDetails); |
37 | 0 | validateRequiredAttributesAgainstReceived(requestedDetails); |
38 | 0 | return Collections.unmodifiableList(performPermissionMatches(requestedDetails, permissionsList)); |
39 | |
} |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
protected List<Permission> performPermissionMatches(Map<String, String> requestedDetails, List<Permission> permissionsList) { |
48 | 0 | List<Permission> matchingPermissions = new ArrayList<Permission>(); |
49 | 0 | for (Permission permission : permissionsList) { |
50 | 0 | if ( performMatch(requestedDetails, permission.getAttributes()) ) { |
51 | 0 | matchingPermissions.add( permission ); |
52 | |
} |
53 | |
} |
54 | 0 | return matchingPermissions; |
55 | |
} |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
protected boolean doesPropertyNameMatch( |
66 | |
String requestedDetailsPropertyName, |
67 | |
String permissionDetailsPropertyName) { |
68 | 0 | if (StringUtils.isBlank(permissionDetailsPropertyName)) { |
69 | 0 | return true; |
70 | |
} |
71 | 0 | if ( requestedDetailsPropertyName == null ) { |
72 | 0 | requestedDetailsPropertyName = ""; |
73 | |
} |
74 | 0 | return StringUtils.equals(requestedDetailsPropertyName, permissionDetailsPropertyName) |
75 | |
|| (requestedDetailsPropertyName.startsWith(permissionDetailsPropertyName+".")); |
76 | |
} |
77 | |
} |