2010-08-19 85 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; 
}