|
@@ -18,6 +18,8 @@ package org.springframework.security.saml2.provider.service.registration;
|
|
|
|
|
|
import java.security.PrivateKey;
|
|
import java.security.PrivateKey;
|
|
import java.security.cert.X509Certificate;
|
|
import java.security.cert.X509Certificate;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
import java.util.Collections;
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
@@ -27,6 +29,8 @@ import java.util.Set;
|
|
import java.util.function.Consumer;
|
|
import java.util.function.Consumer;
|
|
import java.util.function.Function;
|
|
import java.util.function.Function;
|
|
|
|
|
|
|
|
+import org.opensaml.xmlsec.signature.support.SignatureConstants;
|
|
|
|
+
|
|
import org.springframework.security.saml2.core.Saml2X509Credential;
|
|
import org.springframework.security.saml2.core.Saml2X509Credential;
|
|
import org.springframework.util.Assert;
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
@@ -438,10 +442,12 @@ public final class RelyingPartyRegistration {
|
|
|
|
|
|
private final Saml2MessageBinding singleSignOnServiceBinding;
|
|
private final Saml2MessageBinding singleSignOnServiceBinding;
|
|
|
|
|
|
|
|
+ private List<String> signingMethodAlgorithms;
|
|
|
|
+
|
|
private AssertingPartyDetails(String entityId, boolean wantAuthnRequestsSigned,
|
|
private AssertingPartyDetails(String entityId, boolean wantAuthnRequestsSigned,
|
|
Collection<Saml2X509Credential> verificationX509Credentials,
|
|
Collection<Saml2X509Credential> verificationX509Credentials,
|
|
Collection<Saml2X509Credential> encryptionX509Credentials, String singleSignOnServiceLocation,
|
|
Collection<Saml2X509Credential> encryptionX509Credentials, String singleSignOnServiceLocation,
|
|
- Saml2MessageBinding singleSignOnServiceBinding) {
|
|
|
|
|
|
+ Saml2MessageBinding singleSignOnServiceBinding, List<String> signingMethodAlgorithms) {
|
|
Assert.hasText(entityId, "entityId cannot be null or empty");
|
|
Assert.hasText(entityId, "entityId cannot be null or empty");
|
|
Assert.notNull(verificationX509Credentials, "verificationX509Credentials cannot be null");
|
|
Assert.notNull(verificationX509Credentials, "verificationX509Credentials cannot be null");
|
|
for (Saml2X509Credential credential : verificationX509Credentials) {
|
|
for (Saml2X509Credential credential : verificationX509Credentials) {
|
|
@@ -457,12 +463,14 @@ public final class RelyingPartyRegistration {
|
|
}
|
|
}
|
|
Assert.notNull(singleSignOnServiceLocation, "singleSignOnServiceLocation cannot be null");
|
|
Assert.notNull(singleSignOnServiceLocation, "singleSignOnServiceLocation cannot be null");
|
|
Assert.notNull(singleSignOnServiceBinding, "singleSignOnServiceBinding cannot be null");
|
|
Assert.notNull(singleSignOnServiceBinding, "singleSignOnServiceBinding cannot be null");
|
|
|
|
+ Assert.notEmpty(signingMethodAlgorithms, "signingMethodAlgorithms cannot be empty");
|
|
this.entityId = entityId;
|
|
this.entityId = entityId;
|
|
this.wantAuthnRequestsSigned = wantAuthnRequestsSigned;
|
|
this.wantAuthnRequestsSigned = wantAuthnRequestsSigned;
|
|
this.verificationX509Credentials = verificationX509Credentials;
|
|
this.verificationX509Credentials = verificationX509Credentials;
|
|
this.encryptionX509Credentials = encryptionX509Credentials;
|
|
this.encryptionX509Credentials = encryptionX509Credentials;
|
|
this.singleSignOnServiceLocation = singleSignOnServiceLocation;
|
|
this.singleSignOnServiceLocation = singleSignOnServiceLocation;
|
|
this.singleSignOnServiceBinding = singleSignOnServiceBinding;
|
|
this.singleSignOnServiceBinding = singleSignOnServiceBinding;
|
|
|
|
+ this.signingMethodAlgorithms = signingMethodAlgorithms;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -542,6 +550,15 @@ public final class RelyingPartyRegistration {
|
|
return this.singleSignOnServiceBinding;
|
|
return this.singleSignOnServiceBinding;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Return the list of preferred signature algorithm URIs, in preference order.
|
|
|
|
+ * @return the list of signature algorithm URIs
|
|
|
|
+ * @since 5.5
|
|
|
|
+ */
|
|
|
|
+ public List<String> getSigningMethodAlgorithms() {
|
|
|
|
+ return this.signingMethodAlgorithms;
|
|
|
|
+ }
|
|
|
|
+
|
|
public static final class Builder {
|
|
public static final class Builder {
|
|
|
|
|
|
private String entityId;
|
|
private String entityId;
|
|
@@ -556,6 +573,8 @@ public final class RelyingPartyRegistration {
|
|
|
|
|
|
private Saml2MessageBinding singleSignOnServiceBinding = Saml2MessageBinding.REDIRECT;
|
|
private Saml2MessageBinding singleSignOnServiceBinding = Saml2MessageBinding.REDIRECT;
|
|
|
|
|
|
|
|
+ private List<String> signingMethodAlgorithms = new ArrayList<>();
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Set the asserting party's <a href=
|
|
* Set the asserting party's <a href=
|
|
* "https://wiki.shibboleth.net/confluence/display/CONCEPT/EntityNaming">EntityID</a>.
|
|
* "https://wiki.shibboleth.net/confluence/display/CONCEPT/EntityNaming">EntityID</a>.
|
|
@@ -639,15 +658,31 @@ public final class RelyingPartyRegistration {
|
|
return this;
|
|
return this;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Apply this {@link Consumer} to the list of signature algorithm URIs
|
|
|
|
+ * @param signingMethodAlgorithmsConsumer a {@link Consumer} of the list of
|
|
|
|
+ * signature algorithm URIs
|
|
|
|
+ * @return this {@code Builder}
|
|
|
|
+ * @since 5.5
|
|
|
|
+ */
|
|
|
|
+ public Builder signingMethodAlgorithms(Consumer<List<String>> signingMethodAlgorithmsConsumer) {
|
|
|
|
+ signingMethodAlgorithmsConsumer.accept(this.signingMethodAlgorithms);
|
|
|
|
+ return this;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Creates an immutable ProviderDetails object representing the configuration
|
|
* Creates an immutable ProviderDetails object representing the configuration
|
|
* for an Identity Provider, IDP
|
|
* for an Identity Provider, IDP
|
|
* @return immutable ProviderDetails object
|
|
* @return immutable ProviderDetails object
|
|
*/
|
|
*/
|
|
public AssertingPartyDetails build() {
|
|
public AssertingPartyDetails build() {
|
|
|
|
+ List<String> signingMethodAlgorithmsCopy = this.signingMethodAlgorithms.isEmpty()
|
|
|
|
+ ? Arrays.asList(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256)
|
|
|
|
+ : Collections.unmodifiableList(this.signingMethodAlgorithms);
|
|
|
|
+
|
|
return new AssertingPartyDetails(this.entityId, this.wantAuthnRequestsSigned,
|
|
return new AssertingPartyDetails(this.entityId, this.wantAuthnRequestsSigned,
|
|
this.verificationX509Credentials, this.encryptionX509Credentials,
|
|
this.verificationX509Credentials, this.encryptionX509Credentials,
|
|
- this.singleSignOnServiceLocation, this.singleSignOnServiceBinding);
|
|
|
|
|
|
+ this.singleSignOnServiceLocation, this.singleSignOnServiceBinding, signingMethodAlgorithmsCopy);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|