public class Session extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Session.OnContextsChangedListener
Listener notified whenever the registered list of contexts changes.
|
Modifier | Constructor and Description |
---|---|
protected |
Session(Model model)
Constructor for the current session.
|
Modifier and Type | Method and Description |
---|---|
void |
addContext(Context c)
Adds the given context.
|
void |
addExcludeFromProxyRegex(String ignoredRegex) |
void |
addExcludeFromScanRegexs(String ignoredRegex) |
void |
addExcludeFromSpiderRegex(String ignoredRegex)
Adds the given regular expression to the list of regular expressions used to exclude URLs
from the spiders (e.g.
|
void |
addGlobalExcludeURLRegexs(String regex)
Deprecated.
(2.6.0) No longer works, modification of global exclude URLs should not be done
through the session.
|
void |
addOnContextsChangedListener(Session.OnContextsChangedListener l) |
void |
clearContextData(int contextId) |
void |
clearContextDataForType(int contextId,
int type) |
protected void |
close() |
void |
deleteContext(Context c) |
protected void |
discard() |
void |
exportContext(Context c,
File file)
Export the specified context to a file
|
void |
exportContext(int contextIndex,
File file)
Export the specified context to a file
|
void |
forceGlobalExcludeURLRefresh()
Resets the global exclude URLs of the Local Proxy.
|
Context |
getContext(int index) |
Context |
getContext(String name) |
List<String> |
getContextDataStrings(int contextId,
int type) |
List<Context> |
getContexts() |
List<Context> |
getContextsForNode(SiteNode sn) |
List<Context> |
getContextsForUrl(String url) |
List<String> |
getExcludeFromProxyRegexs() |
List<String> |
getExcludeFromScanRegexs() |
List<String> |
getExcludeFromSpiderRegexs()
Gets the regular expressions used to exclude URLs from the spiders (e.g.
|
String |
getFileName() |
ParameterParser |
getFormParamParser(String url)
Returns the form parameter parser associated with the first context found that includes the
URL, or the default parser if it is not in a context
|
Map<String,String> |
getFormParams(org.apache.commons.httpclient.URI uri,
String formData)
Returns the FORM parameters for the given URL based on the parser associated with the first
context found that includes the URL, or the default parser if it is not in a context
|
List<String> |
getGlobalExcludeURLRegexs()
Gets the global exclude URLs.
|
Context |
getNewContext(String name)
Gets a newly created context with the given name.
|
List<SiteNode> |
getNodesInContextFromSiteTree(Context context)
Gets the nodes from the site tree which are "In Scope" in a given context.
|
List<SiteNode> |
getNodesInScopeFromSiteTree()
Gets the nodes from the site tree which are "In Scope".
|
List<NameValuePair> |
getParameters(HttpMessage msg,
HtmlParameter.Type type)
Gets the parameters of the given
type from the given message . |
Map<String,String> |
getParams(HttpMessage msg,
HtmlParameter.Type type)
Returns the specified parameters for the given message based on the parser associated with
the first context found that includes the URL for the message, or the default parser if it is
not in a context
|
String |
getSessionDesc() |
String |
getSessionFolder() |
long |
getSessionId() |
String |
getSessionName() |
List<String> |
getSessionUrls(int type) |
SiteMap |
getSiteTree() |
List<SiteNode> |
getTopNodesInScopeFromSiteTree()
Gets the top nodes from the site tree which contain nodes that are "In Scope".
|
List<String> |
getTreePath(HttpMessage msg) |
List<String> |
getTreePath(org.apache.commons.httpclient.URI uri) |
ParameterParser |
getUrlParamParser(String url)
Returns the url parameter parser associated with the first context found that includes the
URL, or the default parser if it is not in a context
|
Map<String,String> |
getUrlParams(org.apache.commons.httpclient.URI uri)
Returns the URL parameters for the given URL based on the parser associated with the first
context found that includes the URL, or the default parser if it is not in a context
|
Context |
importContext(File file)
Imports a context from the specified (XML) file.
|
protected boolean |
isExcludedFromScope(SiteNode sn) |
protected boolean |
isIncludedInScope(SiteNode sn) |
boolean |
isInScope(HistoryReference href) |
boolean |
isInScope(SiteNode sn) |
boolean |
isInScope(String url) |
boolean |
isNewState()
Tells whether this session is in a new state or not.
|
protected void |
open(File file,
SessionListener callback) |
protected void |
open(String fileName) |
protected void |
open(String sessionFile,
SessionListener callback) |
protected void |
persistProperties()
Persists the properties (e.g.
|
void |
removeOnContextsChangedListener(Session.OnContextsChangedListener l) |
protected void |
save(String fileName)
Synchronous call to save a session.
|
protected void |
save(String fileName,
SessionListener callback)
Asynchronous call to save a session.
|
void |
saveAllContexts() |
void |
saveContext(Context c) |
void |
setContextData(int contextId,
int type,
List<String> dataList) |
void |
setContextData(int contextId,
int type,
String data) |
void |
setExcludeFromProxyRegexs(List<String> ignoredRegexs) |
void |
setExcludeFromScanRegexs(List<String> ignoredRegexs) |
void |
setExcludeFromSpiderRegexs(List<String> ignoredRegexs)
Sets the given regular expressions as the list of regular expressions used to exclude URLs
from the spiders (e.g.
|
void |
setGlobalExcludeURLRegexs(List<String> ignoredRegexs)
Deprecated.
(2.6.0) No longer works, when needed, the global exclude URLs are obtained from
the options.
|
void |
setSessionDesc(String sessionDesc) |
void |
setSessionId(long sessionId) |
void |
setSessionName(String name) |
void |
setSessionUrl(int type,
String url) |
void |
setSessionUrls(int type,
List<String> urls) |
protected void |
snapshot(String fileName)
Synchronous call to snapshot a session.
|
protected void |
snapshot(String fileName,
SessionListener callback)
Asynchronous call to snapshot a session.
|
protected Session(Model model)
model
- protected void discard()
protected void close()
public String getSessionDesc()
public long getSessionId()
public String getSessionName()
public SiteMap getSiteTree()
public boolean isNewState()
true
if this session is in a new state, false
otherwise.protected void open(File file, SessionListener callback)
protected void open(String sessionFile, SessionListener callback)
protected void open(String fileName) throws DatabaseException, IOException, Exception
DatabaseException
IOException
Exception
protected void save(String fileName, SessionListener callback)
fileName
- callback
- protected void save(String fileName) throws Exception
fileName
- Exception
protected void persistProperties() throws Exception
Should be called only by "core" classes.
Exception
- if an error occurred while persisting the properties.setSessionName(String)
,
setSessionDesc(String)
protected void snapshot(String fileName, SessionListener callback)
fileName
- callback
- protected void snapshot(String fileName) throws Exception
fileName
- Exception
public void setSessionDesc(String sessionDesc)
sessionDesc
- The sessionDesc to set.public void setSessionId(long sessionId)
sessionId
- The sessionId to set.public void setSessionName(String name)
name
- The name to set.public String getFileName()
public String getSessionFolder()
protected boolean isIncludedInScope(SiteNode sn)
protected boolean isExcludedFromScope(SiteNode sn)
public boolean isInScope(HistoryReference href)
public boolean isInScope(SiteNode sn)
public boolean isInScope(String url)
public List<SiteNode> getNodesInScopeFromSiteTree()
public List<SiteNode> getTopNodesInScopeFromSiteTree()
public List<SiteNode> getNodesInContextFromSiteTree(Context context)
context
- the contextpublic void setExcludeFromProxyRegexs(List<String> ignoredRegexs) throws DatabaseException
DatabaseException
public void addExcludeFromProxyRegex(String ignoredRegex) throws DatabaseException
DatabaseException
public void addExcludeFromScanRegexs(String ignoredRegex) throws DatabaseException
DatabaseException
public void setExcludeFromScanRegexs(List<String> ignoredRegexs) throws DatabaseException
DatabaseException
public List<String> getExcludeFromSpiderRegexs()
List
containing the regular expressions, never null
.public void addExcludeFromSpiderRegex(String ignoredRegex) throws DatabaseException
ignoredRegex
- the regular expression to be addedIllegalArgumentException
- if the regular expression is not valid.DatabaseException
- if an error occurred while persisting the list.public void setExcludeFromSpiderRegexs(List<String> ignoredRegexs) throws DatabaseException
ignoredRegexs
- the regular expressions to be setIllegalArgumentException
- if any of the regular expressions is not valid.DatabaseException
- if an error occurred while persisting the list.public void forceGlobalExcludeURLRefresh()
This should be considered an internal method, to be called only by core code.
public List<String> getGlobalExcludeURLRegexs()
Note: This method is only provided as a convenience, the global exclude URLs are not saved in the session.
List
containing the URLs that should be excluded globally.@Deprecated public void addGlobalExcludeURLRegexs(String regex)
Note: The changes are lost after changing the session.
regex
- the regular expression to add.@Deprecated public void setGlobalExcludeURLRegexs(List<String> ignoredRegexs)
Note: The changes are lost after changing the session.
ignoredRegexs
- the global exclude URLspublic void setSessionUrls(int type, List<String> urls) throws DatabaseException
DatabaseException
public void setSessionUrl(int type, String url) throws DatabaseException
DatabaseException
public List<String> getSessionUrls(int type) throws DatabaseException
DatabaseException
public List<String> getContextDataStrings(int contextId, int type) throws DatabaseException
DatabaseException
public void setContextData(int contextId, int type, String data) throws DatabaseException
DatabaseException
public void setContextData(int contextId, int type, List<String> dataList) throws DatabaseException
DatabaseException
public void clearContextDataForType(int contextId, int type) throws DatabaseException
DatabaseException
public void clearContextData(int contextId) throws DatabaseException
DatabaseException
public void saveContext(Context c)
public void saveAllContexts()
public Context getNewContext(String name)
The context is automatically added to the session.
name
- the name of the contextContext
.IllegalContextNameException
- (since 2.6.0) if the given name is null
or empty
or if a context with the given name already exists.public void addContext(Context c)
c
- the context to be addedIllegalArgumentException
- (since 2.6.0) if the given context is null
.IllegalContextNameException
- (since 2.6.0) if context's name is null
or empty
or if a context with the same name already exists.public void deleteContext(Context c)
public Context getContext(int index)
public void exportContext(int contextIndex, File file) throws org.apache.commons.configuration.ConfigurationException
contextIndex
- file
- org.apache.commons.configuration.ConfigurationException
public void exportContext(Context c, File file) throws org.apache.commons.configuration.ConfigurationException
c
- file
- org.apache.commons.configuration.ConfigurationException
public Context importContext(File file) throws org.apache.commons.configuration.ConfigurationException, ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException
file
- the (XML) file that contains the context dataContext
, already added to the session.org.apache.commons.configuration.ConfigurationException
ClassNotFoundException
InstantiationException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
NoSuchMethodException
SecurityException
IllegalContextNameException
- (since 2.6.0) if context's name is not provided or it's
empty or if a context with the same name already exists.public ParameterParser getUrlParamParser(String url)
url
- public ParameterParser getFormParamParser(String url)
url
- public Map<String,String> getParams(HttpMessage msg, HtmlParameter.Type type)
msg
- type
- public List<NameValuePair> getParameters(HttpMessage msg, HtmlParameter.Type type)
type
from the given message
.
Parameters' names and values are in decoded form.
msg
- the message whose parameters will be extracted fromtype
- the type of parameters to extractList
containing the parametersIllegalArgumentException
- if any of the parameters is null
or if the given
type
is not url
or
form
.StandardParameterParser.getParameters(HttpMessage,
org.parosproxy.paros.network.HtmlParameter.Type)
public Map<String,String> getUrlParams(org.apache.commons.httpclient.URI uri) throws org.apache.commons.httpclient.URIException
uri
- org.apache.commons.httpclient.URIException
public Map<String,String> getFormParams(org.apache.commons.httpclient.URI uri, String formData) throws org.apache.commons.httpclient.URIException
uri
- formData
- org.apache.commons.httpclient.URIException
public List<String> getTreePath(org.apache.commons.httpclient.URI uri) throws org.apache.commons.httpclient.URIException
org.apache.commons.httpclient.URIException
public List<String> getTreePath(HttpMessage msg) throws org.apache.commons.httpclient.URIException
org.apache.commons.httpclient.URIException
public void addOnContextsChangedListener(Session.OnContextsChangedListener l)
public void removeOnContextsChangedListener(Session.OnContextsChangedListener l)