public class WebPageHandler extends HtmlResourceHandler
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
authorizationToken
Authorization token
|
private BootstrapConfig |
config
Configuration.
|
private java.lang.String |
cookieToken
Cookie token
|
private static java.util.logging.Logger |
LOG
Logger.
|
Constructor and Description |
---|
WebPageHandler(BootstrapConfig config,
java.lang.String root,
java.lang.String skel)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
private boolean |
checkCookies(javax.servlet.http.HttpServletRequest request)
Check cookies list for a cookie that match the expected value.
|
private boolean |
checkQueryParam(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Check authorization token PARAM_TOKEN.
|
void |
handle(java.lang.String target,
org.eclipse.jetty.server.Request base,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Return the main page for AJAX clients.
|
protected java.lang.String |
handleReplacements(org.eclipse.jetty.server.Request base,
java.lang.String text)
Process the given string and make any replacements of parameter
values as needed.
|
java.lang.String |
htmlColor(java.lang.String color)
Convert to HTML color format.
|
private boolean |
isAuthorized(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Check authorization.
|
void |
setAuthorizationToken(java.lang.String token)
Set authorization token.
|
destroy, doStart, doStop, dumpThis, getServer, setServer
addBean, addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
private static final java.util.logging.Logger LOG
private BootstrapConfig config
private java.lang.String cookieToken
private java.lang.String authorizationToken
public WebPageHandler(BootstrapConfig config, java.lang.String root, java.lang.String skel)
config
- Configuration parameters.root
- Prefix for all URLs relating to this page.skel
- Fully qualified resource name of the HTML file which should be used.public void handle(java.lang.String target, org.eclipse.jetty.server.Request base, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException
handle
in interface org.eclipse.jetty.server.Handler
handle
in class HtmlResourceHandler
target
- The target of the request - either a URI or a name.base
- The base request.request
- The object or a wrapper of the request.response
- The object or a wrapper of the response.java.io.IOException
javax.servlet.ServletException
public void setAuthorizationToken(java.lang.String token)
token
- Authorization token;public java.lang.String htmlColor(java.lang.String color)
color
- Color text string.protected java.lang.String handleReplacements(org.eclipse.jetty.server.Request base, java.lang.String text)
Example: ${expression}
handleReplacements
in class HtmlResourceHandler
base
- The details and state the request.text
- The text line that may need modifications.private boolean isAuthorized(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
If query parameter is missing check the browser cookies list for a cookie having an authorization token that match the expected cookie. If found the request is authorized otherwise the request is denied. This should happen after initial redirection whenever the page is reloaded.
request
- HttpServletRequest instance.response
- HttpServletResponse instance.true
if authorized false
otherwise.private boolean checkQueryParam(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
request
- HttpServletRequest instance.response
- HttpServletResponse instance.true
if authorized false
otherwise.private boolean checkCookies(javax.servlet.http.HttpServletRequest request)
request
- HttpServletRequest instance.true
if authorized false
otherwise.