0

I'm trying to get the pac4j-saml running. I've got a local IDP running and am now trying to setup a simple service provider via tomcat.

Acording to the documentation this should be fairly simple but it will not work.

If my interpretation of the documentation is right this should trigger the SP request to the IDP:

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

The test is printed on the page but there is no redirection. So at least all my imports and tomcat etc. are working as expected.

Some of my saml code seems to work since I'm able to create the SP metadata with the pac4j-saml library using this command:

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

Can anyone give me an hint to what I'm missing to get the initial request to the IDP?

Thanks, FMK

FMK
  • 1,062
  • 1
  • 14
  • 25

1 Answers1

0

According to the maintainer of the library this is the way to do it without the usage of any of the integrations (this works in my case):

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

%>
FMK
  • 1,062
  • 1
  • 14
  • 25