use of ddf.catalog.plugin.StopProcessingException in project ddf by codice.
the class SendEvent method sendEvent.
private void sendEvent(String operation, Metacard... metacards) {
if (subject == null) {
return;
}
try {
List<Result> results = Arrays.asList(metacards).stream().map(ResultImpl::new).collect(Collectors.toList());
QueryResponse queryResponse = new QueryResponseImpl(query, results, true, metacards.length);
CswRecordCollection recordCollection = new CswRecordCollection();
recordCollection.setElementName(elementName);
recordCollection.setElementSetType(elementSetType);
recordCollection.setById(false);
recordCollection.setRequest(request);
recordCollection.setResultType(resultType);
recordCollection.setDoWriteNamespaces(false);
recordCollection.setMimeType(mimeType);
recordCollection.setOutputSchema(outputSchema);
queryResponse.getRequest().getProperties().put(SecurityConstants.SECURITY_SUBJECT, subject);
for (AccessPlugin plugin : getAccessPlugins()) {
queryResponse = plugin.processPostQuery(queryResponse);
}
if (queryResponse.getResults().isEmpty()) {
return;
}
recordCollection.setSourceResponse(queryResponse);
send(operation, recordCollection);
} catch (StopProcessingException | InvalidSyntaxException e) {
LOGGER.debug("Unable to send event error running AccessPlugin processPostQuery. ", e);
}
}
use of ddf.catalog.plugin.StopProcessingException in project ddf by codice.
the class GeoCoderPlugin method process.
@Override
public CreateRequest process(CreateRequest input) throws PluginExecutionException, StopProcessingException {
if (input.getMetacards() == null) {
return input;
}
try {
GeoCoder geoCoder = geoCoderFactory.getService();
input.getMetacards().forEach(metacard -> setCountryCode(metacard, geoCoder));
} catch (Exception e) {
throw new PluginExecutionException("Unable to determine country code for data", e);
}
return input;
}
use of ddf.catalog.plugin.StopProcessingException in project ddf by codice.
the class OperationPlugin method checkOperation.
/**
* checkOperation will throw a StopProcessingException if the operation is not permitted based on
* the the subjects attributes and the operations property "operation.security"
*
* @param operation The operation to check
* @throws StopProcessingException
*/
private void checkOperation(Operation operation) throws StopProcessingException {
if (!operation.hasProperties() || !operation.containsPropertyName(PolicyPlugin.OPERATION_SECURITY)) {
return;
}
Object securityAssertion = operation.getPropertyValue(SecurityConstants.SECURITY_SUBJECT);
Subject subject;
if (securityAssertion instanceof Subject) {
subject = (Subject) securityAssertion;
} else {
throw new StopProcessingException("Unable to filter contents of current message, no user Subject available.");
}
Map<String, Set<String>> perms = (Map<String, Set<String>>) operation.getPropertyValue(PolicyPlugin.OPERATION_SECURITY);
KeyValueCollectionPermission securityPermission = permissions.buildKeyValueCollectionPermission(CollectionPermission.READ_ACTION, perms);
if (!subject.isPermitted(securityPermission)) {
String userName = "UNKNOWN";
if (subjectOperations != null) {
userName = subjectOperations.getName(subject, userName);
}
throw new StopProcessingException("User " + userName + " does not have the required attributes " + perms);
}
}
use of ddf.catalog.plugin.StopProcessingException 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;
previous = previousStateMetacards.stream().filter(x -> x.getId().equals(newMetacard.getId())).findFirst().orElse(null);
return pointOfContactChanged(newMetacard, previous) ? new PolicyResponseImpl(null, permissionMap) : new PolicyResponseImpl();
}
use of ddf.catalog.plugin.StopProcessingException in project ddf by codice.
the class FilterPluginTest method testPluginFilterNoStrategies.
@Test
public void testPluginFilterNoStrategies() {
plugin = new FilterPlugin(new Security());
plugin.setPermissions(new PermissionsImpl());
plugin.setSubjectOperations(new SubjectUtils());
plugin.setSecurityLogger(mock(SecurityLogger.class));
try {
QueryResponse response = plugin.processPostQuery(incomingResponse);
verifyFilterResponse(response);
} catch (StopProcessingException e) {
LOGGER.error("Stopped processing the redaction plugin", e);
}
}
Aggregations