A minimal SAML 2.0 Service Provider for the integration test leg of
NemLog-in DevTest4, the pre-production
environment (https://saml.test-devtest4-nemlog-in.dk), built on Spring Security's own SAML support.
Disclaimer: this is not a complete example or a production-ready Service Provider. It only shows how Spring Security's SAML support can be adapted to work with NemLog-in. Hardening, session handling, error handling, logging and certificate management are left to the integrating application.
Java 25, Maven, Spring Boot 4.1.1, Spring Security 7.1 (spring-security-saml2-service-provider,
OpenSAML 5), Thymeleaf. OpenSAML 5 is not on Maven Central, so pom.xml adds the Shibboleth repository.
mvn spring-boot:runOpen https://localhost:8443/secure and accept the certificate warning. For demo purposes the SP
(entity ID https://oiosaml.java-spring) is already registered in the DevTest4 integration test leg,
so login works out of the box.
NemLog-in encrypts the assertion but leaves the enclosing <saml2p:Response> unsigned. The
signature is on the assertion inside the encrypted blob. Spring Security's
BaseOpenSamlAuthenticationProvider only decrypts when the response itself is signed, in a private
method no hook can reach, so every NemLog-in login with Spring SAML defaults fails with
"Did not decrypt response […] since it is not signed".
EncryptedAssertionDecryptingConverter decrypts one step earlier, in the AuthenticationConverter,
and hands the provider a response whose assertion is already decrypted. The provider still verifies
the assertion signature against the IdP metadata so no signature check is skipped.
EncryptedAssertionDecryptingConverterTests shows the provider rejecting the NemLog-in message shape
alone and accepting it after the converter.
Sample includes copy of own metadata as well as pre-production inttest metadata.
| URL | Purpose |
|---|---|
/secure |
protected page, triggers login |
/saml2/metadata |
SP metadata |
/saml2/login |
assertion consumer service |
/saml2/logout |
single logout |
/logout |
SP-initiated logout (POST) |
- ACS and SLO are moved from Spring's defaults to
/saml2/loginand/saml2/logout, so the metadata URLs carry no registration id.SamlSecurityConfigsets this on the registration, thesaml2Login/saml2Logoutconfigurers and the converter's request matcher. - The
AuthnRequestis signed withrsa-sha256and requests the NSIS level fromnemlogin.nsis-level(Comparison="minimum"). /secureshows the NameID and raw attributes without interpreting them. For a full OIOSAML 3 profile implementation, see OIOSAML.Java.
Apache License 2.0. Security issues: see SECURITY.md.