2010-08-19 86 views
2

我正在使用JBoss 4.2。我希望通過HTTPS訪問特定的網址格式。 我使用了自我認證的密鑰庫文件,問題是:一旦HTTPS網址被訪問, 網站上的所有其他網址都會通過HTTPS,那麼問題是什麼?Jboss中的HTTPS配置

已更新:我發現了這個問題。我使用相對路徑來引用資源,所以一旦URL更改爲HTTPS,所有後續鏈接都將以HTTPS啓動,那麼我必須在HTTPS網頁中使用絕對路徑嗎?

我的配置是這樣的: 在web.xml:

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>artists.jsp</web-resource-name> 
     <url-pattern>/artists.*</url-pattern> 
     <http-method>GET</http-method> 
     <http-method>POST</http-method> 
    </web-resource-collection> 
    <user-data-constraint> 
     <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint> 
</security-constraint> 

server.xml中:

<Connector port="8443" 
    scheme="https"  
    secure="true"  
    clientAuth="false" 
    keystoreFile="${jboss.server.home.dir}/conf/server.keystore" 
    keystorePass="changeit" 
    sslProtocol = "TLS" /> 

回答

1

不幸的是肯定的,因爲一個URL開始與協議(HTTP,HTTPS)你需要絕對路徑在它們之間切換。

我的建議是:編寫一個靜態方法,將您的URL進行合理的格式化,並引入一些命名約定,比如所有以i.g開頭的頁面。 _sec旨在與https一起使用。

僞代碼(未測試只是爲了說明基本想法):

public static String fmtURL(String relpath) { 
    String url = relparth.startsWith("_sec") ? "https://":"http://"; 
    url += hostname;      // from a configfile 
    if (relparth.startsWith("_sec") { 
     url += ":443"; 
    } 
    url += relpath; 
    return url; 
}