org.owasp.webscarab.model
Class FrameworkModel

java.lang.Object
  extended by org.owasp.webscarab.model.FrameworkModel

public class FrameworkModel
extends java.lang.Object

Provides a model of the conversations that have been seen

Author:
rogan

Constructor Summary
FrameworkModel()
          Creates a new ConversationModel
 
Method Summary
 void addConversation(ConversationID id, java.util.Date when, Request request, Response response, java.lang.String origin)
          adds a request and a response to the model, also specifying which plugin caused it.
 boolean addConversationProperty(ConversationID conversation, java.lang.String property, java.lang.String value)
          adds the value to a list of existing values for the specified property and conversation
 void addCookie(Cookie cookie)
          adds a cookie to the model
 void addModelListener(FrameworkListener listener)
          adds a listener to the model
 boolean addUrlProperty(HttpUrl url, java.lang.String property, java.lang.String value)
          adds the value to a list of existing values for the specified property and Url
protected  void fireConversationPropertyChanged(ConversationID id, java.lang.String property)
          notifies listeners that a conversation property changed
protected  void fireCookieAdded(Cookie cookie)
          notifies listeners that a completely new cookie was added
protected  void fireCookieRemoved(Cookie cookie)
          notifies listeners that all values for cookie have been removed.
protected  void fireCookiesChanged()
          notifies listeners that all cookies in the model have changed
protected  void fireUrlPropertyChanged(HttpUrl url, java.lang.String property)
          notifies listeners that an URL property changed
 void flush()
          instructs the SiteModel to flush any unwritten data in the underlying store to disk, prior to exit.
 java.util.Date getConversationDate(ConversationID id)
           
 ConversationModel getConversationModel()
           
 java.lang.String getConversationOrigin(ConversationID id)
           
 java.lang.String[] getConversationProperties(ConversationID conversation, java.lang.String property)
          returns a String array containing the values that has been set for a particular conversation property
 java.lang.String getConversationProperty(ConversationID conversation, java.lang.String property)
          returns a String containing the value that has been identified for a particular conversation property
 java.lang.String getCookieAt(int index)
          returns a key representing the cookie name at the position specified
 Cookie getCookieAt(java.lang.String key, int index)
          returns the actual Cookie corresponding to the key and position specified
 int getCookieCount()
          returns the number of uniquely named cookies that have been added to the model.
 int getCookieCount(java.lang.String key)
          returns the number of unique values that have been observed for the specified cookie
 Cookie[] getCookiesForUrl(HttpUrl url)
          returns an array of cookies that would be applicable to a request sent to the url.
 Cookie getCurrentCookie(java.lang.String key)
           
 int getIndexOfCookie(Cookie cookie)
          returns the position of the cookie in its list.
 int getIndexOfCookie(java.lang.String key, Cookie cookie)
          returns the position of the cookie in its list.
 Request getRequest(ConversationID conversation)
          returns the request corresponding to the conversation ID
 java.lang.String getRequestMethod(ConversationID id)
           
 HttpUrl getRequestUrl(ConversationID conversation)
          returns the url of the conversation in question
 Response getResponse(ConversationID conversation)
          returns the response corresponding to the conversation ID
 java.lang.String getResponseStatus(ConversationID id)
           
 UrlModel getUrlModel()
           
 java.lang.String[] getUrlProperties(HttpUrl url, java.lang.String property)
          returns a String array containing the values that has been set for a particular url property
 java.lang.String getUrlProperty(HttpUrl url, java.lang.String property)
          returns a String containing the value that has been identified for a particular url property
 boolean isModified()
          indicates whether there have been modifications to the site model
 EDU.oswego.cs.dl.util.concurrent.Sync readLock()
           
 void removeCookie(Cookie cookie)
          removes a cookie from the model
 void removeModelListener(FrameworkListener listener)
          removes a listener from the model
 ConversationID reserveConversationID()
          reserve a conversation ID for later use.
 void setConversationProperty(ConversationID conversation, java.lang.String property, java.lang.String value)
          sets the specified property of the conversation
 void setSession(java.lang.String type, java.lang.Object store, java.lang.String session)
           
 void setUrlProperty(HttpUrl url, java.lang.String property, java.lang.String value)
          sets the specified property of the url
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FrameworkModel

public FrameworkModel()
Creates a new ConversationModel

Method Detail

setSession

public void setSession(java.lang.String type,
                       java.lang.Object store,
                       java.lang.String session)
                throws StoreException
Throws:
StoreException

readLock

public EDU.oswego.cs.dl.util.concurrent.Sync readLock()

getUrlModel

public UrlModel getUrlModel()

getConversationModel

public ConversationModel getConversationModel()

flush

public void flush()
           throws StoreException
instructs the SiteModel to flush any unwritten data in the underlying store to disk, prior to exit.

Throws:
StoreException - if there is any problem writing to the store

isModified

public boolean isModified()
indicates whether there have been modifications to the site model

Returns:
true if the model has been modified since it was last flushed, false otherwise

reserveConversationID

public ConversationID reserveConversationID()
reserve a conversation ID for later use. This is mostly used by the Proxy plugin to allow it to add conversations in the order that they are seen, not in the order that they are completed.

Returns:
a new ConversationID

addConversation

public void addConversation(ConversationID id,
                            java.util.Date when,
                            Request request,
                            Response response,
                            java.lang.String origin)
adds a request and a response to the model, also specifying which plugin caused it.

Parameters:
id - the previously reserved ConversationID that identifies this conversation
request - the request
response - the response from the server
origin - the plugin that created this conversation

getConversationOrigin

public java.lang.String getConversationOrigin(ConversationID id)

getConversationDate

public java.util.Date getConversationDate(ConversationID id)

getRequestUrl

public HttpUrl getRequestUrl(ConversationID conversation)
returns the url of the conversation in question

Parameters:
conversation - the conversation
Returns:
the url

setConversationProperty

public void setConversationProperty(ConversationID conversation,
                                    java.lang.String property,
                                    java.lang.String value)
sets the specified property of the conversation

Parameters:
conversation - the conversation ID
property - the name of the property to change
value - the value to use

addConversationProperty

public boolean addConversationProperty(ConversationID conversation,
                                       java.lang.String property,
                                       java.lang.String value)
adds the value to a list of existing values for the specified property and conversation

Parameters:
conversation - the conversation
property - the name of the property
value - the value to add

getConversationProperty

public java.lang.String getConversationProperty(ConversationID conversation,
                                                java.lang.String property)
returns a String containing the value that has been identified for a particular conversation property

Parameters:
conversation - the conversation id
property - the name of the property
Returns:
the property value, or null if none has been set

getRequestMethod

public java.lang.String getRequestMethod(ConversationID id)

getResponseStatus

public java.lang.String getResponseStatus(ConversationID id)

getConversationProperties

public java.lang.String[] getConversationProperties(ConversationID conversation,
                                                    java.lang.String property)
returns a String array containing the values that has been set for a particular conversation property

Parameters:
conversation - the conversation id
property - the name of the property
Returns:
an array of strings representing the property values, possibly zero length

setUrlProperty

public void setUrlProperty(HttpUrl url,
                           java.lang.String property,
                           java.lang.String value)
sets the specified property of the url

Parameters:
url - the url
property - the name of the property to change
value - the value to use

addUrlProperty

public boolean addUrlProperty(HttpUrl url,
                              java.lang.String property,
                              java.lang.String value)
adds the value to a list of existing values for the specified property and Url

Parameters:
url - the url
property - the name of the property
value - the value to add

getUrlProperties

public java.lang.String[] getUrlProperties(HttpUrl url,
                                           java.lang.String property)
returns a String array containing the values that has been set for a particular url property

Parameters:
url - the url
property - the name of the property
Returns:
an array of strings representing the property values, possibly zero length

getUrlProperty

public java.lang.String getUrlProperty(HttpUrl url,
                                       java.lang.String property)
returns a String containing the value that has been identified for a particular url property

Parameters:
url - the url
property - the name of the property
Returns:
the property value, or null if none has been set

getRequest

public Request getRequest(ConversationID conversation)
returns the request corresponding to the conversation ID

Parameters:
conversation - the conversation ID
Returns:
the request

getResponse

public Response getResponse(ConversationID conversation)
returns the response corresponding to the conversation ID

Parameters:
conversation - the conversation ID
Returns:
the response

addModelListener

public void addModelListener(FrameworkListener listener)
adds a listener to the model

Parameters:
listener - the listener to add

removeModelListener

public void removeModelListener(FrameworkListener listener)
removes a listener from the model

Parameters:
listener - the listener to remove

getCookieCount

public int getCookieCount()
returns the number of uniquely named cookies that have been added to the model. This does not consider changes in value of cookies.

Returns:
the number of cookies

getCookieCount

public int getCookieCount(java.lang.String key)
returns the number of unique values that have been observed for the specified cookie

Parameters:
key - a key identifying the cookie
Returns:
the number of values in the model

getCookieAt

public java.lang.String getCookieAt(int index)
returns a key representing the cookie name at the position specified

Parameters:
index - which cookie in the list
Returns:
a key which can be used to get values for this cookie

getCookieAt

public Cookie getCookieAt(java.lang.String key,
                          int index)
returns the actual Cookie corresponding to the key and position specified

Parameters:
key - the cookie identifier
index - the position in the list
Returns:
the cookie

getIndexOfCookie

public int getIndexOfCookie(Cookie cookie)
returns the position of the cookie in its list. (The key is extracted from the cookie itself)

Parameters:
cookie - the cookie
Returns:
the position in the list

getIndexOfCookie

public int getIndexOfCookie(java.lang.String key,
                            Cookie cookie)
returns the position of the cookie in its list. (The key is extracted from the cookie itself)

Parameters:
cookie - the cookie
Returns:
the position in the list

getCurrentCookie

public Cookie getCurrentCookie(java.lang.String key)

addCookie

public void addCookie(Cookie cookie)
adds a cookie to the model

Parameters:
cookie - the cookie to add

removeCookie

public void removeCookie(Cookie cookie)
removes a cookie from the model

Parameters:
cookie - the cookie to remove

getCookiesForUrl

public Cookie[] getCookiesForUrl(HttpUrl url)
returns an array of cookies that would be applicable to a request sent to the url.

Parameters:
url - the url
Returns:
an array of cookies, or a zero length array if there are none applicable.

fireCookieAdded

protected void fireCookieAdded(Cookie cookie)
notifies listeners that a completely new cookie was added

Parameters:
cookie - the cookie

fireCookieRemoved

protected void fireCookieRemoved(Cookie cookie)
notifies listeners that all values for cookie have been removed.

Parameters:
cookie - the last cookie that was removed

fireCookiesChanged

protected void fireCookiesChanged()
notifies listeners that all cookies in the model have changed


fireConversationPropertyChanged

protected void fireConversationPropertyChanged(ConversationID id,
                                               java.lang.String property)
notifies listeners that a conversation property changed

Parameters:
cookie - the cookie

fireUrlPropertyChanged

protected void fireUrlPropertyChanged(HttpUrl url,
                                      java.lang.String property)
notifies listeners that an URL property changed

Parameters:
cookie - the cookie