2

Https Connection subdomain

Im Looking to set up my wickets 1.5 application with HTTPS.

I have added the following to my Application Class.

setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(8080, 8443)));
mountPage("/go/securepage", securePage.class);

As i have annotated the securePage.class with "@RequireHttps" the Link correctly loads the page with HTTPS.

However i want to forward all https connections to a seperate subdomain.

So instead of going to

https://www.example.com/go/securepage the user is forwarded to https://securepage.example.com/go/securepage

How can this be done?

Prince John Wesley
  • 62,492
  • 12
  • 87
  • 94
Fergal
  • 43
  • 4

1 Answers1

3

I've never needed to do this, but looking at the sources of HttpsMapper it seems you will we able to do this by overriding HttpsMapper.mapHandler().

public Url mapHandler(IRequestHandler requestHandler) {
        Url url = delegate.mapHandler(requestHandler);
        switch (checker.getProtocol(requestHandler)){
            case HTTP :
                url.setProtocol("http");
                url.setPort(httpsConfig.getHttpPort());
                break;
            case HTTPS :
                url.setProtocol("https");
                url.setPort(httpsConfig.getHttpsPort());
                break;
        }
        return url;
    }

So, you can override it like this:

setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(8080, 8443)){
    @Override
    public Url mapHandler(IRequestHandler requestHandler) {
        Url url = super.mapHandler(requestHandler);
        if ("https".equals(url.getProtocol)){
            // Force the HostName for HTTPS requests
            url.setHost("securepage.example.com");   
        }
        return url;
    }
});
Xavi López
  • 27,550
  • 11
  • 97
  • 161