use of org.craftercms.commons.security.permissions.DefaultPermission in project studio by craftercms.
the class CompositePermissionResolverImpl method getPermission.
@Override
public Permission getPermission(String username, Map<String, Object> resourceIds) throws PermissionException {
String siteName = "";
List<String> paths = new ArrayList<String>();
if (MapUtils.isNotEmpty(resourceIds)) {
if (resourceIds.containsKey(SITE_ID_RESOURCE_ID)) {
siteName = (String) resourceIds.get(SITE_ID_RESOURCE_ID);
if (StringUtils.equals(siteName, studioConfiguration.getProperty(CONFIGURATION_GLOBAL_SYSTEM_SITE))) {
siteName = StringUtils.EMPTY;
}
}
if (resourceIds.containsKey(PATH_RESOURCE_ID)) {
paths.add((String) resourceIds.get(PATH_RESOURCE_ID));
}
if (resourceIds.containsKey(PATH_LIST_RESOURCE_ID)) {
paths = (List<String>) resourceIds.get(PATH_LIST_RESOURCE_ID);
}
}
if (CollectionUtils.isEmpty(paths)) {
paths.add("/");
}
String finalSiteName = siteName;
CompositePermission permission = paths.stream().map(x -> {
DefaultPermission dp = new DefaultPermission();
Set<String> allowedActions = securityService.getUserPermissions(finalSiteName, x, username, null);
dp.setAllowedActions(allowedActions);
return dp;
}).collect(CompositePermission::new, CompositePermission::addPermission, CompositePermission::addPermission);
return permission;
}
use of org.craftercms.commons.security.permissions.DefaultPermission in project studio by craftercms.
the class PermissionResolverImpl method getPermission.
@Override
public Permission getPermission(String username, Map<String, Object> resourceIds) throws PermissionException {
String siteName = "";
String path = "/";
if (MapUtils.isNotEmpty(resourceIds)) {
if (resourceIds.containsKey(SITE_ID_RESOURCE_ID)) {
siteName = (String) resourceIds.get(SITE_ID_RESOURCE_ID);
if (StringUtils.equals(siteName, studioConfiguration.getProperty(CONFIGURATION_GLOBAL_SYSTEM_SITE))) {
siteName = StringUtils.EMPTY;
}
}
if (resourceIds.containsKey(PATH_RESOURCE_ID)) {
path = (String) resourceIds.get(PATH_RESOURCE_ID);
}
}
Set<String> allowedActions = securityService.getUserPermissions(siteName, path, username, null);
DefaultPermission permission = new DefaultPermission();
permission.setAllowedActions(allowedActions);
return permission;
}
Aggregations