public class SecureLinkTool extends LinkTool
It has the same interface as StrutsLinkTool and can function as a substitute if Struts 1.x and SSL Ext are installed.
Usage:
Template example: <!-- Use just like a regular StrutsLinkTool --> $link.action.nameOfAction $link.action.nameOfForward If the action or forward is marked as secure, or not, in your struts-config then the link will be rendered with https or http accordingly. Toolbox configuration: <tool> <key>link</key> <scope>request</scope> <class>org.apache.velocity.tools.struts.SecureLinkTool</class> </tool>
LinkTool.QueryPair| Modifier and Type | Field and Description |
|---|---|
private static java.lang.String |
HTTP |
private static java.lang.String |
HTTPS |
private static java.lang.String |
STD_HTTP_PORT |
private static java.lang.String |
STD_HTTPS_PORT |
application, AUTO_IGNORE_PARAMETERS_KEY, HTML_QUERY_DELIMITER, LOG, request, response, SELF_ABSOLUTE_KEY, SELF_INCLUDE_PARAMETERS_KEY, XHTML_QUERY_DELIMITER| Constructor and Description |
|---|
SecureLinkTool() |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
computeURL(javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext app,
java.lang.String link)
Compute a hyperlink URL based on the specified action link.
|
private static org.apache.struts.config.SecureActionConfig |
getActionConfig(javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext app,
java.lang.String linkString)
Finds the configuration definition for the specified action link
|
SecureLinkTool |
setAction(java.lang.String action)
Returns a copy of the link with the given action name
converted into a server-relative URI reference.
|
SecureLinkTool |
setForward(java.lang.String forward)
Returns a copy of the link with the given global forward name
converted into a server-relative URI reference.
|
private static java.lang.StringBuffer |
startNewUrlString(javax.servlet.http.HttpServletRequest request,
java.lang.String desiredScheme,
java.lang.String desiredPort)
Builds the protocol, server name, and port portion of the new URL
|
java.lang.String |
toEncoded(java.lang.String url,
java.lang.String sessionId)
Return the specified URL with the specified session identifier
suitably encoded.
|
absolute, addAllParameters, addIgnore, addQueryData, addQueryData, anchor, configure, copyWith, copyWith, copyWith, copyWithAnchor, copyWithIgnore, duplicate, encodeURL, getAnchor, getBaseRef, getContextPath, getContextURL, getParams, getQueryData, getRequestPath, getSelf, getUri, getURI, init, param, params, relative, setAbsolute, setAnchor, setAutoIgnoreParameters, setRelative, setSelfAbsolute, setSelfIncludeParameters, setURI, setXhtml, toString, uriprivate static final java.lang.String HTTP
private static final java.lang.String HTTPS
private static final java.lang.String STD_HTTP_PORT
private static final java.lang.String STD_HTTPS_PORT
public SecureLinkTool setAction(java.lang.String action)
Returns a copy of the link with the given action name converted into a server-relative URI reference. This method does not check if the specified action really is defined. This method will overwrite any previous URI reference settings but will copy the query string.
action - an action path as defined in struts-config.xmlpublic SecureLinkTool setForward(java.lang.String forward)
Returns a copy of the link with the given global forward name
converted into a server-relative URI reference. If the parameter
does not map to an existing global forward name, null
is returned. This method will overwrite any previous URI reference
settings but will copy the query string.
forward - a global forward name as defined in struts-config.xmlpublic java.lang.String computeURL(javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext app,
java.lang.String link)
response.encodeURL() for adding a session identifier.request - the current request.app - the current ServletContext.link - the action that is to be converted to a hyperlink URLprivate static org.apache.struts.config.SecureActionConfig getActionConfig(javax.servlet.http.HttpServletRequest request,
javax.servlet.ServletContext app,
java.lang.String linkString)
request - the current request.app - the current ServletContext.linkString - The action we are searching for, specified as a
link. (i.e. may include "..")private static java.lang.StringBuffer startNewUrlString(javax.servlet.http.HttpServletRequest request,
java.lang.String desiredScheme,
java.lang.String desiredPort)
request - The current requestdesiredScheme - The scheme (http or https) to be used in the new URLdesiredPort - The port number to be used in th enew URLpublic java.lang.String toEncoded(java.lang.String url,
java.lang.String sessionId)
url - URL to be encoded with the session idsessionId - Session id to be included in the encoded URLCopyright (c) 2003-2007 Apache Software Foundation