2011-10-20 64 views
2

Https连接子域https连接子站点URL更改

Im寻求使用HTTPS设置我的wickets 1.5应用程序。

我已将以下内容添加到我的应用程序类中。

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

,因为我有注释的securePage.class与"@RequireHttps"链接正确加载使用HTTPS页面。

但是我想转发所有https连接到一个单独的子域。

因此而不是去

https://www.example.com/go/securepage用户转发到 https://securepage.example.com/go/securepage

如何才能做到这一点?

回答

3

我从来没有需要这样做,但看看HttpsMapper的来源,看来你可以通过重写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; 
    } 

所以,你可以重写它是这样的:

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; 
    } 
}); 
+0

优秀王子约翰·卫斯理,这就是工作了魅力。 – Fergal

+0

对不起,哈维洛佩斯,:-) – Fergal