1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.krad.service.impl; |
17 | |
|
18 | |
import org.apache.commons.lang.StringUtils; |
19 | |
import org.kuali.rice.kim.api.KimConstants; |
20 | |
import org.kuali.rice.kim.api.permission.Permission; |
21 | |
import org.kuali.rice.kim.impl.permission.PermissionBo; |
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 | 0 | public class ParameterPermissionTypeServiceImpl extends |
32 | |
NamespaceWildcardAllowedAndOrStringExactMatchPermissionTypeServiceImpl { |
33 | |
|
34 | |
@Override |
35 | |
protected List<String> getRequiredAttributes() { |
36 | 0 | final List<String> attrs = new ArrayList<String>(super.getRequiredAttributes()); |
37 | 0 | attrs.add(KimConstants.AttributeConstants.PARAMETER_NAME); |
38 | 0 | attrs.add(KimConstants.AttributeConstants.COMPONENT_NAME); |
39 | 0 | return Collections.unmodifiableList(attrs); |
40 | |
} |
41 | |
|
42 | |
@Override |
43 | |
protected boolean isCheckRequiredAttributes() { |
44 | 0 | return true; |
45 | |
} |
46 | |
|
47 | |
@Override |
48 | |
protected List<Permission> performPermissionMatches(Map<String, String> requestedDetails, List<Permission> permissionsList) { |
49 | 0 | String requestedParameterName = requestedDetails.get(KimConstants.AttributeConstants.PARAMETER_NAME); |
50 | 0 | String requestedComponentName = requestedDetails.get(KimConstants.AttributeConstants.COMPONENT_NAME); |
51 | 0 | List<Permission> matchingPermissions = new ArrayList<Permission>(); |
52 | 0 | for (Permission kpi : permissionsList ) { |
53 | 0 | PermissionBo bo = PermissionBo.from(kpi); |
54 | 0 | String parameterName = bo.getDetails().get(KimConstants.AttributeConstants.PARAMETER_NAME); |
55 | 0 | String componentName = bo.getDetails().get(KimConstants.AttributeConstants.COMPONENT_NAME); |
56 | 0 | if ( (StringUtils.isBlank(parameterName) |
57 | |
|| StringUtils.equals(requestedParameterName, parameterName)) |
58 | |
&&(StringUtils.isBlank(componentName) |
59 | |
|| StringUtils.equals(requestedComponentName, componentName))) { |
60 | 0 | matchingPermissions.add(kpi); |
61 | |
} |
62 | 0 | } |
63 | 0 | return super.performPermissionMatches(requestedDetails, matchingPermissions); |
64 | |
} |
65 | |
} |