Package org.owasp.webscarab.model

Examples of org.owasp.webscarab.model.Response


            ConversationModel cmodel = _frameworkModel.getConversationModel();
            int count = cmodel.getConversationCount();
            for (int i=0; i<count; i++) {
                id = cmodel.getConversationAt(i);
                Request request = cmodel.getRequest(id);
                Response response = cmodel.getResponse(id);
                String origin = cmodel.getConversationOrigin(id);
                boolean matches = matches(id, request, response, origin, expr);
                _model.setSearchMatch(id, description, matches);
            }
        } catch (Exception e) {
View Full Code Here


        ConversationModel conversationModel = this.model.getConversationModel();
        HttpUrl samlHttpUrl = conversationModel.getRequestUrl(samlId);
        int samlConversationIndex = conversationModel.getIndexOfConversation(samlId);
        for (int conversationIndex = samlConversationIndex - 1; conversationIndex >= 0; conversationIndex--) {
            ConversationID id = conversationModel.getConversationAt(conversationIndex);
            Response response = conversationModel.getResponse(id);
            HttpUrl httpUrl = conversationModel.getRequestUrl(id);
            Object parsedContent = Parser.parse(httpUrl, response);
            if (null == parsedContent) {
                continue;
            }
View Full Code Here

        return null;
    }

    public byte[] getResponseContent(ConversationID id) {
        ConversationModel conversationModel = this.model.getConversationModel();
        Response response = conversationModel.getResponse(id);
        byte[] content = response.getContent();
        return content;
    }
View Full Code Here

    public Response fetchResponse(Request request) throws IOException {
        /*
         * We want a very fast fall-through in case nothing needs to be done.
         */
        if (false == this.samlProxyConfig.doSomething()) {
            Response response = this.in.fetchResponse(request);
            return response;
        }

        changeSamlResponse(request);

        String samlProxyHeader = "";
        if (this.samlProxyConfig.doReplay()) {
            samlProxyHeader += "replayed;";
        }
       
        if (this.samlProxyConfig.doInjectAttribute()) {
            samlProxyHeader += "injected attribute;";
        }
        if (this.samlProxyConfig.doInjectSubject()) {
            samlProxyHeader += "injected subject;";
        }
        if (this.samlProxyConfig.doInjectPublicDoctype()) {
            samlProxyHeader += "injected public doctype;";
        }
        if (this.samlProxyConfig.doInjectRelayState()) {
            samlProxyHeader += "injected relay state;";
        }
       
        if (this.samlProxyConfig.doSignSamlMessage()) {
            samlProxyHeader += "sign;";
        } else if (this.samlProxyConfig.doRemoveSignature()) {
            samlProxyHeader += "removed signature;";
        } else {
            if (this.samlProxyConfig.doCorruptSignature()) {
                samlProxyHeader += "corrupted signature;";
            }
            if (this.samlProxyConfig.doInjectRemoteReference()) {
                samlProxyHeader += "injected remote reference;";
            }
        }

        if (samlProxyHeader.length() > 0) {
            request.addHeader("X-SAMLProxy", samlProxyHeader);
        }

        Response response = this.in.fetchResponse(request);
        return response;
    }
View Full Code Here

     * returns a copy of the desired Response, or null if the id did not exist
     * @param id the numerical id of the response
     * @return a copy of the desired Response, or null if it did not exist
     */   
    public Response getResponse(ConversationID id) {
        Response response = _model.getResponse(id);
        if (response == null) return response;
        return new Response(response);
    }
View Full Code Here

        // pass the request for possible modification or analysis
        connection.setRequest(request);
        connection.setResponse(null);
        _proxy.interceptRequest(connection);
        request = connection.getRequest();
        Response response = connection.getResponse();

        if (request == null)
          throw new IOException("Request was cancelled");
        if (response != null) {
          _proxy.failedResponse(id, "Response provided by script");
          _proxy = null;
        } else {

          // pass the request through the plugins, and return the
          // response
          try {
            response = hc.fetchResponse(request);
            if (response.getRequest() != null)
              request = response.getRequest();
          } catch (IOException ioe) {
            _logger
                .severe("IOException retrieving the response for "
                    + request.getURL() + " : " + ioe);
            ioe.printStackTrace();
            response = errorResponse(request, ioe);
            // prevent the conversation from being
            // submitted/recorded
            _proxy.failedResponse(id, ioe.toString());
            _proxy = null;
          }
          if (response == null) {
            _logger.severe("Got a null response from the fetcher");
            _proxy.failedResponse(id, "Null response");
            return;
          }
        }

        if (_proxy != null) {
          // pass the response for analysis or modification by the
          // scripts
          connection.setResponse(response);
          _proxy.interceptResponse(connection);
          response = connection.getResponse();
        }

        if (response == null)
          throw new IOException("Response was cancelled");

        try {
          if (_clientOut != null) {
            _logger.fine("Writing the response to the browser");
            response.write(_clientOut);
            _logger
                .fine("Finished writing the response to the browser");
          }
        } catch (IOException ioe) {
          _logger
              .severe("Error writing back to the browser : "
                  + ioe);
        } finally {
          response.flushContentStream(); // this simply flushes the
                          // content from the server
        }
        // this should not happen, but might if a proxy plugin is
        // careless
        if (response.getRequest() == null) {
          _logger.warning("Response had no associated request!");
          response.setRequest(request);
        }
        if (_proxy != null && !request.getMethod().equals("CONNECT")) {
          _proxy.gotResponse(id, response);
        }

        keepAlive = response.getHeader("Connection");
        version = response.getVersion();

        request = null;

        _logger.fine("Version: " + version + " Connection: "
            + connection);
View Full Code Here

      throw e;
    }
  }

  private Response errorResponse(Request request, Exception e) {
    Response response = new Response();
    response.setRequest(request);
    response.setVersion("HTTP/1.0");
    response.setStatus("500");
    response.setMessage("WebScarab error");
    response.setHeader("Content-Type", "text/html");
    response.setHeader("Connection", "Close");
    String template = "<HTML><HEAD><TITLE>WebScarab Error</TITLE></HEAD>";
    template = template
        + "<BODY>WebScarab encountered an error trying to retrieve <P><pre>"
        + HtmlEncoder.encode(request.toString()) + "</pre><P>";
    template = template + "The error was : <P><pre>"
        + HtmlEncoder.encode(e.getLocalizedMessage()) + "\n";
    StackTraceElement[] trace = e.getStackTrace();
    if (trace != null) {
      for (int i = 0; i < trace.length; i++) {
        template = template + "\tat " + trace[i].getClassName() + "."
            + trace[i].getMethodName() + "(";
        if (trace[i].getLineNumber() == -2) {
          template = template + "Native Method";
        } else if (trace[i].getLineNumber() == -1) {
          template = template + "Unknown Source";
        } else {
          template = template + trace[i].getFileName() + ":"
              + trace[i].getLineNumber();
        }
        template = template + ")\n";
      }
    }
    template = template + "</pre><P></HTML>";
    response.setContent(template.getBytes());
    return response;
  }
View Full Code Here

                request.write(_out);
            }
            _out.flush();
            _logger.finest("Request : \n" + request.toString());

            _response = new Response();
            _response.setRequest(request);

            // test for spurious 100 header from IIS 4 and 5.
            // See http://mail.python.org/pipermail/python-list/2000-December/023204.html
            _logger.fine("Reading the response");
View Full Code Here

                        _out.write(("Proxy-Authorization: " + authHeader + "\r\n").getBytes());
                    }
                    _out.write("\r\n".getBytes());
                    _out.flush();
                    _logger.fine("Sent CONNECT, reading Proxy response");
                    Response response = new Response();
                    response.read(_in);
                    _logger.fine("Got proxy response " + response.getStatusLine());
                    status = response.getStatus();
                    if (status.equals("407")) {
                        response.flushContentStream();
                        oldAuthHeader = authHeader;
                        String[] challenges = response.getHeaders("Proxy-Authenticate");
                        if (_proxyAuthCreds == null && _authenticator != null)
                            _proxyAuthCreds = _authenticator.getProxyCredentials(_httpsProxy, challenges);
                        if (_proxyAuthCreds == null) {
                            _response = response;
                            return;
View Full Code Here

                _response = (Response) _messagePanel.getMessage();
                _modified = true;
                invalidatePanels();
            }
            if (_response == null) {
                _response = new Response();
            }
            // if _modified
            _response.setStatus(statusTextField.getText());
            _response.setMessage(messageTextField.getText());
            _response.setVersion(versionTextField.getText());
        } else if (displayTabbedPane.getTitleAt(panel).equals("Raw")) { // raw text
            if (_textPanel.isModified()) {
                try {
                    Response r = new Response();
                    r.parse(new String(_textPanel.getBytes()));
                    _response = r;
                } catch (Exception e) {
                    System.err.println("Error parsing the rawTextArea, abandoning changes : " + e);
                }
                _modified = true;
View Full Code Here

TOP

Related Classes of org.owasp.webscarab.model.Response

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.