Following on from my previous article about configuring SAML SSO with Tomcat and Picketlink this time I will show you how to do the same thing with JBoss Wildfly.

The afore mentioned article can be found here SAML Single Sign-On with Tomcat and PicketLink I will include the sequence diagram for SAML Single Sign-On here as well. For a detailed explanation of the diagram see my previous article

To enable SAML Single Sign-On in Wildfly, you also need to enable SSL for the inbound connection / call back when the users browser sends their token supplied by the Identity Provider to avoid man in the middle attacks.

Commands for setting up SSL on JBoss (wildfly_ssl.cli)

create the script below and execute it with this command $JBOSS_HOME/bin/ --connect --file=wildfly_ssl.cli

# Batch script to add and configure the quickstart-domain security domain in the JBoss server

# Start batching commands

# Add and configure the security domain, then add the PicketLink SAML2LoginModule. Which wil be used to extract user's information from the SAML Assertion and authenticate the user.
/core-service=management/security-realm=SSLRealm/server-identity=ssl:add(keystore-path=ssl-keystore.jks, keystore-relative-to=jboss.server.config.dir,keystore-password=changeit, alias=myhostname.local, key-password=changeit)

# Run the batch commands

# Reload the server configuration

/subsystem=undertow/server=default-server/https-listener=https:add(socket-binding=https, security-realm=SSLRealm)


It isn’t necessary to install PicketLink libraries on JBOSS because they are preinstalled. Custom handlers may need to be installed depending on the configuration of the identity provider.

For one identity provider I had to implement a handler for splitting a list of roles because they were stored in a single assertion attribute. In another case it was necessary to retrieve the the username from an assertion attribute and then change the user principal to reflect this name.

Web Application / Web Archive Structure

Here our web app config will end up with the following structure:


Changes to the web.xml

You must define the role names used in LDAP within the web.xml like this:

    <description>App Users</description>

These roles will then need to be specified within the SecurityConstraints within the web.xml as well, like this:

        <web-resource-name>User Space</web-resource-name>

However do not remove the login-config section because unlike in Tomcat here it is required even if never used.


Add picketlink.xml to the WEB-INF folder

<?xml version="1.0" encoding="UTF-8"?>
<PicketLink xmlns="urn:picketlink:identity-federation:config:2.1">
  <PicketLinkSP xmlns="urn:picketlink:identity-federation:config:2.1" BindingType="POST">
  <Handlers xmlns="urn:picketlink:identity-federation:handler:config:2.1">
    <Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2IssuerTrustHandler" />
    <Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2LogOutHandler" />
    <Handler class="org.picketlink.identity.federation.web.handlers.saml2.SAML2AuthenticationHandler">
      <Option Key="ROLE_KEY" Value=""/>
    <Handler class="org.picketlink.identity.federation.web.handlers.saml2.RolesGenerationHandler" />

Valves and Realms

Unlike tomcat here a valve is not required and apart from the SSLRealm we configured earlier there isn’t any need for a specific realm for SAML

JBoss does require a jboss-web.xml in the WEB-INF folder.

In this file is specified the Security Domain for the web app, the one configured previously in the cli file. We also define the context root of the web app which should match the prefix in the picketlink file when referring to the ServiceURL e.g. if the context is myapp the service url is prefixed with [generic]${myapp.url::[/generic]



In the [shell]META-INF[/shell] folder add a file called jboss-deployment-structure.xml. This file should contain the module dependencies of the web app, in this case we have added [java]org.picketlink[/java] as a dependency.

<?xml version="1.0" encoding="UTF-8"?>


      <module name="org.picketlink"/>




Now we should add a service definition to the war, telling it to use the SPServletExtension. You do this by creating a file called [java]io.undertow.servlet.ServletExtension[/java] in the folder [shell]WEB-INF/classes/META-INF/services/[/shell]

the file should contain the following class name:



Useful command for checking out the log files which you use from the JBoss command line interface [shell]$JBOSS_HOME/bin/ –connect.[/shell]