org.owasp.webscarab.plugin.scripted
Class ScriptedObjectModel

java.lang.Object
  extended by org.owasp.webscarab.plugin.scripted.ScriptedObjectModel

public class ScriptedObjectModel
extends java.lang.Object

Provides a wrapper around the Scripting plugin, so that we do not expose potentially dangerous methods, such as adding listeners, stopping the plugin, etc

Author:
rogan

Constructor Summary
ScriptedObjectModel(Framework framework, Scripted scripted)
          Creates a new instance of ScriptedObjectModel
 
Method Summary
 ConversationID addConversation(Response response)
          adds a conversation to the overall WebScarab framework.
 Response fetchResponse(Request request)
          instructs WebScarab to submit the supplied Request to the appropriate server, and return the corresponding corresponding Response to the caller
 Response getAsyncResponse()
          gets an asynchronous Response that corresponds to a previous Request The actual Request can be obtained using the Response.getRequest() method
 HttpUrl getChildAt(java.lang.String url, int index)
          returns the indicated child of the supplied URL
 int getChildCount(java.lang.String url)
          returns the number of URLs under the supplied URL
 ConversationID getConversationAt(int index)
          returns the identifier of the conversation at the specified index
 int getConversationCount()
          returns the number of conversations for the specified URL.
 java.lang.String getConversationProperty(ConversationID id, java.lang.String property)
           
 java.lang.String getConversationProperty(int id, java.lang.String property)
           
 Request getRequest(ConversationID id)
          returns a copy of the desired Request, or null if the id did not exist
 Request getRequest(int id)
          convenience method, saving the user from doing "new ConversationID(1)" each time returns a copy of the desired Request, or null if the id did not exist
 Response getResponse(ConversationID id)
          returns a copy of the desired Response, or null if the id did not exist
 Response getResponse(int id)
          convenience method, saving the user from doing "new ConversationID(1)" each time returns a copy of the desired Response, or null if the id did not exist
 java.lang.String getUrlProperty(java.lang.String url, java.lang.String property)
           
 boolean hasAsyncCapacity()
          checks whether the Scripted plugin can accept any more Requests for asynchronous fetching
 boolean hasAsyncResponse()
          checks whether the Scripted plugin has a Response ready
 boolean isAsyncBusy()
          checks whether the Scripted plugin is still busy fetching Requests
 void submitAsyncRequest(Request request)
          instructs the Scripted plugin to fetch the supplied Request asynchronously returns immediately without waiting for the Response
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptedObjectModel

public ScriptedObjectModel(Framework framework,
                           Scripted scripted)
Creates a new instance of ScriptedObjectModel

Parameters:
framework - The framework that holds WebScarab together
scripted - the scripting plugin that we interact with
Method Detail

addConversation

public ConversationID addConversation(Response response)
adds a conversation to the overall WebScarab framework. All such conversations will be processed by all of the other plugins, and will be available for later review. The Response includes the corresponding Request as a parameter.

Parameters:
response - the Response to add to the framework
Returns:
the ConversationID allocated to the conversation

getRequest

public Request getRequest(int id)
convenience method, saving the user from doing "new ConversationID(1)" each time returns a copy of the desired Request, or null if the id did not exist

Parameters:
id - the numerical id of the request
Returns:
a copy of the desired Request, or null if it did not exist

getRequest

public Request getRequest(ConversationID id)
returns a copy of the desired Request, or null if the id did not exist

Parameters:
id - the numerical id of the request
Returns:
a copy of the desired Request, or null if it did not exist

getResponse

public Response getResponse(int id)
convenience method, saving the user from doing "new ConversationID(1)" each time returns a copy of the desired Response, or null if the id did not exist

Parameters:
id - the numerical id of the response
Returns:
a copy of the desired Response, or null if it did not exist

getResponse

public Response getResponse(ConversationID id)
returns a copy of the desired Response, or null if the id did not exist

Parameters:
id - the numerical id of the response
Returns:
a copy of the desired Response, or null if it did not exist

getChildCount

public int getChildCount(java.lang.String url)
                  throws java.net.MalformedURLException
returns the number of URLs under the supplied URL

Parameters:
url - the url
Returns:
the number of child URLs
Throws:
java.net.MalformedURLException - if the url is malformed

getChildAt

public HttpUrl getChildAt(java.lang.String url,
                          int index)
                   throws java.net.MalformedURLException
returns the indicated child of the supplied URL

Parameters:
url - the parent url
index - the index of the desired child
Returns:
the url of the indicated child
Throws:
java.net.MalformedURLException - if the url is malformed

getUrlProperty

public java.lang.String getUrlProperty(java.lang.String url,
                                       java.lang.String property)
                                throws java.net.MalformedURLException
Parameters:
url -
property -
Returns:
Throws:
java.net.MalformedURLException

getConversationCount

public int getConversationCount()
returns the number of conversations for the specified URL.

Returns:
the number of conversations
Throws:
java.net.MalformedURLException - if the URL is malformed

getConversationAt

public ConversationID getConversationAt(int index)
returns the identifier of the conversation at the specified index

Parameters:
index -
Returns:
the ConversationID at the requested index

getConversationProperty

public java.lang.String getConversationProperty(int id,
                                                java.lang.String property)
Parameters:
id -
property -
Returns:

getConversationProperty

public java.lang.String getConversationProperty(ConversationID id,
                                                java.lang.String property)
Parameters:
id -
property -
Returns:

fetchResponse

public Response fetchResponse(Request request)
                       throws java.io.IOException
instructs WebScarab to submit the supplied Request to the appropriate server, and return the corresponding corresponding Response to the caller

Parameters:
request - the Request to execute
Returns:
the Response received from the server
Throws:
java.io.IOException - if there is any connectivity problem

hasAsyncCapacity

public boolean hasAsyncCapacity()
checks whether the Scripted plugin can accept any more Requests for asynchronous fetching

Returns:
true if at least one more Request can be submitted

submitAsyncRequest

public void submitAsyncRequest(Request request)
instructs the Scripted plugin to fetch the supplied Request asynchronously returns immediately without waiting for the Response

Parameters:
request - the Request to execute

isAsyncBusy

public boolean isAsyncBusy()
checks whether the Scripted plugin is still busy fetching Requests

Returns:
true if there are still pending Requests, false otherwise

hasAsyncResponse

public boolean hasAsyncResponse()
checks whether the Scripted plugin has a Response ready

Returns:
true if an asynchronous Request has completed, and the Response is ready

getAsyncResponse

public Response getAsyncResponse()
                          throws java.io.IOException
gets an asynchronous Response that corresponds to a previous Request The actual Request can be obtained using the Response.getRequest() method

Returns:
a Response that was fetched
Throws:
java.io.IOException - if there was any problem fetching the Response