配置 JAX-RS 2.0 客户机以验证 LTPA 令牌认证信息
关于此任务
轻量级第三方认证 (LTPA) 是定义特定令牌格式的 WebSphere® Application Server 安全性中的一种认证机制。LTPA 令牌认证的目的是将 LTPA 令牌从第一个 Web Service(其认证生成客户机)流动到下游 Web Service。可配置客户机以验证 LTPA 令牌认证。
过程
- 在 WebSphere® Application Server(传统) 管理控制台中配置 LTPA 属性。 要查看管理控制台页面,请完成下列步骤:
- 单击安全性 -> 全局安全性。
- 在认证区域下,单击 LTPA。
有关 LTPA 属性的更多信息,请参阅LTPA。
- 要在开发客户机应用程序时启用 LTPA,请在客户机应用程序代码中添加客户机属性。
将客户机属性键设置为 com.ibm.ws.jaxrs.client.ltpa.handler,将其值设置为 true。请参阅以下代码片段作为参考:
ClientBuilder cb = ClientBuilder.newBuilder(); Client c = cb.build(); c.property("com.ibm.ws.jaxrs.client.ltpa.handler", "true");
- 在应用程序 WAR 文件中的 web.xml 文件中定义 role-name 参数值,如下所示:
<?xml version="1.0" encoding="UTF-8"?> <web-app id="HelloworldServlet" 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>JAX-RS HelloWorld Sample</display-name> <description>Server-side application to test Hello world client.</description> <login-config> <auth-method>FORM</auth-method> <realm-name>defaultWIMFileBasedRealm</realm-name> <form-login-config> <form-login-page>/login.html</form-login-page> <form-error-page>/loginError.jsp</form-error-page> </form-login-config> </login-config> <security-constraint> <display-name>FormLogin</display-name> <web-resource-collection> <web-resource-name>FormLogin</web-resource-name> <url-pattern>/ClientTestServlet</url-pattern> <http-method>GET</http-method> <http-method>POST</http-method> </web-resource-collection> <auth-constraint> <role-name>myTestRole</role-name> </auth-constraint> <user-data-constraint> <transport-guarantee>NONE</transport-guarantee> </user-data-constraint> </security-constraint> <security-role id="SecurityRole_1"> <description>All Authenticated Users Role.</description> <role-name>myTestRole</role-name> </security-role> </web-app>
- 使用管理控制台将客户机应用程序部署到 WebSphere Application Server(传统)。
- 在管理控制台中,将用户或组映射到角色。 要将用户或组映射到角色,请继续完成下列步骤:
- 转到应用程序 -> 应用程序类型 -> WebSphere 企业应用程序。
- 在企业应用程序区域中,选择部署到 WebSphere Application Server(传统) 的一个或多个应用程序。
- 在详细信息属性字段下,选择安全角色到用户/组映射选项。
- 选择在 web.xml 文件中定义的角色名称。
- 单击安全角色到用户/组映射页面上的映射用户按钮,并根据需要配置映射用户属性。
- 单击确定保存配置。
- 在 WebSphere Application Server(传统) 管理控制台中启动应用程序。 要启动应用程序,请转到应用程序 -> 应用程序类型 -> WebSphere 企业应用程序 -> 启动。


http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=twbs_jaxrs_impl_securejaxrs2
文件名:twbs_jaxrs_impl_securejaxrs2.0_ltpa.html