Search in sources :

Example 6 with PolicyPlugin

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

the class ResourceOperations method processPreResourcePolicyPlugins.

private ResourceRequest processPreResourcePolicyPlugins(ResourceRequest resourceReq) throws StopProcessingException {
    HashMap<String, Set<String>> requestPolicyMap = new HashMap<>();
    for (PolicyPlugin plugin : frameworkProperties.getPolicyPlugins()) {
        PolicyResponse policyResponse = plugin.processPreResource(resourceReq);
        opsSecuritySupport.buildPolicyMap(requestPolicyMap, policyResponse.operationPolicy().entrySet());
    }
    resourceReq.getProperties().put(PolicyPlugin.OPERATION_SECURITY, requestPolicyMap);
    return resourceReq;
}
Also used : Set(java.util.Set) HashMap(java.util.HashMap) PolicyPlugin(ddf.catalog.plugin.PolicyPlugin) PolicyResponse(ddf.catalog.plugin.PolicyResponse)

Example 7 with PolicyPlugin

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

the class DeleteOperations method processPreDeletePolicyPlugins.

private DeleteRequest processPreDeletePolicyPlugins(DeleteRequest deleteRequest) throws StopProcessingException {
    List<Metacard> metacards = getDeleteMetacards(deleteRequest);
    Map<String, Serializable> unmodifiableProperties = Collections.unmodifiableMap(deleteRequest.getProperties());
    HashMap<String, Set<String>> requestPolicyMap = new HashMap<>();
    for (PolicyPlugin plugin : frameworkProperties.getPolicyPlugins()) {
        PolicyResponse policyResponse = plugin.processPreDelete(metacards, unmodifiableProperties);
        opsSecuritySupport.buildPolicyMap(requestPolicyMap, policyResponse.operationPolicy().entrySet());
    }
    deleteRequest.getProperties().put(PolicyPlugin.OPERATION_SECURITY, requestPolicyMap);
    return deleteRequest;
}
Also used : Metacard(ddf.catalog.data.Metacard) Serializable(java.io.Serializable) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) PolicyPlugin(ddf.catalog.plugin.PolicyPlugin) PolicyResponse(ddf.catalog.plugin.PolicyResponse)

Example 8 with PolicyPlugin

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

the class CreateOperations method updateCreateRequestPolicyMap.

private CreateRequest updateCreateRequestPolicyMap(CreateRequest createRequest) throws StopProcessingException {
    Map<String, Serializable> unmodifiablePropertiesMap = Collections.unmodifiableMap(createRequest.getProperties());
    HashMap<String, Set<String>> requestPolicyMap = new HashMap<>();
    for (Metacard metacard : createRequest.getMetacards()) {
        HashMap<String, Set<String>> itemPolicyMap = new HashMap<>();
        for (PolicyPlugin plugin : frameworkProperties.getPolicyPlugins()) {
            PolicyResponse policyResponse = plugin.processPreCreate(metacard, unmodifiablePropertiesMap);
            opsSecuritySupport.buildPolicyMap(itemPolicyMap, policyResponse.itemPolicy().entrySet());
            opsSecuritySupport.buildPolicyMap(requestPolicyMap, policyResponse.operationPolicy().entrySet());
        }
        metacard.setAttribute(new AttributeImpl(Metacard.SECURITY, itemPolicyMap));
    }
    createRequest.getProperties().put(PolicyPlugin.OPERATION_SECURITY, requestPolicyMap);
    return createRequest;
}
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)

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