Class HttpsMapper

  • All Implemented Interfaces:
    org.apache.wicket.request.IRequestMapper, org.apache.wicket.request.mapper.IRequestMapperDelegate

    public class HttpsMapper
    extends Object
    implements org.apache.wicket.request.mapper.IRequestMapperDelegate
    A 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
    Author:
    igor
    • Constructor Detail

      • HttpsMapper

        public HttpsMapper​(org.apache.wicket.request.IRequestMapper delegate,
                           HttpsConfig config)
        Constructor
        Parameters:
        delegate -
        config -
    • Method Detail

      • getDelegateMapper

        public org.apache.wicket.request.IRequestMapper getDelegateMapper()
        Specified by:
        getDelegateMapper in interface org.apache.wicket.request.mapper.IRequestMapperDelegate
      • getCompatibilityScore

        public final int getCompatibilityScore​(org.apache.wicket.request.Request request)
        Specified by:
        getCompatibilityScore in interface org.apache.wicket.request.IRequestMapper
      • mapRequest

        public final org.apache.wicket.request.IRequestHandler mapRequest​(org.apache.wicket.request.Request request)
        Specified by:
        mapRequest in interface org.apache.wicket.request.IRequestMapper
      • mapHandler

        public final org.apache.wicket.request.Url mapHandler​(org.apache.wicket.request.IRequestHandler handler)
        Specified by:
        mapHandler in interface org.apache.wicket.request.IRequestMapper
      • createRedirectHandler

        protected org.apache.wicket.request.IRequestHandler createRedirectHandler​(String url)
        Creates the IRequestHandler that will be responsible for the redirect
        Parameters:
        url -
        Returns:
        request handler
      • createRedirectUrl

        protected String createRedirectUrl​(org.apache.wicket.request.IRequestHandler handler,
                                           org.apache.wicket.request.Request request,
                                           Scheme scheme)
        Constructs a redirect url that should switch the user to the specified scheme
        Parameters:
        handler - request handler being accessed
        request - current request
        scheme - desired scheme for the redirect url
        Returns:
        url
      • getDesiredSchemeFor

        protected Scheme getDesiredSchemeFor​(org.apache.wicket.request.IRequestHandler handler)
        Figures out which Scheme should be used to access the request handler
        Parameters:
        handler - request handler
        Returns:
        Scheme
      • getConfig

        public final HttpsConfig getConfig()
        Returns:
        config with which this mapper was created