Ejemplo n.º 1
0
  public AMFSubmit(AMFRequest request, SubmitContext submitContext, boolean async) {
    this.request = request;
    this.context = submitContext;

    List<SubmitListener> regListeners =
        SoapUI.getListenerRegistry().getListeners(SubmitListener.class);

    SubmitListener[] submitListeners = request.getSubmitListeners();
    this.listeners = new SubmitListener[submitListeners.length + regListeners.size()];
    for (int c = 0; c < submitListeners.length; c++) {
      this.listeners[c] = submitListeners[c];
    }

    for (int c = 0; c < regListeners.size(); c++) {
      this.listeners[submitListeners.length + c] = regListeners.get(c);
    }

    error = null;
    status = Status.INITIALIZED;
    timestamp = System.currentTimeMillis();

    if (async) {
      future = SoapUI.getThreadPool().submit(this);
    } else {
      run();
    }
  }
  public WsdlTestRequestDesktopPanel(WsdlTestRequestStep requestStep) {
    super(requestStep, requestStep.getTestRequest());

    SoapUI.getTestMonitor().addTestMonitorListener(testMonitorListener);
    setEnabled(!SoapUI.getTestMonitor().hasRunningTest(requestStep.getTestCase()));

    requestStep.getTestRequest().addAssertionsListener(assertionsListener);
  }
Ejemplo n.º 3
0
  /**
   * Cursor position Before: <theElement>^</theElement> After: <theElement><lots of
   * stuff/>^</theElement>
   */
  public void createSampleForType(SchemaType stype, XmlCursor xmlc) {
    _exampleContent =
        SoapUI.getSettings().getBoolean(WsdlSettings.XML_GENERATION_TYPE_EXAMPLE_VALUE);
    _typeComment = SoapUI.getSettings().getBoolean(WsdlSettings.XML_GENERATION_TYPE_COMMENT_TYPE);
    _skipComments = SoapUI.getSettings().getBoolean(WsdlSettings.XML_GENERATION_SKIP_COMMENTS);

    QName nm = stype.getName();
    if (nm == null && stype.getContainerField() != null) nm = stype.getContainerField().getName();

    if (nm != null && excludedTypes.contains(nm)) {
      if (!_skipComments) xmlc.insertComment("Ignoring type [" + nm + "]");
      return;
    }

    if (_typeStack.contains(stype)) return;

    _typeStack.add(stype);

    try {
      if (stype.isSimpleType() || stype.isURType()) {
        processSimpleType(stype, xmlc);
        return;
      }

      // complex Type
      // <theElement>^</theElement>
      processAttributes(stype, xmlc);

      // <theElement attri1="string">^</theElement>
      switch (stype.getContentType()) {
        case SchemaType.NOT_COMPLEX_TYPE:
        case SchemaType.EMPTY_CONTENT:
          // noop
          break;
        case SchemaType.SIMPLE_CONTENT:
          {
            processSimpleType(stype, xmlc);
          }
          break;
        case SchemaType.MIXED_CONTENT:
          xmlc.insertChars(pick(WORDS) + " ");
          if (stype.getContentModel() != null) {
            processParticle(stype.getContentModel(), xmlc, true);
          }
          xmlc.insertChars(pick(WORDS));
          break;
        case SchemaType.ELEMENT_CONTENT:
          if (stype.getContentModel() != null) {
            processParticle(stype.getContentModel(), xmlc, false);
          }
          break;
      }
    } finally {
      _typeStack.remove(_typeStack.size() - 1);
    }
  }
Ejemplo n.º 4
0
  @Override
  protected void execute(
      SecurityTestRunner securityTestRunner, TestStep testStep, SecurityTestRunContext context) {
    scriptEngine.setScript(groovyscc.getExecuteScript().getStringValue());
    scriptEngine.setVariable("context", context);
    scriptEngine.setVariable("testStep", testStep);
    scriptEngine.setVariable("securityScan", this);
    scriptEngine.setVariable("parameters", parameters);
    scriptEngine.setVariable("log", SoapUI.ensureGroovyLog());

    try {
      scriptResult = scriptEngine.run();
      hasNext = castResultToBoolean(scriptResult);
      XmlObjectTreeModel model = null;
      for (SecurityCheckedParameter scp : getParameterHolder().getParameterList()) {
        if (parameters.containsKey(scp.getLabel()) && parameters.get(scp.getLabel()) != null) {
          if (scp.isChecked() && scp.getXpath().trim().length() > 0) {
            model = SecurityScanUtil.getXmlObjectTreeModel(testStep, scp);
            XmlTreeNode[] treeNodes = null;
            treeNodes = model.selectTreeNodes(context.expand(scp.getXpath()));
            if (treeNodes.length > 0) {
              XmlTreeNode mynode = treeNodes[0];
              mynode.setValue(1, parameters.get(scp.getLabel()));
            }
            updateRequestProperty(testStep, scp.getName(), model.getXmlObject().toString());

          } else {
            updateRequestProperty(testStep, scp.getName(), parameters.get(scp.getLabel()));
          }
        } else if (parameters.containsKey(scp.getLabel())
            && parameters.get(scp.getLabel()) == null) { // clears null values form parameters
          parameters.remove(scp.getLabel());
        }
      }

      MessageExchange message =
          (MessageExchange) testStep.run((TestCaseRunner) securityTestRunner, context);
      createMessageExchange(clearNullValues(parameters), message, context);

    } catch (Exception e) {
      SoapUI.logError(e);
      hasNext = false;
    } finally {
      // if( scriptResult != null )
      // {
      // getTestStep().getProperty( "Request" ).setValue( ( String
      // )scriptResult );
      //
      // getTestStep().run( ( TestCaseRunner )securityTestRunner,
      // ( TestCaseRunContext )securityTestRunner.getRunContext() );
      // }

    }
  }
Ejemplo n.º 5
0
  private void initDefaultVectors() {
    try {
      InputStream in =
          SoapUI.class.getResourceAsStream(
              "/com/eviware/soapui/resources/security/xmlbomb/BillionLaughsAttack.xml.txt");
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      String strLine;
      StringBuffer value = new StringBuffer();
      while ((strLine = br.readLine()) != null) {
        value.append(strLine).append('\n');
      }
      in.close();
      XmlString bomb = xmlBombConfig.addNewXmlBombs();
      bomb.setStringValue(value.toString());
    } catch (Exception e) {
      SoapUI.logError(e);
    }

    try {
      InputStream in =
          SoapUI.class.getResourceAsStream(
              "/com/eviware/soapui/resources/security/xmlbomb/QuadraticBlowup.xml.txt");
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      String strLine;
      StringBuffer value = new StringBuffer();
      while ((strLine = br.readLine()) != null) {
        value.append(strLine).append('\n');
      }
      in.close();
      XmlString bomb = xmlBombConfig.addNewXmlBombs();
      bomb.setStringValue(value.toString());
    } catch (Exception e) {
      SoapUI.logError(e);
    }

    try {
      InputStream in =
          SoapUI.class.getResourceAsStream(
              "/com/eviware/soapui/resources/security/xmlbomb/ExternalEntity.dtd.txt");
      BufferedReader br = new BufferedReader(new InputStreamReader(in));
      String strLine;
      StringBuffer value = new StringBuffer();
      while ((strLine = br.readLine()) != null) {
        value.append(strLine).append('\n');
      }
      in.close();
      XmlString bomb = xmlBombConfig.addNewXmlBombs();
      bomb.setStringValue(value.toString());
    } catch (Exception e) {
      SoapUI.logError(e);
    }
  }
Ejemplo n.º 6
0
 private Boolean castResultToBoolean(Object scriptResult2) {
   try {
     hasNext = (Boolean) scriptResult2;
     if (hasNext == null) {
       hasNext = false;
       SoapUI.ensureGroovyLog().error("You must return Boolean value from groovy script!");
     }
   } catch (Exception e) {
     hasNext = false;
     SoapUI.ensureGroovyLog().error("You must return Boolean value from groovy script!");
   }
   return hasNext;
 }
Ejemplo n.º 7
0
 public void logout() {
   SoapUIAMFConnection connection =
       (SoapUIAMFConnection) context.getProperty(AMFSubmit.AMF_CONNECTION);
   CommandMessage commandMessage = createLogoutCommandMessage();
   try {
     connection.call((SubmitContext) context, null, commandMessage);
   } catch (ClientStatusException e) {
     SoapUI.logError(e);
   } catch (ServerStatusException e) {
     SoapUI.logError(e);
   } finally {
     connection.close();
   }
 }
Ejemplo n.º 8
0
  public TestStepResult run(TestCaseRunner testRunner, TestCaseRunContext context) {
    SoapUI.ensureGroovyLog();

    WsdlTestStepResult result = new WsdlTestStepResult(this);
    Logger log = (Logger) context.getProperty("log");
    if (log == null) log = logger;

    try {
      if (scriptText.trim().length() > 0)
        synchronized (this) {
          scriptEngine.setVariable("context", context);
          scriptEngine.setVariable("testRunner", testRunner);
          scriptEngine.setVariable("log", log);

          result.setTimeStamp(System.currentTimeMillis());
          result.startTimer();
          scriptResult = scriptEngine.run();
          result.stopTimer();

          if (scriptResult != null) {
            result.addMessage("Script-result: " + scriptResult.toString());
            // FIXME The property should not me hard coded
            firePropertyValueChanged("result", null, String.valueOf(result));
          }
        }

      // testRunner status may have been changed by script..
      Status testRunnerStatus = testRunner.getStatus();
      if (testRunnerStatus == Status.FAILED) result.setStatus(TestStepStatus.FAILED);
      else if (testRunnerStatus == Status.CANCELED) result.setStatus(TestStepStatus.CANCELED);
      else result.setStatus(TestStepStatus.OK);
    } catch (Throwable e) {
      String errorLineNumber = GroovyUtils.extractErrorLineNumber(e);

      SoapUI.logError(e);
      result.stopTimer();
      result.addMessage(e.toString());
      if (errorLineNumber != null) result.addMessage("error at line: " + errorLineNumber);
      result.setError(e);
      result.setStatus(TestStepStatus.FAILED);
    } finally {
      if (!isForLoadTest())
        setIcon(result.getStatus() == TestStepStatus.FAILED ? failedIcon : okIcon);

      if (scriptEngine != null) scriptEngine.clearVariables();
    }

    return result;
  }
Ejemplo n.º 9
0
  public void run() {
    try {
      for (int i = 0; i < listeners.length; i++) {
        if (!listeners[i].beforeSubmit(this, context)) {
          status = Status.CANCELED;
          SoapUI.log.error("listener cancelled submit..");
          return;
        }
      }

      status = Status.RUNNING;
      Object responseContent = executeAmfCall(getRequest());
      createResponse(responseContent);

      if (status != Status.CANCELED && status != Status.ERROR) {
        status = Status.FINISHED;
      }
    } catch (Exception e) {
      UISupport.showErrorMessage("There's been an error in executing query " + e.toString());
      error = e;
    } finally {

      if (status != Status.CANCELED) {
        for (int i = 0; i < listeners.length; i++) {
          try {
            listeners[i].afterSubmit(this, context);
          } catch (Throwable e) {
            SoapUI.logError(e);
          }
        }
      }
    }
  }
Ejemplo n.º 10
0
    public boolean isAcceptable(Transferable transferable, Point point) {
      int row = getPropertiesTable().rowAtPoint(point);
      if (row >= 0) {
        int column = getPropertiesTable().columnAtPoint(point);
        if (column != 1) {
          return false;
        }

        if (!getPropertiesTable().isCellEditable(row, column)) {
          return false;
        }
      } else if (!(getHolder() instanceof MutableTestPropertyHolder)) {
        return false;
      }

      DataFlavor[] flavors = transferable.getTransferDataFlavors();
      for (int i = 0; i < flavors.length; i++) {
        DataFlavor flavor = flavors[i];
        if (flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) {
          try {
            Object modelItem = transferable.getTransferData(flavor);
            if (modelItem instanceof PropertyModelItem
                && ((PropertyModelItem) modelItem).getProperty().getModelItem()
                    != getHolder().getModelItem()) {
              return PropertyExpansionUtils.canExpandProperty(
                  getHolder().getModelItem(), ((PropertyModelItem) modelItem).getProperty());
            }
          } catch (Exception ex) {
            SoapUI.logError(ex);
          }
        }
      }

      return false;
    }
Ejemplo n.º 11
0
  protected void generate(StringToStringMap values, ToolHost toolHost, WsdlProject project)
      throws Exception {
    String wstoolsDir =
        SoapUI.getSettings().getString(ToolsSettings.JBOSSWS_WSTOOLS_LOCATION, null);
    if (Tools.isEmpty(wstoolsDir)) {
      UISupport.showErrorMessage("wstools directory must be set in global preferences");
      return;
    }

    String wsToolsExtension = UISupport.isWindows() ? ".bat" : ".sh";

    File wstoolsFile = new File(wstoolsDir + File.separatorChar + "wstools" + wsToolsExtension);
    if (!wstoolsFile.exists()) {
      UISupport.showErrorMessage("Could not find wstools script at [" + wstoolsFile + "]");
      return;
    }

    ProcessBuilder builder = new ProcessBuilder();
    ArgumentBuilder args = buildArgs(values, UISupport.isWindows());
    builder.command(args.getArgs());
    builder.directory(new File(wstoolsDir));

    toolHost.run(
        new ToolRunner(builder, new File(values.get(OUTPUT)), values.get(SERVICE_NAME), project));
  }
Ejemplo n.º 12
0
  public XPathReferenceImpl(
      String label, TestProperty property, Object target, String xpathPropertyName) {
    this.label = label;
    this.target = target;
    this.xpathPropertyName = xpathPropertyName;

    ModelItem modelItem = property == null ? null : property.getModelItem();

    if (modelItem instanceof WsdlTestRequestStep) {
      operation = ((WsdlTestRequestStep) modelItem).getTestRequest().getOperation();
      request = property.getName().equalsIgnoreCase("Request");
    } else if (modelItem instanceof WsdlMockResponseTestStep) {
      operation = ((WsdlMockResponseTestStep) modelItem).getOperation();
      request = property.getName().equalsIgnoreCase("Request");
    } else if (modelItem instanceof WsdlMockResponse) {
      operation = ((WsdlMockResponse) modelItem).getMockOperation().getOperation();
      request = property.getName().equalsIgnoreCase("Request");
    } else if (modelItem instanceof WsdlMockOperation) {
      operation = ((WsdlMockOperation) modelItem).getOperation();
      request = property.getName().equalsIgnoreCase("Request");
    }
    try {
      this.xpath = (String) PropertyUtils.getProperty(target, xpathPropertyName);
    } catch (Exception e) {
      SoapUI.logError(e);
    }
  }
Ejemplo n.º 13
0
  protected String getWsdlUrl(StringToStringMap values, T modelItem) {
    String wsdl = values.get(WSDL);
    boolean useCached = values.getBoolean(CACHED_WSDL);

    if (modelItem instanceof AbstractInterface) {
      AbstractInterface<?> iface = (AbstractInterface<?>) modelItem;

      boolean hasDefinition = StringUtils.hasContent(iface.getDefinition());
      if (wsdl == null && !useCached && hasDefinition) {
        return PathUtils.expandPath(iface.getDefinition(), iface);
      }

      if (!hasDefinition || (useCached && iface.getDefinitionContext().isCached())) {
        try {
          File tempFile = File.createTempFile("tempdir", null);
          String path = tempFile.getAbsolutePath();
          tempFile.delete();
          wsdl = iface.getDefinitionContext().export(path);

          // CachedWsdlLoader loader = (CachedWsdlLoader)
          // iface.createWsdlLoader();
          // wsdl = loader.saveDefinition(path);
        } catch (Exception e) {
          SoapUI.logError(e);
        }
      }
    }

    return wsdl;
  }
  public Response execute(SubmitContext submitContext, Request request, long timeStarted)
      throws Exception {
    Session queueSession = null;
    JMSConnectionHolder jmsConnectionHolder = null;
    try {
      init(submitContext, request);
      jmsConnectionHolder =
          new JMSConnectionHolder(jmsEndpoint, hermes, false, clientID, username, password);

      // session
      queueSession = jmsConnectionHolder.getSession();

      // destination
      Queue queue = jmsConnectionHolder.getQueue(jmsConnectionHolder.getJmsEndpoint().getReceive());

      // consumer
      MessageConsumer messageConsumer =
          queueSession.createConsumer(queue, submitContext.expand(messageSelector));

      return makeResponse(submitContext, request, timeStarted, null, messageConsumer);

    } catch (JMSException jmse) {
      return errorResponse(submitContext, request, timeStarted, jmse);
    } catch (Throwable t) {
      SoapUI.logError(t);
    } finally {
      if (jmsConnectionHolder != null) jmsConnectionHolder.closeAll();
      closeSessionAndConnection(
          jmsConnectionHolder != null ? jmsConnectionHolder.getConnection() : null, queueSession);
    }
    return null;
  }
Ejemplo n.º 15
0
  public SoapUIPreferencesAction() {
    super("Preferences");

    putValue(Action.SHORT_DESCRIPTION, "Sets global SoapUI preferences");
    putValue(Action.ACCELERATOR_KEY, UISupport.getKeyStroke("menu alt P"));

    // addPrefs( new HttpPrefs( HTTP_SETTINGS));
    addPrefs(new AnnotatedSettingsPrefs(HttpSettings.class, HTTP_SETTINGS));
    addPrefs(new ProxyPrefs(PROXY_SETTINGS));
    addPrefs(new AnnotatedSettingsPrefs(SSLSettings.class, SSL_SETTINGS));
    addPrefs(new AnnotatedSettingsPrefs(WsdlSettings.class, WSDL_SETTINGS));
    addPrefs(new UIPrefs(UI_SETTINGS));
    addPrefs(new EditorPrefs(EDITOR_SETTINGS));
    addPrefs(new ToolsPrefs(INTEGRATED_TOOLS));
    addPrefs(new AnnotatedSettingsPrefs(WSISettings.class, WS_I_SETTINGS));
    addPrefs(new GlobalPropertiesPrefs());
    addPrefs(new AnnotatedSettingsPrefs(SecuritySettings.class, GLOBAL_SECURITY_SETTINGS));
    addPrefs(new AnnotatedSettingsPrefs(WsaSettings.class, WSA_SETTINGS));
    addPrefs(new AnnotatedSettingsPrefs(WebRecordingSettings.class, WEBRECORDING_SETTINGS));
    addPrefs(new SecurityScansPrefs(GLOBAL_SENSITIVE_INFORMATION_TOKENS));
    addPrefs(new AnnotatedSettingsPrefs(VersionUpdateSettings.class, VERSIONUPDATE_SETTINGS));

    for (PrefsFactory factory : SoapUI.getFactoryRegistry().getFactories(PrefsFactory.class)) {
      addPrefs(factory.createPrefs());
    }

    instance = this;
  }
Ejemplo n.º 16
0
  /**
   * Compress temporary directory and save it on given path.
   *
   * @param exportPath
   * @return
   * @throws IOException
   */
  private boolean packageAll(String exportPath) {
    if (!exportPath.endsWith(".zip")) exportPath = exportPath + ".zip";

    BufferedInputStream origin = null;
    ZipOutputStream out;
    boolean result = true;
    try {
      FileOutputStream dest = new FileOutputStream(exportPath);
      out = new ZipOutputStream(new BufferedOutputStream(dest));
      byte data[] = new byte[BUFFER];
      // get a list of files from current directory

      String files[] = tmpDir.list();

      for (int i = 0; i < files.length; i++) {
        //				System.out.println( "Adding: " + files[i] );
        FileInputStream fi = new FileInputStream(new File(tmpDir, files[i]));
        origin = new BufferedInputStream(fi, BUFFER);
        ZipEntry entry = new ZipEntry(files[i]);
        out.putNextEntry(entry);
        int count;
        while ((count = origin.read(data, 0, BUFFER)) != -1) {
          out.write(data, 0, count);
        }
        origin.close();
      }
      out.close();
    } catch (IOException e) {
      // TODO: handle exception
      result = false;
      SoapUI.logError(e, "Error packaging export");
    }
    return result;
  }
Ejemplo n.º 17
0
  public static List<String> getZipContents(String archive) {
    List<String> contents = new ArrayList<String>();

    try {
      ZipFile zipFile = new ZipFile(archive);
      for (Enumeration<? extends ZipEntry> em1 = zipFile.entries(); em1.hasMoreElements(); ) {
        contents.add(em1.nextElement().toString());
      }
    } catch (ZipException ze) {
      SoapUI.logError(ze);
    } catch (IOException e) {
      SoapUI.logError(e);
    }

    return contents;
  }
Ejemplo n.º 18
0
  @Override
  public int getRowForModelItem(ModelItem modelItem) {
    if (modelItem == null) return -1;

    TreePath treePath = SoapUI.getNavigator().getTreePath(modelItem);
    return getTree().getRowForPath(treePath);
  }
Ejemplo n.º 19
0
    protected void afterRun(RunnerContext context) {
      if (context.getStatus() != RunnerContext.RunnerStatus.FINISHED) return;

      try {
        String wsdlUrl =
            "file:"
                + outDir.getAbsolutePath()
                + File.separatorChar
                + "wsdl"
                + File.separatorChar
                + serviceName
                + ".wsdl";
        Interface[] ifaces = WsdlInterfaceFactory.importWsdl(project, wsdlUrl, true);

        if (ifaces.length > 0) {
          context.log("Added Interface [" + ifaces[0].getName() + "] to project");
          ifaces[0]
              .getSettings()
              .setString(
                  WSToolsRegenerateJava2WsdlAction.class.getName() + "@values",
                  getDialog().getValues().toXml());
          UISupport.select(ifaces[0]);
        }
      } catch (SoapUIException e) {
        SoapUI.logError(e);
      }
    }
Ejemplo n.º 20
0
  public String createXmlRepresentation(TypedContent typedContent) {
    String content = typedContent == null ? null : typedContent.getContentAsString();
    if (!StringUtils.hasContent(content)) {
      return "<xml/>";
    }

    try {
      // XmlObject.Factory.parse( new ByteArrayInputStream(
      // content.getBytes() ) );
      XmlUtils.createXmlObject(new ByteArrayInputStream(content.getBytes()));
      return content;
    } catch (Exception e) {
      // fall through, this wasn't xml
    }

    try {
      Tidy tidy = new Tidy();
      tidy.setXmlOut(true);
      tidy.setShowWarnings(false);
      tidy.setErrout(new PrintWriter(new StringWriter()));
      // tidy.setQuiet(true);
      tidy.setNumEntities(true);
      tidy.setQuoteNbsp(true);
      tidy.setFixUri(false);

      Document document = tidy.parseDOM(new ByteArrayInputStream(content.getBytes()), null);
      StringWriter writer = new StringWriter();
      XmlUtils.serializePretty(document, writer);
      return writer.toString();
    } catch (Throwable e) {
      SoapUI.logError(e);
    }
    return null;
  }
Ejemplo n.º 21
0
  private Object executeAmfCall(AMFRequest amfRequest)
      throws ClientStatusException, ServerStatusException {
    SoapUIAMFConnection amfConnection = null;
    try {
      amfConnection = getConnection(amfRequest);
      addAmfHeaders(amfRequest, amfConnection);
      addHttpHeaders(amfRequest, amfConnection);
      Object result =
          amfConnection.call(context, amfRequest.getAmfCall(), amfRequest.argumentsToArray());

      return result;
    } catch (Exception e) {
      SoapUI.logError(e);
      error = e;
      status = Status.ERROR;
    } finally {
      amfRequest.clearArguments();
      if (context.getModelItem() instanceof AMFRequestTestStep) {
        if (credentials != null && credentials.isLoggedIn()) {
          credentials.logout();
          credentials = null;
        } else {
          amfConnection.close();
        }
      }
    }
    return null;
  }
Ejemplo n.º 22
0
  protected void generate(StringToStringMap values, ToolHost toolHost, Interface modelItem)
      throws Exception {
    String wsimportDir =
        SoapUI.getSettings().getString(ToolsSettings.JBOSSWS_WSTOOLS_LOCATION, null);
    if (Tools.isEmpty(wsimportDir)) {
      UISupport.showErrorMessage(
          "JBossWS wstools/wsconsume directory must be set in global preferences");
      return;
    }

    String wsimportExtension = UISupport.isWindows() ? ".bat" : ".sh";

    File wscompileFile =
        new File(wsimportDir + File.separatorChar + "wsconsume" + wsimportExtension);
    if (!wscompileFile.exists()) {
      UISupport.showErrorMessage("Could not find wsconsume script at [" + wscompileFile + "]");
      return;
    }

    ProcessBuilder builder = new ProcessBuilder();
    ArgumentBuilder args = buildArgs(UISupport.isWindows(), modelItem);
    builder.command(args.getArgs());
    builder.directory(new File(wsimportDir));

    toolHost.run(new ProcessToolRunner(builder, "JBossWS wsconsume", modelItem));
  }
Ejemplo n.º 23
0
  private void copyToRequest(
      SubmitContext context,
      AbstractHttpRequestInterface<?> wsdlRequest,
      EndpointDefaults def,
      String requestUsername,
      String requestPassword,
      String requestDomain,
      String defUsername,
      String defPassword,
      String defDomain,
      com.eviware.soapui.config.CredentialsConfig.AuthType.Enum authType) {
    // only set if not set in request
    String wssType = def.getWssType();

    if (wssType != null) {
      HttpAuthenticationRequestFilter.initRequestCredentials(
          context, null, project.getSettings(), null, null, null);
    } else {
      HttpAuthenticationRequestFilter.initRequestCredentials(
          context, defUsername, project.getSettings(), defPassword, defDomain, authType);
    }

    String wssTimeToLive = def.getWssTimeToLive();
    if (wssTimeToLive == null) {
      wssTimeToLive = "";
    }

    try {
      WssAuthenticationRequestFilter.setWssHeaders(
          context, defUsername, defPassword, wssType, wssTimeToLive);
    } catch (Exception e) {
      SoapUI.logError(e);
    }
  }
Ejemplo n.º 24
0
 public void update() {
   try {
     PropertyUtils.setProperty(target, xpathPropertyName, xpath);
   } catch (Exception e) {
     SoapUI.logError(e);
   }
 }
Ejemplo n.º 25
0
 public Binding getBinding() {
   try {
     return findBinding(getWsdlContext()).binding;
   } catch (Exception e) {
     SoapUI.logError(e);
     return null;
   }
 }
 public void writeTo(OutputStream arg0) throws IOException {
   try {
     arg0.write("\r\n".getBytes());
     ((MimeMultipart) message.getContent()).writeTo(arg0);
   } catch (Exception e) {
     SoapUI.logError(e);
   }
 }
Ejemplo n.º 27
0
  /**
   * Method for processing policy on interface level it should include processing of all types of
   * policies, but for now there's only Addressing policy implemented
   *
   * @param policy
   * @return this interface changed in a proper way indicated by the policy
   */
  public void processPolicy(Policy policy) throws Exception {

    // default is optional
    // String anonymous = AnonymousTypeConfig.OPTIONAL.toString();
    // if (StringUtils.isNullOrEmpty(interfaceAnonymous) || policyFlag)
    // interfaceAnonymous = AnonymousTypeConfig.OPTIONAL.toString() ;
    // if (StringUtils.isNullOrEmpty(interfaceWsaVersion)|| policyFlag)
    // interfaceWsaVersion = WsaVersionTypeConfig.NONE.toString();
    if (!policyFlag) {
      interfaceAnonymous = AnonymousTypeConfig.OPTIONAL.toString();
      interfaceWsaVersion = WsaVersionTypeConfig.NONE.toString();
    }
    policyFlag = true;

    if (policy != null) {
      List<Addressing> addressingList = policy.getAddressingList();
      List<?> usingAddressingList = policy.getUsingAddressingList();
      for (Addressing addressing : addressingList) {
        policyFlag = true;
        String optional = addressing.getOptional().toString();
        if (StringUtils.isNullOrEmpty(optional)
            || optional.equals("false")
            || (optional.equals("true")
                && SoapUI.getSettings().getBoolean(WsaSettings.ENABLE_FOR_OPTIONAL))) {
          interfaceWsaVersion = WsaVersionTypeConfig.X_200508.toString();
        }
        Policy innerPolicy = addressing.getPolicy();
        if (innerPolicy != null) {
          List<AnonymousResponses> anonymousList = innerPolicy.getAnonymousResponsesList();
          List<NonAnonymousResponses> nonAnonymousList = innerPolicy.getNonAnonymousResponsesList();
          if (anonymousList.size() > 0 && nonAnonymousList.size() > 0) {
            throw new Exception(
                "Wrong addressing policy, anonymousResponses and nonAnonymousResponses can not be specified together");
          }
          if (anonymousList.size() > 0) {
            interfaceAnonymous = AnonymousTypeConfig.REQUIRED.toString();
          } else {
            if (nonAnonymousList.size() > 0) {
              interfaceAnonymous = AnonymousTypeConfig.PROHIBITED.toString();
            }
          }
        }
      }
      if (interfaceWsaVersion == WsaVersionTypeConfig.NONE.toString()
          && !usingAddressingList.isEmpty()) {
        /*
         * UsingAddressing can also be specified insde Policy check
         * http://www.w3.org/TR/ws-addr-wsdl/#id2263339
         */
        interfaceWsaVersion = WsaVersionTypeConfig.X_200508.toString();
      }
    }
    setAnonymous(interfaceAnonymous);
    // set wsaVersion to one from policy only if it was null from wsdl binding
    if (getConfig().getWsaVersion().equals(WsaVersionTypeConfig.NONE)) {
      setWsaVersion(interfaceWsaVersion);
    }
  }
Ejemplo n.º 28
0
 protected void createResponse(Object responseContent) {
   try {
     response = new AMFResponse(request, context, responseContent);
     response.setTimestamp(timestamp);
     response.setTimeTaken(System.currentTimeMillis() - timestamp);
   } catch (Exception e) {
     SoapUI.logError(e);
   }
 }
 public MonitorMessageExchangeDataSource(String name, InputStream in, String contentType) {
   try {
     data = Tools.readAll(in, 0).toByteArray();
     this.contentType = contentType;
     this.name = name;
   } catch (Exception e) {
     SoapUI.logError(e);
   }
 }
Ejemplo n.º 30
0
  /** To be overridden.. */
  public void onClose(T modelItem) {
    if (dialog == null) return;

    if (modelItem == null) {
      SoapUI.getSettings().setString(valuesSettingID, dialog.getValues().toXml());
    } else {
      modelItem.getSettings().setString(valuesSettingID, dialog.getValues().toXml());
    }
  }