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; }
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; }