pac4j-saml客户端未向IDP发送请求

问题描述 投票:0回答:1

我正在尝试使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个回答
0
投票

根据库的维护者,这是在不使用任何集成的情况下进行此操作的方式(在我的情况下,这是可行的:]

<%@ 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);

%>
© www.soinside.com 2019 - 2024. All rights reserved.