private boolean isPolicyValid(
      RespondingGatewayProvideAndRegisterDocumentSetSecuredRequestType request,
      AssertionType assertion) {
    boolean isValid = false;

    if (hasNhinTargetHomeCommunityId(request)) {
      String senderHCID =
          getSubjectHelper()
              .determineSendingHomeCommunityId(assertion.getHomeCommunity(), assertion);
      String receiverHCID = getNhinTargetHomeCommunityId(request);
      LOG.debug("Receiving home community id: " + receiverHCID);
      isValid =
          getXDRPolicyChecker()
              .checkXDRRequestPolicy(
                  request.getProvideAndRegisterDocumentSetRequest(),
                  assertion,
                  senderHCID,
                  receiverHCID,
                  NhincConstants.POLICYENGINE_OUTBOUND_DIRECTION);
    } else {
      LOG.warn(
          "Check on policy requires a non null target home community ID specified in the request");
    }
    LOG.debug("Check on policy returns: " + isValid);

    return isValid;
  }