public class WebPageHandler extends HtmlResourceHandler
Modifier and Type | Class and Description |
---|---|
protected class |
WebPageHandler.WebPageKeysProvider
Builds the target map of keys and their value providers for the associated template
given by the skeleton page.
|
HtmlResourceHandler.HtmlTemplateKeysProvider
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
authorizationToken
Authorization token
|
protected 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.
|
protected java.util.Map<java.lang.String,java.util.function.Supplier<java.lang.String>> |
getTemplateKeys(org.eclipse.jetty.server.Request base)
Generates a map of template keys with their value suppliers in order to fill gaps in
the html skeleton template page.
|
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.
|
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
protected 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.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.protected java.util.Map<java.lang.String,java.util.function.Supplier<java.lang.String>> getTemplateKeys(org.eclipse.jetty.server.Request base)
getTemplateKeys
in class HtmlResourceHandler
base
- The request