Search in sources :

Example 1 with PolicyPlugin

use of ddf.catalog.plugin.PolicyPlugin 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;
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) PolicyPlugin(ddf.catalog.plugin.PolicyPlugin) PolicyResponse(ddf.catalog.plugin.PolicyResponse)

Example 2 with PolicyPlugin

use of ddf.catalog.plugin.PolicyPlugin 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;
}
Also used : Serializable(java.io.Serializable) Metacard(ddf.catalog.data.Metacard) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) PolicyPlugin(ddf.catalog.plugin.PolicyPlugin) PolicyResponse(ddf.catalog.plugin.PolicyResponse)

Example 3 with PolicyPlugin

use of ddf.catalog.plugin.PolicyPlugin in project ddf by codice.

the class QueryOperations method populateQueryResponsePolicyMap.

private QueryResponse populateQueryResponsePolicyMap(QueryResponse queryResponse) throws FederationException {
    HashMap<String, Set<String>> responsePolicyMap = new HashMap<>();
    Map<String, Serializable> unmodifiableProperties = Collections.unmodifiableMap(queryResponse.getProperties());
    for (Result result : queryResponse.getResults()) {
        HashMap<String, Set<String>> itemPolicyMap = new HashMap<>();
        for (PolicyPlugin plugin : frameworkProperties.getPolicyPlugins()) {
            try {
                PolicyResponse policyResponse = plugin.processPostQuery(result, unmodifiableProperties);
                opsSecuritySupport.buildPolicyMap(itemPolicyMap, policyResponse.itemPolicy().entrySet());
                opsSecuritySupport.buildPolicyMap(responsePolicyMap, policyResponse.operationPolicy().entrySet());
            } catch (StopProcessingException e) {
                throw new FederationException("Query could not be executed.", e);
            }
        }
        result.getMetacard().setAttribute(new AttributeImpl(Metacard.SECURITY, itemPolicyMap));
    }
    queryResponse.getProperties().put(PolicyPlugin.OPERATION_SECURITY, responsePolicyMap);
    return queryResponse;
}
Also used : Serializable(java.io.Serializable) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) PolicyPlugin(ddf.catalog.plugin.PolicyPlugin) StopProcessingException(ddf.catalog.plugin.StopProcessingException) FederationException(ddf.catalog.federation.FederationException) PolicyResponse(ddf.catalog.plugin.PolicyResponse) Result(ddf.catalog.data.Result)

Example 4 with PolicyPlugin

use of ddf.catalog.plugin.PolicyPlugin in project ddf by codice.

the class QueryOperations method populateQueryRequestPolicyMap.

private QueryRequest populateQueryRequestPolicyMap(QueryRequest queryReq) throws FederationException {
    HashMap<String, Set<String>> requestPolicyMap = new HashMap<>();
    Map<String, Serializable> unmodifiableProperties = Collections.unmodifiableMap(queryReq.getProperties());
    for (PolicyPlugin plugin : frameworkProperties.getPolicyPlugins()) {
        try {
            PolicyResponse policyResponse = plugin.processPreQuery(queryReq.getQuery(), unmodifiableProperties);
            opsSecuritySupport.buildPolicyMap(requestPolicyMap, policyResponse.operationPolicy().entrySet());
        } catch (StopProcessingException e) {
            throw new FederationException("Query could not be executed.", e);
        }
    }
    queryReq.getProperties().put(PolicyPlugin.OPERATION_SECURITY, requestPolicyMap);
    return queryReq;
}
Also used : Serializable(java.io.Serializable) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) PolicyPlugin(ddf.catalog.plugin.PolicyPlugin) StopProcessingException(ddf.catalog.plugin.StopProcessingException) FederationException(ddf.catalog.federation.FederationException) PolicyResponse(ddf.catalog.plugin.PolicyResponse)

Example 5 with PolicyPlugin

use of ddf.catalog.plugin.PolicyPlugin in project ddf by codice.

the class UpdateOperations method populateUpdateRequestPolicyMap.

private UpdateRequest populateUpdateRequestPolicyMap(UpdateRequest updateRequest) throws StopProcessingException {
    Map<String, Metacard> metacardMap = getUpdateMap(updateRequest);
    HashMap<String, Set<String>> requestPolicyMap = new HashMap<>();
    for (Map.Entry<Serializable, Metacard> update : updateRequest.getUpdates()) {
        HashMap<String, Set<String>> itemPolicyMap = new HashMap<>();
        HashMap<String, Set<String>> oldItemPolicyMap = new HashMap<>();
        Metacard oldMetacard = metacardMap.get(update.getKey().toString());
        for (PolicyPlugin plugin : frameworkProperties.getPolicyPlugins()) {
            PolicyResponse updatePolicyResponse = plugin.processPreUpdate(update.getValue(), Collections.unmodifiableMap(updateRequest.getProperties()));
            PolicyResponse oldPolicyResponse = plugin.processPreUpdate(oldMetacard, Collections.unmodifiableMap(updateRequest.getProperties()));
            opsSecuritySupport.buildPolicyMap(itemPolicyMap, updatePolicyResponse.itemPolicy().entrySet());
            opsSecuritySupport.buildPolicyMap(oldItemPolicyMap, oldPolicyResponse.itemPolicy().entrySet());
            opsSecuritySupport.buildPolicyMap(requestPolicyMap, updatePolicyResponse.operationPolicy().entrySet());
        }
        update.getValue().setAttribute(new AttributeImpl(Metacard.SECURITY, itemPolicyMap));
        if (oldMetacard != null) {
            oldMetacard.setAttribute(new AttributeImpl(Metacard.SECURITY, oldItemPolicyMap));
        }
    }
    updateRequest.getProperties().put(PolicyPlugin.OPERATION_SECURITY, requestPolicyMap);
    return updateRequest;
}
Also used : Metacard(ddf.catalog.data.Metacard) Serializable(java.io.Serializable) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) AttributeImpl(ddf.catalog.data.impl.AttributeImpl) PolicyPlugin(ddf.catalog.plugin.PolicyPlugin) Map(java.util.Map) HashMap(java.util.HashMap) AbstractMap(java.util.AbstractMap) PolicyResponse(ddf.catalog.plugin.PolicyResponse)

Aggregations

PolicyPlugin (ddf.catalog.plugin.PolicyPlugin)8 PolicyResponse (ddf.catalog.plugin.PolicyResponse)8 HashMap (java.util.HashMap)8 Set (java.util.Set)8 Serializable (java.io.Serializable)6 HashSet (java.util.HashSet)6 Metacard (ddf.catalog.data.Metacard)4 AttributeImpl (ddf.catalog.data.impl.AttributeImpl)4 FederationException (ddf.catalog.federation.FederationException)2 StopProcessingException (ddf.catalog.plugin.StopProcessingException)2 Result (ddf.catalog.data.Result)1 AbstractMap (java.util.AbstractMap)1 Map (java.util.Map)1