信任关联拦截器支持主体集创建

信任关联拦截器 (TAI) com.ibm.wsspi.security.tai.TrustAssociationInterceptor 接口支持一些功能,但这些功能与现有 com.ibm.websphere.security.TrustAssociationInterceptor 接口支持的功能不同。

TAI 接口支持多阶段协商认证进程。例如,某些系统需要支持客户机的提问-应答协议。此接口中的两个关键方法是:
关键方法名
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 结果,它指示请求处理的状态。可以查询请求对象并且可以修改响应对象。
TAIResult 类有三个静态方法可用于创建 TAIResult 结果。TAIResult 创建方法采用 int 类型作为第一个参数。WebSphere Application Server 预期结果是有效的 HTTP 请求返回码并用以下某种方式解释:
  • 如果值是 HttpServletResponse.SC_OK,那么此响应告诉 WebSphere Application Server TAI 已完成它的协商。此响应还告诉 WebSphere Application Server 使用 TAIResult 结果中的信息来创建用户标识。
  • 其他值会要求 WebSphere Application Server 将放置到 HttpServletResponse 响应中的 TAI 输出返回给 Web 客户机。通常,Web 客户机提供其他信息然后向 TAI 发出另一个调用。
表 1. TAIResults 定义. 所创建的 TAIResult 结果具有下列含义:
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 指示状态、用户的用户标识或唯一标识以及定制主题。如果主题包含散列表,那么会忽略主体。主题的内容成为最终用户主题的一部分。
以下所有示例都在 TAI 的 negotiateValidateandEstablishTrust 方法中。
以下代码样本指示需要进行另外的协商:
// Modify the HttpServletResponse object
	//  The response code is meaningful only on the client
		return TAIResult.create(HttpServletResponse.SC_CONTINUE);
以下代码样本指示 TAI 已确定用户标识。WebSphere Application Server 只收到用户标识,并查询用户注册表以获取其他信息:
// modify the HttpServletResponse object
		return TAIResult.create(HttpServletResponse.SC_OK, userid);
以下代码样本指示 TAI 已确定用户标识。WebSphere Application Server 收到包含在散列表中的完整用户信息。有关散列表的更多信息,请参阅配置入站标识映射在此代码样本中,散列表放置在主体集的公用凭证部分。
// 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);
以下代码样本指示认证失败。WebSphere Application Server 认证请求失败:
//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 提供了执行任何必要清除的机会。如果不需要清除,那么此方法不是必需的。

指示主题类型的图标 参考主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rsec_taisubcreate
文件名:rsec_taisubcreate.html