java - TAI 的 isTargetInterceptor 方法没有被调用

标签 java single-sign-on websphere-8

我正在尝试使用 TAI 拦截器来拦截来自尝试访问我的应用程序的受信任第三方的请求。我的目的是避免向用户显示身份验证页面,因为用户已经在我信任的第三方应用程序中进行了身份验证。

为此,我创建了一个实现 TrustAssociationInterceptor 的简单类。我在方法中有几个系统输出,例如 初始化isTargetInterceptornegotiateValidateandEstablishTrust

我已经创建了一个 Jar 文件并将其放置在 \Appserver\lib\ext 文件夹 中。

我还在拦截器中配置了自定义 TAI。从 WebSphere Application Server 管理控制台, 导航到安全=>全局安全=>Web和SIP安全=>信任关联=>启用启用信任关联的复选框并保存=>拦截器=>单击新建并输入我的名称自定义 TAI 类。

当WebSphere 服务器启动时,将调用initialize 方法。我可以在 \Appserver\profiles\AppSrv1\logs\server1\SystemOut.txt 中看到系统输出。

我创建了一个示例 Web 应用程序,它从 JSP 页面调用 servlet。 我的问题是我的自定义 TAI 不会在中间拦截,我的请求直接发送到 servlet。 (我在 SystemOut.txt 中没有看到任何系统输出)

我在这里遗漏了什么吗?

最佳答案

检查您是否有:

  • 已启用应用程序安全性(在控制台中 - 安全性 > 全局安全性)
  • 您的应用程序在 web.xml 中定义了安全约束,因为您必须访问 protected 资源才能让 TAI 拦截。

您可以启用跟踪 com.ibm.ws.security.*=all,以便在向应用程序发出请求期间在 trace.log 中查看更多详细信息。

更新
这是我的样本。我使用的是WAS 8.5.5.1,所有方法都被调用:

// during start
[8/6/14 20:37:09:544 CEST] 00000001 TrustAssociat A   SECJ0121I: Trust Association Init class tai.TaiTest loaded successfully
[8/6/14 20:37:09:544 CEST] 00000001 SystemOut     O initialize
[8/6/14 20:37:09:544 CEST] 00000001 SystemOut     O getVersion
[8/6/14 20:37:09:544 CEST] 00000001 TrustAssociat A   SECJ0122I: Trust Association Init Interceptor signature: 1.0
[8/6/14 20:37:09:544 CEST] 00000001 SystemOut     O getType

//during stop
[8/6/14 20:40:24:338 CEST] 0000008d SystemOut     O cleanup

示例代码:

package tai;

import java.util.Properties;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ibm.websphere.security.WebTrustAssociationException;
import com.ibm.websphere.security.WebTrustAssociationFailedException;
import com.ibm.wsspi.security.tai.TAIResult;
import com.ibm.wsspi.security.tai.TrustAssociationInterceptor;

public class TaiTest implements TrustAssociationInterceptor {

    @Override
    public void cleanup() {
        System.out.println("cleanup");
    }

    @Override
    public String getType() {
        System.out.println("getType");
        return "TaiTest";
    }

    @Override
    public String getVersion() {
        System.out.println("getVersion");
        return "1.0";
    }

    @Override
    public int initialize(Properties arg0)
            throws WebTrustAssociationFailedException {
        System.out.println("initialize");
        return 0;
    }

    @Override
    public boolean isTargetInterceptor(HttpServletRequest arg0)
            throws WebTrustAssociationException {
        System.out.println("isTarget");
        return false;
    }

    @Override
    public TAIResult negotiateValidateandEstablishTrust(
            HttpServletRequest arg0, HttpServletResponse arg1)
            throws WebTrustAssociationFailedException {
        // TODO Auto-generated method stub
        System.out.println("Negotiate");
        return null;
    }
}

关于java - TAI 的 isTargetInterceptor 方法没有被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25051799/

相关文章:

java - Java (Android 8.0.0) 中的本地浮点变量如何被损坏?

tomcat - 检索 Java EE Web 应用程序中的当前 Windows 用户以实现单点登录

java - Websphere App 8 : DataContentHandler requires String object, 被赋予类型为 com.sun.jersey.api.view.Viewable 类的对象

java - 一个适配器中有多个 View (充气器)

java - Android listview in listview追加数据

java - 操作系统 : the trustAnchors parameter must be non-empty

java - Websphere liberty 配置文件错误 : 404 SRVE0190E

angular - keycloak saml 登录后请求无效,缺少参数用户名

java - 在 Java 中没有 cookie 的单点登录

java - JVMJ9VM035 无法分配 OutOfMemoryError