@Override
  public void filterAbstractHttpRequest(SubmitContext context, AbstractHttpRequest<?> request) {
    HttpRequestBase httpMethod =
        (HttpRequestBase) context.getProperty(BaseHttpRequestTransport.HTTP_METHOD);

    String strURL = request.getEndpoint();
    strURL = PropertyExpander.expandProperties(context, strURL);
    try {
      if (StringUtils.hasContent(strURL)) {
        URI uri = new URI(strURL, request.getSettings().getBoolean(HttpSettings.ENCODED_URLS));
        context.setProperty(BaseHttpRequestTransport.REQUEST_URI, uri);
        httpMethod.setURI(HttpUtils.createUri(uri));
      }
    } catch (Exception e) {
      SoapUI.logError(e);
    }
  }
  public void filterAbstractHttpRequest(SubmitContext context, AbstractHttpRequest<?> wsdlRequest) {
    if (!wsdlRequest.isStripWhitespaces()) {
      return;
    }

    String content = (String) context.getProperty(BaseHttpRequestTransport.REQUEST_CONTENT);
    if (content == null) {
      log.warn("Missing request content in context, skipping stripWhitespaces");
    } else {
      content = XmlUtils.stripWhitespaces(content);
      context.setProperty(BaseHttpRequestTransport.REQUEST_CONTENT, content);
    }
  }
Esempio n. 3
0
  private void getAllMessages(ModelItem modelItem, List<AbstractWsdlModelItem<?>> list) {
    if (modelItem instanceof AbstractHttpRequestInterface<?>) {
      AbstractHttpRequest<?> wsdlRequest = (AbstractHttpRequest<?>) modelItem;
      if (wsdlRequest.getOperation().getInterface() == this) list.add(wsdlRequest);
    } else if (modelItem instanceof WsdlTestRequestStep) {
      WsdlTestRequestStep testRequestStep = (WsdlTestRequestStep) modelItem;
      WsdlTestRequest testRequest = testRequestStep.getTestRequest();
      if (testRequest != null
          && testRequest.getOperation() != null
          && testRequest.getOperation().getInterface() == this) list.add(testRequest);
    } else if (modelItem instanceof WsdlMockResponse) {
      WsdlMockResponse mockResponse = (WsdlMockResponse) modelItem;
      if (mockResponse.getMockOperation() != null
          && mockResponse.getMockOperation().getOperation() != null
          && mockResponse.getMockOperation().getOperation().getInterface() == this)
        list.add(mockResponse);
    }

    // Traverse the ModelItem hierarchy.
    for (ModelItem child : modelItem.getChildren()) {
      getAllMessages(child, list);
    }
  }
  @Override
  public void filterAbstractHttpRequest(SubmitContext context, AbstractHttpRequest<?> httpRequest) {
    Settings settings = httpRequest.getSettings();
    String compressionAlg = settings.getString(HttpSettings.REQUEST_COMPRESSION, "None");
    if (!"None".equals(compressionAlg)) {
      try {
        ExtendedHttpMethod method =
            (ExtendedHttpMethod) context.getProperty(BaseHttpRequestTransport.HTTP_METHOD);
        if (method instanceof HttpEntityEnclosingRequest) {
          HttpEntity requestEntity = ((HttpEntityEnclosingRequest) method).getEntity();
          if (requestEntity != null) {
            ByteArrayOutputStream tempOut = new ByteArrayOutputStream();
            requestEntity.writeTo(tempOut);

            byte[] compressedData =
                CompressionSupport.compress(compressionAlg, tempOut.toByteArray());
            ((HttpEntityEnclosingRequest) method).setEntity(new ByteArrayEntity(compressedData));
          }
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
  protected void prepareRequestStep(HttpRequestTestStep requestStep) {
    AbstractHttpRequest<?> httpRequest = requestStep.getHttpRequest();
    if (StringUtils.hasContent(endpoint)) {
      httpRequest.setEndpoint(endpoint);
    } else if (StringUtils.hasContent(host)) {
      try {
        String ep = Tools.replaceHost(httpRequest.getEndpoint(), host);
        httpRequest.setEndpoint(ep);
      } catch (Exception e) {
        log.error("Failed to set host on endpoint", e);
      }
    }

    if (StringUtils.hasContent(username)) {
      httpRequest.setUsername(username);
    }

    if (StringUtils.hasContent(password)) {
      httpRequest.setPassword(password);
    }

    if (StringUtils.hasContent(domain)) {
      httpRequest.setDomain(domain);
    }

    if (httpRequest instanceof WsdlRequest) {

      if (wssPasswordType != null && wssPasswordType.length() > 0) {
        ((WsdlRequest) httpRequest)
            .setWssPasswordType(
                wssPasswordType.equals("Digest")
                    ? WsdlTestRequest.PW_TYPE_DIGEST
                    : WsdlTestRequest.PW_TYPE_TEXT);
      }
    }
  }
Esempio n. 6
0
  public JComponent getComponent() {
    if (mainPanel == null) {
      mainPanel = new JPanel(new BorderLayout());

      form = new SimpleBindingForm(new PresentationModel<AbstractHttpRequest<?>>(request));
      form.addSpace(5);
      form.appendComboBox(
          "authType",
          "Authorisation Type",
          new String[] {
            AuthType.GLOBAL_HTTP_SETTINGS.toString(),
            AuthType.PREEMPTIVE.toString(),
            AuthType.NTLM_KERBEROS.toString()
          },
          "");
      form.appendTextField("username", "Username", "The username to use for HTTP Authentication");
      form.appendPasswordField(
          "password", "Password", "The password to use for HTTP Authentication");
      form.appendTextField(
          "domain", "Domain", "The domain to use for Authentication(NTLM/Kerberos)");

      if (request instanceof WsdlRequest) {
        StringList outgoingNames =
            new StringList(
                request
                    .getOperation()
                    .getInterface()
                    .getProject()
                    .getWssContainer()
                    .getOutgoingWssNames());
        outgoingNames.add("");
        StringList incomingNames =
            new StringList(
                request
                    .getOperation()
                    .getInterface()
                    .getProject()
                    .getWssContainer()
                    .getIncomingWssNames());
        incomingNames.add("");

        form.addSpace(5);
        form.appendComboBox(
            "outgoingWss",
            "Outgoing WSS",
            outgoingNames.toStringArray(),
            "The outgoing WS-Security configuration to use");
        form.appendComboBox(
            "incomingWss",
            "Incoming WSS",
            incomingNames.toStringArray(),
            "The incoming WS-Security configuration to use");
      }

      form.addSpace(5);

      mainPanel.add(new JScrollPane(form.getPanel()), BorderLayout.CENTER);
    }

    return mainPanel;
  }