Exemple #1
0
  /**
   * Enforces message Consent header processiong rules defined in the spec.
   *
   * @param consH a Consent header
   * @param messageID the messageID in Correlation header
   * @param isServer true if this is a server
   * @throws SOAPBindingException if the Consent header violates rules on client side
   * @throws SOAPFaultException if the Consent header violates rules on server side
   */
  static void checkConsentHeader(ConsentHeader consH, String messageID, boolean isServer)
      throws SOAPBindingException, SOAPFaultException {
    if (consH == null) {
      return;
    }

    try {
      checkActorAndMustUnderstand(consH.getActor(), consH.getMustUnderstand(), messageID, isServer);
    } catch (SOAPFaultException sfe) {
      sfe.getSOAPFaultMessage().getSOAPFault().getDetail().setConsentHeader(consH);
      throw sfe;
    }
  }
Exemple #2
0
  /**
   * Enforces message Usage Directive header processiong rules defined in the spec.
   *
   * @param usagH a Usage Directive header
   * @param messageID the messageID in Correlation header
   * @param isServer true if this is a server
   * @throws SOAPBindingException if the Usage Directive header violates rules on client side
   * @throws SOAPFaultException if the Usage Directive header violates rules on server side
   */
  static void checkUsageDirectiveHeader(
      UsageDirectiveHeader usagH, String messageID, boolean isServer)
      throws SOAPBindingException, SOAPFaultException {
    if (usagH == null) {
      return;
    }

    try {
      checkActorAndMustUnderstand(usagH.getActor(), usagH.getMustUnderstand(), messageID, isServer);
    } catch (SOAPFaultException sfe) {
      List usagHs = new ArrayList();
      usagHs.add(usagH);
      sfe.getSOAPFaultMessage().getSOAPFault().getDetail().setUsageDirectiveHeaders(usagHs);
      throw sfe;
    }
  }
Exemple #3
0
  /**
   * Enforces message Provider header processing rules defined in the spec.
   *
   * @param provH a Correlation header
   * @param messageID the messageID in Correlation header
   * @param isServer true if this is a server
   * @throws SOAPBindingException if the Provider header violates rules on client side
   * @throws SOAPFaultException if the Provider header violates rules on server side
   */
  static void checkProviderHeader(ProviderHeader provH, String messageID, boolean isServer)
      throws SOAPBindingException, SOAPFaultException {

    if (provH == null) {
      return;
    }

    try {
      checkActorAndMustUnderstand(provH.getActor(), provH.getMustUnderstand(), messageID, isServer);
    } catch (SOAPFaultException sfe) {
      sfe.getSOAPFaultMessage().getSOAPFault().getDetail().setProviderHeader(provH);
      throw sfe;
    }

    if (isServer && SOAPBindingService.enforceOnlyKnownProviders()) {
      String providerID = provH.getProviderID();
      ProviderManager providerManager = ProviderUtil.getProviderManager();

      if (!providerManager.containsProvider(providerID)) {
        SOAPFaultDetail sfd =
            new SOAPFaultDetail(SOAPFaultDetail.PROVIDER_ID_NOT_VALID, messageID, null);
        sfd.setProviderHeader(provH);
        SOAPFault sf = new SOAPFault(FAULT_CODE_SERVER, faultStringServerError, null, sfd);
        throw new SOAPFaultException(new Message(sf));
      }

      String affID = provH.getAffiliationID();
      if ((affID != null) && (!providerManager.isAffiliationMember(providerID, affID))) {

        SOAPFaultDetail sfd =
            new SOAPFaultDetail(SOAPFaultDetail.AFFILIATION_ID_NOT_VALID, messageID, null);
        sfd.setProviderHeader(provH);
        SOAPFault sf = new SOAPFault(FAULT_CODE_SERVER, faultStringServerError, null, sfd);
        throw new SOAPFaultException(new Message(sf));
      }
    }
  }
Exemple #4
0
  /**
   * Enforces message Processing Context header processiong rules defined in the spec.
   *
   * @param procH a Processing Context header
   * @param messageID the messageID in Correlation header
   * @param isServer true if this is a server
   * @throws SOAPBindingException if the Processing Context header violates rules on client side
   * @throws SOAPFaultException if the Processing Context header violates rules on server side
   */
  static void checkProcessingContextHeader(
      ProcessingContextHeader procH, String messageID, boolean isServer)
      throws SOAPBindingException, SOAPFaultException {
    if (procH == null) {
      return;
    }

    try {
      checkActorAndMustUnderstand(procH.getActor(), procH.getMustUnderstand(), messageID, isServer);
    } catch (SOAPFaultException sfe) {
      sfe.getSOAPFaultMessage().getSOAPFault().getDetail().setProcessingContextHeader(procH);
      throw sfe;
    }

    if (isServer) {
      SOAPFaultDetail sfd =
          new SOAPFaultDetail(SOAPFaultDetail.PROC_CTX_URI_NOT_UNSTD, messageID, null);
      sfd.setProcessingContextHeader(procH);
      SOAPFault sf = new SOAPFault(FAULT_CODE_SERVER, faultStringServerError, null, sfd);
      throw new SOAPFaultException(new Message(sf));
    } else {
      throw new SOAPBindingException(bundle.getString("ProcessingContextUnsupported"));
    }
  }
Exemple #5
0
  /**
   * Enforces message Correlation header processiong rules defined in the spec.
   *
   * @param corrH a Correlation header
   * @param requestMessageID the request messageID if we are checking a response message or null if
   *     we are checking a request message
   * @param isServer true if this is a server
   * @throws SOAPBindingException if the Correlation header violates rules on client side
   * @throws SOAPFaultException if the Correlation header violates rules on server side
   */
  static void checkCorrelationHeader(
      CorrelationHeader corrH, String requestMessageID, boolean isServer)
      throws SOAPBindingException, SOAPFaultException {
    if (corrH == null) {
      if (isServer) {
        SOAPFault sf =
            new SOAPFault(
                FAULT_CODE_SERVER,
                faultStringServerError,
                null,
                new SOAPFaultDetail(SOAPFaultDetail.ID_STAR_MSG_NOT_UNSTD, null, null));
        throw new SOAPFaultException(new Message(sf));
      } else {
        throw new SOAPBindingException(bundle.getString("CorrelationHeaderNull"));
      }
    }

    String messageID = corrH.getMessageID();

    try {
      checkActorAndMustUnderstand(corrH.getActor(), corrH.getMustUnderstand(), messageID, isServer);
    } catch (SOAPFaultException sfe) {
      sfe.getSOAPFaultMessage().getSOAPFault().getDetail().setCorrelationHeader(corrH);
      throw sfe;
    }

    Date timestamp = corrH.getTimestamp();
    Date now = new Date();
    if ((now.getTime() - timestamp.getTime()) > stale_time_limit) {
      if (isServer) {
        SOAPFaultDetail sfd = new SOAPFaultDetail(SOAPFaultDetail.STALE_MSG, messageID, null);
        sfd.setCorrelationHeader(corrH);
        SOAPFault sf = new SOAPFault(FAULT_CODE_SERVER, faultStringServerError, null, sfd);
        throw new SOAPFaultException(new Message(sf));

      } else {
        throw new SOAPBindingException(bundle.getString("staleMsg"));
      }
    }

    Long prevMsgIDTime = (Long) messageIDMap.get(messageID);
    long currentTime = System.currentTimeMillis();
    if (prevMsgIDTime != null && currentTime - prevMsgIDTime.longValue() < stale_time_limit) {

      if (isServer) {
        SOAPFaultDetail sfd = new SOAPFaultDetail(SOAPFaultDetail.DUPLICATE_MSG, messageID, null);
        sfd.setCorrelationHeader(corrH);
        SOAPFault sf = new SOAPFault(FAULT_CODE_SERVER, faultStringServerError, null, sfd);
        throw new SOAPFaultException(new Message(sf));

      } else {
        throw new SOAPBindingException(bundle.getString("dupMsg"));
      }
    } else {
      synchronized (messageIDMap) {
        if (debug.messageEnabled()) {
          debug.message("Utils.checkCorrelationHeader: adding " + "messageID: " + messageID);
        }
        messageIDMap.put(messageID, new Long(currentTime));
      }
    }

    String refToMessageID = corrH.getRefToMessageID();
    if (refToMessageID != null
        && requestMessageID != null
        && !refToMessageID.equals(requestMessageID)) {

      if (isServer) {
        SOAPFaultDetail sfd =
            new SOAPFaultDetail(SOAPFaultDetail.INVALID_REF_TO_MSG_ID, messageID, null);
        sfd.setCorrelationHeader(corrH);
        SOAPFault sf = new SOAPFault(FAULT_CODE_SERVER, faultStringServerError, null, sfd);
        throw new SOAPFaultException(new Message(sf));

      } else {
        throw new SOAPBindingException(bundle.getString("invalidRef"));
      }
    }
  }