@@ -0,0 +1,2773 @@
+/*%0A * To change this template, choose Tools %7C Templates%0A * and open the template in the editor.%0A */%0A%0Apackage gov.hhs.fha.nhinc.docquery;%0A%0Aimport gov.hhs.fha.nhinc.common.eventcommon.AdhocQueryRequestEventType;%0Aimport gov.hhs.fha.nhinc.common.nhinccommon.AssertionType;%0Aimport gov.hhs.fha.nhinc.common.nhinccommonadapter.CheckPolicyRequestType;%0Aimport gov.hhs.fha.nhinc.common.nhinccommonadapter.CheckPolicyResponseType;%0Aimport gov.hhs.fha.nhinc.nhinclib.NhincConstants;%0Aimport gov.hhs.fha.nhinc.nhinclib.NullChecker;%0Aimport gov.hhs.fha.nhinc.policyengine.PolicyEngineChecker;%0Aimport gov.hhs.fha.nhinc.policyengine.proxy.PolicyEngineProxy;%0Aimport gov.hhs.fha.nhinc.policyengine.proxy.PolicyEngineProxyObjectFactory;%0Aimport oasis.names.tc.ebxml_regrep.xsd.query._3.AdhocQueryRequest;%0Aimport oasis.names.tc.xacml._2_0.context.schema.os.DecisionType;%0A%0A/**%0A *%0A * @author JHOPPESC%0A */%0Apublic class DocQueryPolicyChecker %7B%0A    /**%0A     * Checks to see if the security policy will permit the query to be executed.%0A     * @param message The AdhocQuery request message.%0A     * @return Returns true if the security policy permits the query; false if denied.%0A     */%0A    public boolean checkIncomingPolicy(AdhocQueryRequest message, AssertionType assertion) %7B%0A        boolean policyIsValid = false;%0A%0A        //convert the request message to an object recognized by the policy engine%0A        AdhocQueryRequestEventType policyCheckReq = new AdhocQueryRequestEventType();%0A        policyCheckReq.setDirection(NhincConstants.POLICYENGINE_INBOUND_DIRECTION);%0A        gov.hhs.fha.nhinc.common.eventcommon.AdhocQueryRequestMessageType request = new gov.hhs.fha.nhinc.common.eventcommon.AdhocQueryRequestMessageType();%0A        request.setAssertion(assertion);%0A        request.setAdhocQueryRequest(message);%0A        policyCheckReq.setMessage(request);%0A%0A        //call the policy engine to check the permission on the request%0A        PolicyEngineChecker policyChecker = new PolicyEngineChecker();%0A        CheckPolicyRequestType policyReq = policyChecker.checkPolicyAdhocQuery(policyCheckReq);%0A        policyReq.setAssertion(assertion);%0A        PolicyEngineProxyObjectFactory policyEngFactory = new PolicyEngineProxyObjectFactory();%0A        PolicyEngineProxy policyProxy = policyEngFactory.getPolicyEngineProxy();%0A        CheckPolicyResponseType policyResp = policyProxy.checkPolicy(policyReq);%0A%0A        //check the policy engine's response, return true if response = permit%0A        if (policyResp.getResponse() != null &&%0A                NullChecker.isNotNullish(policyResp.getResponse().getResult()) &&%0A                policyResp.getResponse().getResult().get(0).getDecision() == DecisionType.PERMIT)%0A        %7B%0A            policyIsValid = true;%0A        %7D%0A%0A        return policyIsValid;%0A    %7D%0A%0A%7D%0A

#26888 Add in incoming policy check