To add browser-based SAML single sign-on to Javalin with pac4j, choose compatible library versions, configure a long-lived SAML2Client with your service provider (SP) keys and identity provider (IdP) metadata, register the SP metadata with the IdP, and connect pac4j’s security, callback, and logout handlers to the appropriate Javalin routes. The callback must accept the IdP’s POSTed assertion, and the client’s replay-cache state must persist between authentications.
Choose compatible versions before writing the integration
The javalin-pac4j README maps version 8 to Javalin 7, pac4j 6, and Java 17. It maps version 7 to Javalin 5.6, pac4j 6, and Java 17. The official Javalin SAML guide shows Javalin 7.0.1, javalin-pac4j 8.0.0, and pac4j-saml 6.5.8. Those are the versions in that example, not a guarantee that they are the latest releases.
Resolve a compatible set of currently released artifacts before implementation. Avoid mixing a Javalin integration version with a Javalin or pac4j major version outside the combinations documented by the integration README.
| javalin-pac4j line | Javalin | pac4j | Java |
|---|---|---|---|
| 8 | 7 | 6 | 17 |
| 7 | 5.6 | 6 | 17 |
These are compatibility combinations documented by the README, not a full dependency lockfile. Check the integration documentation and artifact metadata when selecting exact patch versions.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Prepare the SP keys and metadata
Create and protect a keystore
The SAML client needs SP key material for signing and encryption operations. The Javalin guide demonstrates generating a keystore with Java’s keytool. Treat any passwords shown in a tutorial as examples only: keep the keystore password and private-key password in deployment-managed secrets, not source code or a checked-in configuration file.
pac4j’s SAML 2.0 client reference also describes a writable-resource option for automatic keystore creation. For production, decide deliberately how keys are created, stored, backed up, rotated, and made available to application instances. The private key should not be exposed through a public metadata URL.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Set the SP identity and metadata location
Configure the SAML client with the keystore and its credentials, the IdP metadata, the SP entity ID, and the location where SP metadata is produced. The entity ID is the SP’s identifier; it is not interchangeable with the callback URL. Keep both values consistent with the SP registration at the IdP.
Configure one SAML client and pac4j Config
Create a SAML2Configuration from the SP and IdP settings, then construct a SAML2Client and place it in pac4j’s Config. The same configured client must be used for the protected flow and callback handling. After successful authentication, pac4j supplies a SAML2Profile; application code can use that type or the common UserProfile abstraction, depending on which attributes it needs.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Do not create a fresh SAML client per request without an explicit state strategy. pac4j documents that the client’s replay cache must retain state across authentications and recommends a single client instance. If the deployment cannot retain that instance in the required way, the SAML reference points to a custom ReplayCacheProvider so replay state can be managed appropriately for the deployment.
Register the SP with the identity provider
Exchange the SP metadata generated from your configuration with the IdP administrator or registration workflow, and configure the application with the IdP metadata. The IdP must recognize the SP entity ID and the assertion consumer service (ACS) endpoint where it will send authentication responses.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
- Use the same SP entity ID in the application and IdP registration.
- Make the ACS URL match the application’s callback route, including scheme, host, path, and any externally visible proxy configuration.
- Use metadata and endpoint settings for the organization’s actual IdP; a public test provider in a tutorial is only an example.
An IdP error such as “unknown service provider” commonly indicates that the SP is not registered or that the entity ID sent by the application differs from the registered value.
Connect protection, callback, and logout routes
Protect only the intended routes
Use a Javalin before handler with pac4j’s SecurityHandler on the routes that require authentication. Javalin route patterns are significant: /protected and /protected/* are distinct, so add coverage for both the base path and nested paths if both should be protected. Apply the handler to every intended route rather than assuming the base pattern includes subpaths.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesBest Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Accept the SAML response at the callback
Register pac4j’s callback handling for the indirect SAML flow at the ACS path configured with the IdP. The IdP posts its assertion, so the callback route must be reachable using HTTP POST and its externally registered URL must match the configured callback URL. Ensure the SAML client name is consistent wherever the pac4j callback configuration refers to it.
Choose the logout behavior
Add pac4j’s LogoutHandler and decide whether the application needs only to end its local session or should also request logout at the IdP. Local logout and global single logout are different behaviors; configure the latter only when the IdP supports the needed endpoints and bindings and the application requires that user experience. The integration README documents support for both patterns.
Verify the IdP’s bindings and test the complete flow
Do not assume every provider exposes the same SAML endpoints or bindings. Check the actual IdP metadata and test login and logout against the provider and environment that will be used in production.
One documented compatibility case concerns SimpleSAMLphp: pac4j requires HTTP-POST bindings for both SSO and SLO, while SimpleSAMLphp’s default can expose HTTP-Redirect only. In that case, enable the required POST binding and register the SP entity ID with SimpleSAMLphp. This is provider-specific guidance, not a universal configuration rule for all IdPs.
Quick Recap
- Start the application with the intended production-compatible configuration and confirm that the SP metadata identifies the expected entity ID and ACS endpoint.
- Register that SP metadata with the IdP and confirm the IdP’s metadata and binding configuration are available to the application.
- Open a protected route in a browser and verify that unauthenticated access begins the SAML flow.
- Complete sign-in at the IdP and confirm the POST reaches the configured callback and the application receives the expected profile.
- Exercise the selected logout behavior and inspect the IdP’s response and application session state.
Troubleshoot common integration failures
| Symptom | What to check |
|---|---|
| IdP reports an unknown SP | Compare the application’s SP entity ID with the registered SP metadata. Confirm the ACS URL is also registered and matches the externally reachable callback. |
| Anonymous access reaches a protected page | Check that the SecurityHandler is attached to both the base route and the nested route pattern where needed. |
| Callback fails or does not receive a response | Confirm the callback accepts POST, the ACS URL matches the configured callback, and the SAML client name is consistent in pac4j configuration. |
| Provider rejects an endpoint or binding | Inspect the IdP metadata and provider-specific binding requirements. For the documented SimpleSAMLphp case, configure HTTP-POST for SSO and SLO. |
| Replay or state failures occur intermittently | Retain one SAML client instance across authentications, or implement an appropriate custom replay-cache provider for shared state. |
Implementation checklist
- Choose versions from a documented compatible Javalin, javalin-pac4j, pac4j, and Java combination.
- Generate and protect SP keys; keep credentials out of source control.
- Configure IdP metadata, SP entity ID, and metadata output location in one SAML client configuration.
- Register the resulting SP metadata and matching ACS URL with the IdP.
- Attach security, POST callback, and logout handlers to the routes and behavior you intend.
- Preserve replay-cache state and test against the actual IdP, including its bindings.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

