Ejemplo n.º 1
0
  /**
   * For HttpResendRunnable
   *
   * @param original
   */
  public AbstractExchange(AbstractExchange original) {
    properties = new HashMap<String, Object>(original.properties);
    originalRequestUri = original.originalRequestUri;

    List<String> origDests = original.getDestinations();
    for (String dest : origDests) {
      destinations.add(dest);
    }
    rule = original.getRule();
  }
  public Outcome handleRequest(AbstractExchange exchange) throws Exception {
    Document doc =
        getDocument(
            exchange.getRequest().getBodyAsStreamDecoded(), exchange.getRequest().getCharset());
    Element header = getAuthorisationHeader(doc);
    if (header == null) return Outcome.CONTINUE;
    // System.out.println(DOM2String(doc));
    Element nor = getNorElement(doc);
    nor.appendChild(getUsername(doc, header));
    nor.appendChild(getPassword(doc, header));

    header.getParentNode().removeChild(header);
    exchange
        .getRequest()
        .setBody(new Body(DOM2String(doc).getBytes(exchange.getRequest().getCharset())));
    return Outcome.CONTINUE;
  }