信任关联拦截器支持主体集创建
信任关联拦截器 (TAI) com.ibm.wsspi.security.tai.TrustAssociationInterceptor 接口支持一些功能,但这些功能与现有 com.ibm.websphere.security.TrustAssociationInterceptor 接口支持的功能不同。
- 关键方法名
- public boolean isTargetInterceptor (HttpServletRequest req)
isTargetInterceptor 方法确定该请求是否由与拦截器相关联的代理服务器生成。实现代码必须检查入局请求对象,并确定转发请求的代理服务器对于此拦截器是否为有效的代理服务器。此方法的结果确定拦截器是否处理请求。
- 方法结果
true 值会告诉 WebSphere® Application Server 让 TAI 来处理请求。
false 值会告诉 WebSphere Application Server 忽略 TAI。
- 关键方法名
- public TAIResult negotiateValidateandEstablishTrust (HttpServletRequest
req, HttpServletResponse res)
negotiateValidateandEstablishTrust 方法确定是否信任产生请求的代理服务器。 实现代码必须认证代理服务器。认证机制是特定于代理服务器的。例如,在 WebSEAL 服务器的产品实现中,此方法检索来自 HTTP 头的基本认证信息,并针对 WebSphere Application Server 使用的用户注册表验证信息。如果凭证无效,那么代码将生成 WebTrustAssociationException 异常,它指示代理服务器不可信且请求被拒绝。如果凭证有效,那么代码返回 TAIResult 结果,它指示请求处理的状态以及用于对 Web 资源授权的客户机标识(主体集和主体名称)。
- 方法结果
- 返回 TAIResult 结果,它指示请求处理的状态。可以查询请求对象并且可以修改响应对象。
- 如果值是 HttpServletResponse.SC_OK,那么此响应告诉 WebSphere Application Server TAI 已完成它的协商。此响应还告诉 WebSphere Application Server 使用 TAIResult 结果中的信息来创建用户标识。
- 其他值会要求 WebSphere Application Server 将放置到 HttpServletResponse 响应中的 TAI 输出返回给 Web 客户机。通常,Web 客户机提供其他信息然后向 TAI 发出另一个调用。
TAIResult | 说明 |
---|---|
public static TAIResult create(int status); | 向 WebSphere Application Server 指示状态。这些状态不能为 SC_OK,这是因为已提供标识信息。 |
public static TAIResult create(int status, String principal); | 向 WebSphere Application Server 指示状态并提供此用户的用户标识或唯一标识。WebSphere Application Server 通过查询用户注册表来创建凭证。 |
public static TAIResult create(int status, String principal, Subject subject); | 向 WebSphere Application Server 指示状态、用户的用户标识或唯一标识以及定制主题。如果主题包含散列表,那么会忽略主体。主题的内容成为最终用户主题的一部分。 |
// Modify the HttpServletResponse object
// The response code is meaningful only on the client
return TAIResult.create(HttpServletResponse.SC_CONTINUE);
// modify the HttpServletResponse object
return TAIResult.create(HttpServletResponse.SC_OK, userid);
// create Subject and place Hashtable in it
Subject subject = new Subject;
subject.getPublicCredentials().add(hashtable);
// the response code is meaningful for only the client
return TAIResult.create(HttpServletResponse.SC_OK, "ignored", subject);
//log error message
// ....
throw new WebTrustAssociationFailedException("TAI failed for this reason");
下列方法是 TrustAssociationInterceptor 接口上的附加方法。这些方法用于初始化 TAI、关闭 TAI 以及对 WebSphere Application Server 标识 TAI。有关更多信息,请参阅 Java™ 文档。
- 方法名
- public int initialize(Properties props)
- 方法结果
- 将在 TAI 初始化期间调用此方法,并且仅在对拦截器配置定制属性后才调用此方法。
- 方法名
- public String getVersion()
- 方法结果
- 此方法返回 TAI 的版本。
- 方法名
- public String getType()
- 方法结果
- 此方法返回 TAI 的类型。
- 方法名
- public void cleanup()
- 方法结果
- 停止 WebSphere Application Server 进程时将调用此方法。停止 WebSphere Application Server 进程为 TAI 提供了执行任何必要清除的机会。如果不需要清除,那么此方法不是必需的。