【问题标题】:pac4j-saml client is not sending a request to the IDPpac4j-saml 客户端未向 IDP 发送请求
【发布时间】:2020-03-11 12:55:33
【问题描述】:

我正在尝试让 pac4j-saml 运行。我有一个本地 IDP 正在运行,现在正在尝试通过 tomcat 设置一个简单的服务提供商。

根据documentation,这应该相当简单,但它不会起作用。

如果我对文档的解释是正确的,这应该会触发对 IDP 的 SP 请求:

<%@ page import="org.pac4j.saml.client.SAML2Client" %>
<%@ page import="org.pac4j.saml.config.SAML2Configuration" %>
<%@ page import="org.springframework.core.io.FileSystemResource" %>

<%
SAML2Configuration cfg = new SAML2Configuration(
        new FileSystemResource("/path/to/samlKeystore.jks"),
        "password",
        "password",
        new FileSystemResource("/path/to/idp.xml")
);
cfg.setAuthnRequestBindingType("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST");

SAML2Client client = new SAML2Client(cfg);
client.setCallbackUrl("http://localhost:8080/saml/callback.jsp");

%>

test

测试打印在页面上,但没有重定向。所以至少我所有的导入和 tomcat 等都按预期工作。

我的一些 saml 代码似乎可以工作,因为我可以使用以下命令使用 pac4j-saml 库创建 SP 元数据:

<%
//Get SP metadata.xml
out.print(client.getServiceProviderMetadataResolver().getMetadata().toString());
%>

谁能给我一个提示,说明我缺少什么来获得对 IDP 的初始请求?

谢谢, FMK

【问题讨论】:

    标签: java jsp tomcat saml pac4j


    【解决方案1】:

    根据库的维护者的说法,这是不使用任何集成的方法(这在我的情况下有效):

    <%@ page import="org.pac4j.saml.client.SAML2Client" %>
    <%@ page import="org.pac4j.saml.config.SAML2Configuration" %>
    <%@ page import="org.springframework.core.io.FileSystemResource" %>
    
    <%
    SAML2Configuration cfg = new SAML2Configuration(
            new FileSystemResource("/path/to/samlKeystore.jks"),
            "password",
            "password",
            new FileSystemResource("/path/to/idp.xml")
    );
    cfg.setAuthnRequestBindingType("urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST");
    
    SAML2Client client = new SAML2Client(cfg);
    client.setCallbackUrl("http://localhost:8080/saml/callback.jsp");
    
    J2EContext context = new J2EContext(request, response);
    client.redirect(context);
    
    %>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-03
      • 2019-09-05
      • 2020-10-24
      • 2021-10-16
      • 1970-01-01
      相关资源
      最近更新 更多