use of ddf.catalog.plugin.impl.PolicyResponseImpl in project ddf by codice.
the class MetacardValidityFilterPlugin method processPostQuery.
@Override
public PolicyResponse processPostQuery(Result input, Map<String, Serializable> properties) throws StopProcessingException {
if (input == null || input.getMetacard() == null) {
return new PolicyResponseImpl();
}
Metacard metacard = input.getMetacard();
HashMap<String, Set<String>> securityMap = new HashMap<>();
if (isMarkedForFilter(filterErrors, metacard, Validation.VALIDATION_ERRORS) || isMarkedForFilter(filterWarnings, metacard, Validation.VALIDATION_WARNINGS)) {
for (Map.Entry<String, List<String>> attributeMapping : attributeMap.entrySet()) {
securityMap.put(attributeMapping.getKey(), new HashSet<>(attributeMapping.getValue()));
}
}
return new PolicyResponseImpl(new HashMap<>(), securityMap);
}
use of ddf.catalog.plugin.impl.PolicyResponseImpl in project ddf by codice.
the class RegistryPolicyPlugin method getWritePolicy.
private PolicyResponse getWritePolicy(Metacard input, Map<String, Serializable> properties, Map<String, Set<String>> policy) {
Map<String, Set<String>> operationPolicy = new HashMap<>();
Map<String, Set<String>> securityAttributes = new HashMap<>();
if (Requests.isLocal(properties) && input != null && (RegistryUtility.isInternalRegistryMetacard(input) || RegistryUtility.isRegistryMetacard(input))) {
Attribute securityAttribute = input.getAttribute(RegistryObjectMetacardType.SECURITY_LEVEL);
if (securityAttribute != null) {
securityAttributes.putAll(Permissions.parsePermissionsFromString(securityAttribute.getValues().stream().map(Object::toString).collect(Collectors.toList())));
}
String registryBaseUrl = RegistryUtility.getStringAttribute(input, RegistryObjectMetacardType.REGISTRY_BASE_URL, null);
if (isRegistryDisabled() || (registryBaseUrl != null && registryBaseUrl.startsWith(SystemBaseUrl.getBaseUrl()))) {
operationPolicy.putAll(bypassAccessPolicy);
} else {
operationPolicy.putAll(policy);
}
}
if (securityAttributes.isEmpty()) {
return new PolicyResponseImpl(operationPolicy, operationPolicy);
} else {
return new PolicyResponseImpl(operationPolicy, securityAttributes);
}
}
use of ddf.catalog.plugin.impl.PolicyResponseImpl in project ddf by codice.
the class PointOfContactPolicyPlugin method processPreUpdate.
@Override
public PolicyResponse processPreUpdate(Metacard newMetacard, Map<String, Serializable> properties) throws StopProcessingException {
//If it's not a resource metacard, don't apply the policy.
if (!newMetacard.getTags().isEmpty() && !newMetacard.getTags().contains("resource")) {
return new PolicyResponseImpl();
}
List<Metacard> previousStateMetacards = ((OperationTransaction) properties.get(OPERATION_TRANSACTION_KEY)).getPreviousStateMetacards();
Metacard previous;
try {
previous = previousStateMetacards.stream().filter((x) -> x.getId().equals(newMetacard.getId())).findFirst().get();
} catch (NoSuchElementException e) {
LOGGER.debug("Cannot locate metacard {} for update.", newMetacard.getId());
return new PolicyResponseImpl();
}
return pointOfContactChanged(newMetacard, previous) ? new PolicyResponseImpl(null, PERMISSION_MAP) : new PolicyResponseImpl();
}
use of ddf.catalog.plugin.impl.PolicyResponseImpl in project ddf by codice.
the class ResourceUriPolicy method processPreUpdate.
@Override
public PolicyResponse processPreUpdate(Metacard input, Map<String, Serializable> properties) throws StopProcessingException {
if (!Requests.isLocal(properties)) {
return new PolicyResponseImpl();
}
PolicyResponseImpl policyResponse = new PolicyResponseImpl(null, Permissions.parsePermissionsFromString(getUpdatePermissions()));
List<Metacard> previousStateMetacards = ((OperationTransaction) properties.get(OPERATION_TRANSACTION_KEY)).getPreviousStateMetacards();
Metacard previous;
try {
previous = previousStateMetacards.stream().filter((x) -> x.getId().equals(input.getId())).findFirst().get();
} catch (NoSuchElementException e) {
LOGGER.debug("Cannot locate metacard {} for update. Applying permissions to the item", input.getId());
return policyResponse;
}
return requiresPermission(input.getResourceURI(), previous.getResourceURI()) ? policyResponse : new PolicyResponseImpl();
}
use of ddf.catalog.plugin.impl.PolicyResponseImpl in project ddf by codice.
the class FilterPostQueryPlugin method processPostQuery.
@Override
public PolicyResponse processPostQuery(Result input, Map<String, Serializable> properties) throws StopProcessingException {
HashMap<String, Set<String>> securityFinalMap = new HashMap<>();
securityFinalMap.put(Metacard.POINT_OF_CONTACT, new HashSet(Arrays.asList("admin")));
return new PolicyResponseImpl(new HashMap<>(), securityFinalMap);
}
Aggregations