Beispiel #1
0
 @Override
 public PolicyResponse processPreDelete(
     List<Metacard> metacards, Map<String, Serializable> properties)
     throws StopProcessingException {
   if (metacards != null) {
     for (Metacard metacard : metacards) {
       PolicyResponse response = getWritePolicy(metacard, properties);
       if (!response.operationPolicy().isEmpty()) {
         return response;
       }
     }
   }
   return new PolicyResponseImpl();
 }
Beispiel #2
0
  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;
  }
Beispiel #3
0
  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;
  }