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.permission.Permission; |
20 | |
import org.kuali.rice.kim.impl.permission.PermissionBo; |
21 | |
import org.kuali.rice.kim.util.KimConstants; |
22 | |
|
23 | |
import java.util.ArrayList; |
24 | |
import java.util.List; |
25 | |
import java.util.Map; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | 0 | public class ParameterPermissionTypeServiceImpl extends |
31 | |
NamespaceWildcardAllowedAndOrStringExactMatchPermissionTypeServiceImpl { |
32 | |
|
33 | |
{ |
34 | 0 | requiredAttributes.add(KimConstants.AttributeConstants.PARAMETER_NAME); |
35 | 0 | requiredAttributes.add(KimConstants.AttributeConstants.COMPONENT_NAME); |
36 | 0 | checkRequiredAttributes = true; |
37 | 0 | } |
38 | |
|
39 | |
@Override |
40 | |
protected List<Permission> performPermissionMatches(Map<String, String> requestedDetails, List<Permission> permissionsList) { |
41 | 0 | String requestedParameterName = requestedDetails.get(KimConstants.AttributeConstants.PARAMETER_NAME); |
42 | 0 | String requestedComponentName = requestedDetails.get(KimConstants.AttributeConstants.COMPONENT_NAME); |
43 | 0 | List<Permission> matchingPermissions = new ArrayList<Permission>(); |
44 | 0 | for (Permission kpi : permissionsList ) { |
45 | 0 | PermissionBo bo = PermissionBo.from(kpi); |
46 | 0 | String parameterName = bo.getDetails().get(KimConstants.AttributeConstants.PARAMETER_NAME); |
47 | 0 | String componentName = bo.getDetails().get(KimConstants.AttributeConstants.COMPONENT_NAME); |
48 | 0 | if ( (StringUtils.isBlank(parameterName) |
49 | |
|| StringUtils.equals(requestedParameterName, parameterName)) |
50 | |
&&(StringUtils.isBlank(componentName) |
51 | |
|| StringUtils.equals(requestedComponentName, componentName))) { |
52 | 0 | matchingPermissions.add(kpi); |
53 | |
} |
54 | 0 | } |
55 | 0 | return super.performPermissionMatches(requestedDetails, matchingPermissions); |
56 | |
} |
57 | |
} |