Ssl 如何制作;HTTPS重定向";使用WebSphere Application Server Liberty概要文件?

Ssl 如何制作;HTTPS重定向";使用WebSphere Application Server Liberty概要文件?,ssl,https,websphere,websphere-8,websphere-liberty,Ssl,Https,Websphere,Websphere 8,Websphere Liberty,我想让HTTP重定向在WebSphere Application Server Liberty Profile(WLP)上工作。例如:- 当用户类型: http://localhost:8080/helloworld,浏览器应自动转到(被重定向) https://localhost:9443/helloworld 为了实现这一点,我遵循了第136页第6.2节 下面是server.xml和web.xml的示例:- server.xml <server description="new ser

我想让HTTP重定向在WebSphere Application Server Liberty Profile(WLP)上工作。例如:-

当用户类型:
http://localhost:8080/helloworld
,浏览器应自动转到(被重定向)
https://localhost:9443/helloworld

为了实现这一点,我遵循了第136页第6.2节

下面是server.xml和web.xml的示例:-

server.xml

<server description="new server">

<!-- Enable features -->
<featureManager>
    <feature>jsp-2.2</feature>
    <feature>wab-1.0</feature>
    <feature>jaxrs-1.1</feature>
    <feature>blueprint-1.0</feature>
    <feature>localConnector-1.0</feature>
    <feature>ssl-1.0</feature>
    <feature>appSecurity-2.0</feature>
</featureManager>

<httpEndpoint host="localhost" httpPort="8081" httpsPort="9442" id="defaultHttpEndpoint">
</httpEndpoint>

<applicationMonitor updateTrigger="mbean"/>
<keyStore id="defaultKeyStore" password="{xor}Lz4sLCgwLTtu"/>

<application id="Hello.app" location="Hello.app.eba" name="Hello.app" type="eba"/>
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <display-name>Hello</display-name>

    <security-constraint>
        <display-name>HTTPS Redirect Security Constraint</display-name>
        <web-resource-collection>
            <web-resource-name>Sample Web Service service</web-resource-name>
            <url-pattern>/Hello</url-pattern>
            <http-method>GET</http-method>

        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
</web-app>

jsp-2.2
wab-1.0
jaxrs-1.1
蓝图-1.0
localConnector-1.0
ssl-1.0
appSecurity-2.0

web.xml

<server description="new server">

<!-- Enable features -->
<featureManager>
    <feature>jsp-2.2</feature>
    <feature>wab-1.0</feature>
    <feature>jaxrs-1.1</feature>
    <feature>blueprint-1.0</feature>
    <feature>localConnector-1.0</feature>
    <feature>ssl-1.0</feature>
    <feature>appSecurity-2.0</feature>
</featureManager>

<httpEndpoint host="localhost" httpPort="8081" httpsPort="9442" id="defaultHttpEndpoint">
</httpEndpoint>

<applicationMonitor updateTrigger="mbean"/>
<keyStore id="defaultKeyStore" password="{xor}Lz4sLCgwLTtu"/>

<application id="Hello.app" location="Hello.app.eba" name="Hello.app" type="eba"/>
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">
    <display-name>Hello</display-name>

    <security-constraint>
        <display-name>HTTPS Redirect Security Constraint</display-name>
        <web-resource-collection>
            <web-resource-name>Sample Web Service service</web-resource-name>
            <url-pattern>/Hello</url-pattern>
            <http-method>GET</http-method>

        </web-resource-collection>
        <user-data-constraint>
            <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    </security-constraint>
</web-app>

你好
HTTPS重定向安全约束
示例Web服务
/你好
得到
保密的
为了简洁起见,删除了
标记

以下是我正在使用的版本:- Java7,WLP8.5.5,EclipseJuno,GoogleChrome


非常感谢您提供有关HTTPS重定向不起作用的任何帮助和指导。

我怀疑问题在于您的安全限制。考虑到这一点,我建议将您的url模式更改为:

/地狱世界

而不是:

/你好

如果要匹配多个资源,可以使用通配符,例如:

  • /*-一切都匹配
  • /helloworld/*-匹配url路径中包含helloworld/的所有内容
  • *.jsp-匹配具有jsp扩展名的所有文件

  • 要使HTTPS重定向在WLP上工作,应注意以下几点:-

  • 在WLP的
    server.xml
    中添加用户、角色和密码
  • 将应用程序绑定到安全角色
  • 在WLP的
    server.xml
    中添加appSecurity-2.0功能
  • web.xml中添加以下标记
    
  • 以下是详细的步骤:-

    1。在WLP的
    server.xml
    中添加用户、角色和密码。

    <basicRegistry id="MyRegistry">
        <user password="{xor}Mjo6MT4z" name="anuroop" />
        <group name="MyGroup">
            <member name="anuroop" />
        </group>
    </basicRegistry>
    
    <application id="Hello.app" location="Hello.app.eba" name="Hello.app" type="eba">
        <application-bnd>
            <security-role name="Manager">
            <group name="MyGroup" />
        </security-role>
        </application-bnd>
    </application>
    
    <featureManager>
        <feature>appSecurity-2.0</feature>
    </featureManager>
    
    4.1,4.2,4.3,4.4,4.5

    <login-config>
        <auth-method>FORM</auth-method>
        <realm-name>BasicRegistry</realm-name>
        <form-login-config>
            <form-login-page>/Login.jsp</form-login-page>
            <form-error-page>/LoginError.jsp</form-error-page>
        </form-login-config>
    </login-config>
    
    <security-constraint>
    
            <display-name>HTTPS Redirect Security Constraint</display-name>
            <web-resource-collection>
                <web-resource-name>Sample Web Service service</web-resource-name>
                <url-pattern>/Hello</url-pattern>
                <http-method>GET</http-method>
            </web-resource-collection>
    
        <auth-constraint>
            <role-name>Manager</role-name>
        </auth-constraint>
    
        <user-data-constraint>
        <description>Ensure to allow only confidential communication</description>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
        </user-data-constraint>
    
    </security-constraint>
    
    
    形式
    基础地理学
    /Login.jsp
    /LoginError.jsp
    HTTPS重定向安全约束
    示例Web服务
    /你好
    得到
    经理
    确保只允许保密通信
    保密的
    
    我用不同的方法解决了这个问题,但我认为公认的答案可能更好。您可以编写一个servlet过滤器,然后修改web.xml以将其与路径关联

    web.xml代码:

      <web-app id="WebApp">
          <filter>
            <filter-name>HTTPSFilter</filter-name>
            <filter-class>
            HTTPSFilter
            </filter-class>
        </filter>
        <filter-mapping>
            <filter-name>HTTPSFilter</filter-name>
            <url-pattern>/*</url-pattern>
        </filter-mapping>
        ...
     </web-app>
    

    谢谢你的帮助。但真正的问题似乎是我错过了一个重要的标签。将在验证我的理论后发布答案。@Anuroop您的理论很不幸是错误的,因为您不需要仅用于https重定向的auth约束。您也不需要解决方案中的步骤1和步骤2,也不需要登录配置。因为重定向根本不需要登录。使用web.xml是正确的方法,因为它可以在任何appserver中工作。你是用手做应该用容器做的事。此外,您还硬编码了https端口,因此如果有人需要更改默认端口,您的筛选器将失败。这似乎是WLP中的一个错误。您不应该只需要一个用户来执行重定向。除了WebSphere Classic 9之外,当仅使用安全约束进行重定向时,还需要登录,因此不允许匿名访问。似乎支持匿名websphere重定向的最安全的方法是通过@Vince Thyng提到的过滤器