如何制作“HTTPS重定向”在WebSphere Application Server Liberty Profile上工作? [英] How to make "HTTPS redirect" work on WebSphere Application Server Liberty Profile?

查看:188
本文介绍了如何制作“HTTPS重定向”在WebSphere Application Server Liberty Profile上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让HTTP Redirect在WebSphere Application Server Liberty Profile(WLP)上运行。例如: -

I want make HTTP Redirect work on WebSphere Application Server Liberty Profile (WLP). For example:-

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

When user types: http://localhost:8080/helloworld, the browser should automatically go (be redirected) to https://localhost:9443/helloworld

为实现这一目标,我遵循了文档,第6.2节,第页。 136.

To achieve this, I followed this document, Section 6.2, page no. 136.

以下是示例server.xml和web.xml: -

Below is the sample server.xml and web.xml:-

服务器。 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"/>

web.xml

<?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>

已删除< servlet> < servlet-mapping> 标签为了简洁。

Have removed the <servlet> and <servlet-mapping> tag for brevity.

以下是我使用的版本: -
Java 7,WLP 8.5.5,Eclipse Juno,谷歌浏览器。

Below are the versions that I am using:- Java 7, WLP 8.5.5, Eclipse Juno, Google Chrome.

任何帮助,关于为什么HTTPS重定向不起作用的指南将非常感激。

Any help, guidelines on why HTTPS redirect is not working will be much appreciated.

推荐答案

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

To make HTTPS Redirect work on WLP, following points should be taken care of:-


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

  2. Bind应用于安全角色。

  3. 在WLP的 server.xml 中添加appSecurity-2.0功能。

  4. web.xml中添加以下标记
  1. Add users, roles, and passwords in server.xml of WLP.
  2. Bind the application to the security role.
  3. Add appSecurity-2.0 feature in server.xml of WLP.
  4. Add following tags in web.xml

  1. < login-config>

  2. < security-constraint>

  3. < security-constraint>< web-resource-name>< / security-constraint>

  4. < security-constraint>< auth-constraint>< / security-constraint>

  5. < ; security-constraint>< user-data-constraint>< / security-constraint>

  1. <login-config>
  2. <security-constraint>
  3. <security-constraint><web-resource-name></security-constraint>
  4. <security-constraint><auth-constraint></security-constraint>
  5. <security-constraint><user-data-constraint></security-constraint>


以下是详细步骤: -

Below are the steps in detail:-

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

1. Add users, roles, and passwords in server.xml of WLP.

<basicRegistry id="MyRegistry">
    <user password="{xor}Mjo6MT4z" name="anuroop" />
    <group name="MyGroup">
        <member name="anuroop" />
    </group>
</basicRegistry>

2。将应用程序绑定到安全角色。

<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>

3。在WLP的 server.xml 中添加appSecurity-2.0功能。

3. Add appSecurity-2.0 feature in server.xml of WLP.

<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>

这篇关于如何制作“HTTPS重定向”在WebSphere Application Server Liberty Profile上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆