use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class MetacardValidityFilterPluginTest method testValidMetacards.
@Test
public void testValidMetacards() throws Exception {
Result result = mock(Result.class);
PolicyResponse response = filterPluginResponseHelper(result, getValidMetacard(), true, false);
assertThat(response.itemPolicy().size(), is(0));
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class ResourceOperations method processPostResourcePolicyPlugins.
private ResourceResponse processPostResourcePolicyPlugins(ResourceResponse resourceResponse, Metacard metacard) throws StopProcessingException {
HashMap<String, Set<String>> responsePolicyMap = new HashMap<>();
for (PolicyPlugin plugin : frameworkProperties.getPolicyPlugins()) {
PolicyResponse policyResponse = plugin.processPostResource(resourceResponse, metacard);
opsSecuritySupport.buildPolicyMap(responsePolicyMap, policyResponse.operationPolicy().entrySet());
}
resourceResponse.getProperties().put(PolicyPlugin.OPERATION_SECURITY, responsePolicyMap);
return resourceResponse;
}
use of ddf.catalog.plugin.PolicyResponse in project ddf by codice.
the class DeleteOperations method populateDeleteRequestPolicyMap.
private DeleteRequest populateDeleteRequestPolicyMap(DeleteRequest deleteRequest, DeleteResponse deleteResponse) throws StopProcessingException {
HashMap<String, Set<String>> responsePolicyMap = new HashMap<>();
Map<String, Serializable> unmodifiableProperties = Collections.unmodifiableMap(deleteRequest.getProperties());
if (deleteResponse != null && deleteResponse.getDeletedMetacards() != null) {
for (Metacard metacard : deleteResponse.getDeletedMetacards()) {
HashMap<String, Set<String>> itemPolicyMap = new HashMap<>();
for (PolicyPlugin plugin : frameworkProperties.getPolicyPlugins()) {
PolicyResponse policyResponse = plugin.processPostDelete(metacard, unmodifiableProperties);
opsSecuritySupport.buildPolicyMap(itemPolicyMap, policyResponse.itemPolicy().entrySet());
opsSecuritySupport.buildPolicyMap(responsePolicyMap, policyResponse.operationPolicy().entrySet());
}
metacard.setAttribute(new AttributeImpl(Metacard.SECURITY, itemPolicyMap));
}
}
deleteRequest.getProperties().put(PolicyPlugin.OPERATION_SECURITY, responsePolicyMap);
return deleteRequest;
}
use of ddf.catalog.plugin.PolicyResponse 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.PolicyResponse in project ddf by codice.
the class PointOfContactPolicyPluginTest method processPostDeleteDoesNothing.
@Test
public void processPostDeleteDoesNothing() throws java.lang.Exception {
PolicyResponse response = pointOfContactPolicyPlugin.processPostDelete(new MetacardImpl(), Collections.emptyMap());
responseIsEmpty(response);
}
Aggregations