|
|
@ -26,6 +26,7 @@ import java.util.function.Consumer;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
|
|
|
|
|
|
import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.Decryption;
|
|
|
|
import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.Identityprovider.Verification;
|
|
|
|
import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.Identityprovider.Verification;
|
|
|
|
import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.Registration;
|
|
|
|
import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.Registration;
|
|
|
|
import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.Registration.Signing;
|
|
|
|
import org.springframework.boot.autoconfigure.security.saml2.Saml2RelyingPartyProperties.Registration.Signing;
|
|
|
@ -36,6 +37,7 @@ import org.springframework.context.annotation.Configuration;
|
|
|
|
import org.springframework.core.io.Resource;
|
|
|
|
import org.springframework.core.io.Resource;
|
|
|
|
import org.springframework.security.converter.RsaKeyConverters;
|
|
|
|
import org.springframework.security.converter.RsaKeyConverters;
|
|
|
|
import org.springframework.security.saml2.core.Saml2X509Credential;
|
|
|
|
import org.springframework.security.saml2.core.Saml2X509Credential;
|
|
|
|
|
|
|
|
import org.springframework.security.saml2.core.Saml2X509Credential.Saml2X509CredentialType;
|
|
|
|
import org.springframework.security.saml2.provider.service.registration.InMemoryRelyingPartyRegistrationRepository;
|
|
|
|
import org.springframework.security.saml2.provider.service.registration.InMemoryRelyingPartyRegistrationRepository;
|
|
|
|
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration;
|
|
|
|
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration;
|
|
|
|
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration.AssertingPartyDetails;
|
|
|
|
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration.AssertingPartyDetails;
|
|
|
@ -78,6 +80,8 @@ class Saml2RelyingPartyRegistrationConfiguration {
|
|
|
|
builder.assertingPartyDetails(mapIdentityProvider(properties, usingMetadata));
|
|
|
|
builder.assertingPartyDetails(mapIdentityProvider(properties, usingMetadata));
|
|
|
|
builder.signingX509Credentials((credentials) -> properties.getSigning().getCredentials().stream()
|
|
|
|
builder.signingX509Credentials((credentials) -> properties.getSigning().getCredentials().stream()
|
|
|
|
.map(this::asSigningCredential).forEach(credentials::add));
|
|
|
|
.map(this::asSigningCredential).forEach(credentials::add));
|
|
|
|
|
|
|
|
builder.decryptionX509Credentials((credentials) -> properties.getDecryption().getCredentials().stream()
|
|
|
|
|
|
|
|
.map(this::asDecryptionCredential).forEach(credentials::add));
|
|
|
|
builder.assertingPartyDetails((details) -> details
|
|
|
|
builder.assertingPartyDetails((details) -> details
|
|
|
|
.verificationX509Credentials((credentials) -> properties.getIdentityprovider().getVerification()
|
|
|
|
.verificationX509Credentials((credentials) -> properties.getIdentityprovider().getVerification()
|
|
|
|
.getCredentials().stream().map(this::asVerificationCredential).forEach(credentials::add)));
|
|
|
|
.getCredentials().stream().map(this::asVerificationCredential).forEach(credentials::add)));
|
|
|
@ -111,8 +115,13 @@ class Saml2RelyingPartyRegistrationConfiguration {
|
|
|
|
private Saml2X509Credential asSigningCredential(Signing.Credential properties) {
|
|
|
|
private Saml2X509Credential asSigningCredential(Signing.Credential properties) {
|
|
|
|
RSAPrivateKey privateKey = readPrivateKey(properties.getPrivateKeyLocation());
|
|
|
|
RSAPrivateKey privateKey = readPrivateKey(properties.getPrivateKeyLocation());
|
|
|
|
X509Certificate certificate = readCertificate(properties.getCertificateLocation());
|
|
|
|
X509Certificate certificate = readCertificate(properties.getCertificateLocation());
|
|
|
|
return new Saml2X509Credential(privateKey, certificate, Saml2X509Credential.Saml2X509CredentialType.SIGNING,
|
|
|
|
return new Saml2X509Credential(privateKey, certificate, Saml2X509CredentialType.SIGNING);
|
|
|
|
Saml2X509Credential.Saml2X509CredentialType.DECRYPTION);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Saml2X509Credential asDecryptionCredential(Decryption.Credential properties) {
|
|
|
|
|
|
|
|
RSAPrivateKey privateKey = readPrivateKey(properties.getPrivateKeyLocation());
|
|
|
|
|
|
|
|
X509Certificate certificate = readCertificate(properties.getCertificateLocation());
|
|
|
|
|
|
|
|
return new Saml2X509Credential(privateKey, certificate, Saml2X509CredentialType.DECRYPTION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Saml2X509Credential asVerificationCredential(Verification.Credential properties) {
|
|
|
|
private Saml2X509Credential asVerificationCredential(Verification.Credential properties) {
|
|
|
|