public class HttpsMapper extends Object implements IRequestMapperDelegate
IRequestMapper
that will issue a redirect to secured communication (over https) if the
page resolved by delegate is annotated with @RequireHttps
To setup it:
public class MyApplication extends WebApplication { public void init() { super.init(); getRootRequestMapperAsCompound().add(new MountedMapper("secured", HttpsPage.class)); mountPage(SomeOtherPage.class); // notice that in most cases this should be done as the // last mounting-related operation because it replaces the root mapper setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(80, 443))); } }any request to http://hostname:httpPort/secured will be redirected to https://hostname:httpsPort/secured
Modifier and Type | Class and Description |
---|---|
static class |
HttpsMapper.RedirectHandler
Handler that takes care of redirecting
|
Constructor and Description |
---|
HttpsMapper(IRequestMapper delegate,
HttpsConfig config)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected IRequestHandler |
createRedirectHandler(String url)
Creates the
IRequestHandler that will be responsible for the redirect |
protected String |
createRedirectUrl(IRequestHandler handler,
Request request,
Scheme scheme)
Constructs a redirect url that should switch the user to the specified
scheme |
int |
getCompatibilityScore(Request request) |
HttpsConfig |
getConfig() |
IRequestMapper |
getDelegateMapper() |
protected Scheme |
getDesiredSchemeFor(Class<? extends IRequestablePage> pageClass)
Determines which
Scheme should be used to access the page |
protected Scheme |
getDesiredSchemeFor(IRequestHandler handler)
Figures out which
Scheme should be used to access the request handler |
protected Scheme |
getSchemeOf(Request request)
Determines the
Scheme of the request |
Url |
mapHandler(IRequestHandler handler) |
IRequestHandler |
mapRequest(Request request) |
public HttpsMapper(IRequestMapper delegate, HttpsConfig config)
delegate
- config
- public IRequestMapper getDelegateMapper()
getDelegateMapper
in interface IRequestMapperDelegate
public final int getCompatibilityScore(Request request)
getCompatibilityScore
in interface IRequestMapper
public final IRequestHandler mapRequest(Request request)
mapRequest
in interface IRequestMapper
public final Url mapHandler(IRequestHandler handler)
mapHandler
in interface IRequestMapper
protected IRequestHandler createRedirectHandler(String url)
IRequestHandler
that will be responsible for the redirecturl
- protected String createRedirectUrl(IRequestHandler handler, Request request, Scheme scheme)
scheme
handler
- request handler being accessedrequest
- current requestscheme
- desired scheme for the redirect urlprotected Scheme getDesiredSchemeFor(IRequestHandler handler)
Scheme
should be used to access the request handlerhandler
- request handlerScheme
protected Scheme getSchemeOf(Request request)
Scheme
of the requestrequest
- Scheme.HTTPS
or Scheme.HTTP
protected Scheme getDesiredSchemeFor(Class<? extends IRequestablePage> pageClass)
Scheme
should be used to access the pagepageClass
- type of pageScheme
public final HttpsConfig getConfig()
Copyright © 2006–2018 Apache Software Foundation. All rights reserved.