|
@@ -16,17 +16,13 @@
|
|
|
|
|
|
package org.springframework.security.saml2.provider.service.registration;
|
|
|
|
|
|
-import java.security.PrivateKey;
|
|
|
-import java.security.cert.X509Certificate;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Collections;
|
|
|
import java.util.LinkedHashSet;
|
|
|
import java.util.LinkedList;
|
|
|
import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
import java.util.function.Consumer;
|
|
|
-import java.util.function.Function;
|
|
|
|
|
|
import org.opensaml.xmlsec.signature.support.SignatureConstants;
|
|
|
|
|
@@ -89,9 +85,7 @@ public final class RelyingPartyRegistration {
|
|
|
|
|
|
private final String nameIdFormat;
|
|
|
|
|
|
- private final ProviderDetails providerDetails;
|
|
|
-
|
|
|
- private final List<org.springframework.security.saml2.credentials.Saml2X509Credential> credentials;
|
|
|
+ private final AssertingPartyDetails assertingPartyDetails;
|
|
|
|
|
|
private final Collection<Saml2X509Credential> decryptionX509Credentials;
|
|
|
|
|
@@ -100,8 +94,7 @@ public final class RelyingPartyRegistration {
|
|
|
private RelyingPartyRegistration(String registrationId, String entityId, String assertionConsumerServiceLocation,
|
|
|
Saml2MessageBinding assertionConsumerServiceBinding, String singleLogoutServiceLocation,
|
|
|
String singleLogoutServiceResponseLocation, Saml2MessageBinding singleLogoutServiceBinding,
|
|
|
- ProviderDetails providerDetails, String nameIdFormat,
|
|
|
- Collection<org.springframework.security.saml2.credentials.Saml2X509Credential> credentials,
|
|
|
+ AssertingPartyDetails assertingPartyDetails, String nameIdFormat,
|
|
|
Collection<Saml2X509Credential> decryptionX509Credentials,
|
|
|
Collection<Saml2X509Credential> signingX509Credentials) {
|
|
|
Assert.hasText(registrationId, "registrationId cannot be empty");
|
|
@@ -110,13 +103,7 @@ public final class RelyingPartyRegistration {
|
|
|
Assert.notNull(assertionConsumerServiceBinding, "assertionConsumerServiceBinding cannot be null");
|
|
|
Assert.isTrue(singleLogoutServiceLocation == null || singleLogoutServiceBinding != null,
|
|
|
"singleLogoutServiceBinding cannot be null when singleLogoutServiceLocation is set");
|
|
|
- Assert.notNull(providerDetails, "providerDetails cannot be null");
|
|
|
- Assert.isTrue(
|
|
|
- !credentials.isEmpty() || (decryptionX509Credentials.isEmpty() && signingX509Credentials.isEmpty()),
|
|
|
- "credentials cannot be empty");
|
|
|
- for (org.springframework.security.saml2.credentials.Saml2X509Credential c : credentials) {
|
|
|
- Assert.notNull(c, "credentials cannot contain null elements");
|
|
|
- }
|
|
|
+ Assert.notNull(assertingPartyDetails, "assertingPartyDetails cannot be null");
|
|
|
Assert.notNull(decryptionX509Credentials, "decryptionX509Credentials cannot be null");
|
|
|
for (Saml2X509Credential c : decryptionX509Credentials) {
|
|
|
Assert.notNull(c, "decryptionX509Credentials cannot contain null elements");
|
|
@@ -136,8 +123,7 @@ public final class RelyingPartyRegistration {
|
|
|
this.singleLogoutServiceResponseLocation = singleLogoutServiceResponseLocation;
|
|
|
this.singleLogoutServiceBinding = singleLogoutServiceBinding;
|
|
|
this.nameIdFormat = nameIdFormat;
|
|
|
- this.providerDetails = providerDetails;
|
|
|
- this.credentials = Collections.unmodifiableList(new LinkedList<>(credentials));
|
|
|
+ this.assertingPartyDetails = assertingPartyDetails;
|
|
|
this.decryptionX509Credentials = Collections.unmodifiableList(new LinkedList<>(decryptionX509Credentials));
|
|
|
this.signingX509Credentials = Collections.unmodifiableList(new LinkedList<>(signingX509Credentials));
|
|
|
}
|
|
@@ -278,139 +264,7 @@ public final class RelyingPartyRegistration {
|
|
|
* @since 5.4
|
|
|
*/
|
|
|
public AssertingPartyDetails getAssertingPartyDetails() {
|
|
|
- return this.providerDetails.assertingPartyDetails;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Returns the entity ID of the IDP, the asserting party.
|
|
|
- * @return entity ID of the asserting party
|
|
|
- * @deprecated use {@link AssertingPartyDetails#getEntityId} from
|
|
|
- * {@link #getAssertingPartyDetails}
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public String getRemoteIdpEntityId() {
|
|
|
- return this.providerDetails.getEntityId();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * returns the URL template for which ACS URL authentication requests should contain
|
|
|
- * Possible variables are {@code baseUrl}, {@code registrationId}, {@code baseScheme},
|
|
|
- * {@code baseHost}, and {@code basePort}.
|
|
|
- * @return string containing the ACS URL template, with or without variables present
|
|
|
- * @deprecated Use {@link #getAssertionConsumerServiceLocation} instead
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public String getAssertionConsumerServiceUrlTemplate() {
|
|
|
- return this.assertionConsumerServiceLocation;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Contains the URL for which to send the SAML 2 Authentication Request to initiate a
|
|
|
- * single sign on flow.
|
|
|
- * @return a IDP URL that accepts REDIRECT or POST binding for authentication requests
|
|
|
- * @deprecated use {@link AssertingPartyDetails#getSingleSignOnServiceLocation} from
|
|
|
- * {@link #getAssertingPartyDetails}
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public String getIdpWebSsoUrl() {
|
|
|
- return this.getAssertingPartyDetails().getSingleSignOnServiceLocation();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Returns specific configuration around the Identity Provider SSO endpoint
|
|
|
- * @return the IDP SSO endpoint configuration
|
|
|
- * @since 5.3
|
|
|
- * @deprecated Use {@link #getAssertingPartyDetails} instead
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public ProviderDetails getProviderDetails() {
|
|
|
- return this.providerDetails;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * The local relying party, or Service Provider, can generate it's entity ID based on
|
|
|
- * possible variables of {@code baseUrl}, {@code registrationId}, {@code baseScheme},
|
|
|
- * {@code baseHost}, and {@code basePort}, for example
|
|
|
- * {@code {baseUrl}/saml2/service-provider-metadata/{registrationId}}
|
|
|
- * @return a string containing the entity ID or entity ID template
|
|
|
- * @deprecated Use {@link #getEntityId} instead
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public String getLocalEntityIdTemplate() {
|
|
|
- return this.entityId;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Returns a list of configured credentials to be used in message exchanges between
|
|
|
- * relying party, SP, and asserting party, IDP.
|
|
|
- * @return a list of credentials
|
|
|
- * @deprecated Instead of retrieving all credentials, use the appropriate method for
|
|
|
- * obtaining the correct type
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public List<org.springframework.security.saml2.credentials.Saml2X509Credential> getCredentials() {
|
|
|
- return this.credentials;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return a filtered list containing only credentials of type
|
|
|
- * {@link org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType#VERIFICATION}.
|
|
|
- * Returns an empty list of credentials are not found
|
|
|
- * @deprecated Use {code #getAssertingPartyDetails().getSigningX509Credentials()}
|
|
|
- * instead
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public List<org.springframework.security.saml2.credentials.Saml2X509Credential> getVerificationCredentials() {
|
|
|
- return filterCredentials(
|
|
|
- org.springframework.security.saml2.credentials.Saml2X509Credential::isSignatureVerficationCredential);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return a filtered list containing only credentials of type
|
|
|
- * {@link org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType#SIGNING}.
|
|
|
- * Returns an empty list of credentials are not found
|
|
|
- * @deprecated Use {@link #getSigningX509Credentials()} instead
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public List<org.springframework.security.saml2.credentials.Saml2X509Credential> getSigningCredentials() {
|
|
|
- return filterCredentials(
|
|
|
- org.springframework.security.saml2.credentials.Saml2X509Credential::isSigningCredential);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return a filtered list containing only credentials of type
|
|
|
- * {@link org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType#ENCRYPTION}.
|
|
|
- * Returns an empty list of credentials are not found
|
|
|
- * @deprecated Use {@link AssertingPartyDetails#getEncryptionX509Credentials()}
|
|
|
- * instead
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public List<org.springframework.security.saml2.credentials.Saml2X509Credential> getEncryptionCredentials() {
|
|
|
- return filterCredentials(
|
|
|
- org.springframework.security.saml2.credentials.Saml2X509Credential::isEncryptionCredential);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return a filtered list containing only credentials of type
|
|
|
- * {@link org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType#DECRYPTION}.
|
|
|
- * Returns an empty list of credentials are not found
|
|
|
- * @deprecated Use {@link #getDecryptionX509Credentials()} instead
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public List<org.springframework.security.saml2.credentials.Saml2X509Credential> getDecryptionCredentials() {
|
|
|
- return filterCredentials(
|
|
|
- org.springframework.security.saml2.credentials.Saml2X509Credential::isDecryptionCredential);
|
|
|
- }
|
|
|
-
|
|
|
- private List<org.springframework.security.saml2.credentials.Saml2X509Credential> filterCredentials(
|
|
|
- Function<org.springframework.security.saml2.credentials.Saml2X509Credential, Boolean> filter) {
|
|
|
- List<org.springframework.security.saml2.credentials.Saml2X509Credential> result = new LinkedList<>();
|
|
|
- for (org.springframework.security.saml2.credentials.Saml2X509Credential c : this.credentials) {
|
|
|
- if (filter.apply(c)) {
|
|
|
- result.add(c);
|
|
|
- }
|
|
|
- }
|
|
|
- return result;
|
|
|
+ return this.assertingPartyDetails;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -477,51 +331,6 @@ public final class RelyingPartyRegistration {
|
|
|
registration.getAssertingPartyDetails().getSingleLogoutServiceBinding()));
|
|
|
}
|
|
|
|
|
|
- private static Saml2X509Credential fromDeprecated(
|
|
|
- org.springframework.security.saml2.credentials.Saml2X509Credential credential) {
|
|
|
- PrivateKey privateKey = credential.getPrivateKey();
|
|
|
- X509Certificate certificate = credential.getCertificate();
|
|
|
- Set<Saml2X509Credential.Saml2X509CredentialType> credentialTypes = new LinkedHashSet<>();
|
|
|
- if (credential.isSigningCredential()) {
|
|
|
- credentialTypes.add(Saml2X509Credential.Saml2X509CredentialType.SIGNING);
|
|
|
- }
|
|
|
- if (credential.isSignatureVerficationCredential()) {
|
|
|
- credentialTypes.add(Saml2X509Credential.Saml2X509CredentialType.VERIFICATION);
|
|
|
- }
|
|
|
- if (credential.isEncryptionCredential()) {
|
|
|
- credentialTypes.add(Saml2X509Credential.Saml2X509CredentialType.ENCRYPTION);
|
|
|
- }
|
|
|
- if (credential.isDecryptionCredential()) {
|
|
|
- credentialTypes.add(Saml2X509Credential.Saml2X509CredentialType.DECRYPTION);
|
|
|
- }
|
|
|
- return new Saml2X509Credential(privateKey, certificate, credentialTypes);
|
|
|
- }
|
|
|
-
|
|
|
- private static org.springframework.security.saml2.credentials.Saml2X509Credential toDeprecated(
|
|
|
- Saml2X509Credential credential) {
|
|
|
- PrivateKey privateKey = credential.getPrivateKey();
|
|
|
- X509Certificate certificate = credential.getCertificate();
|
|
|
- Set<org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType> credentialTypes = new LinkedHashSet<>();
|
|
|
- if (credential.isSigningCredential()) {
|
|
|
- credentialTypes.add(
|
|
|
- org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType.SIGNING);
|
|
|
- }
|
|
|
- if (credential.isVerificationCredential()) {
|
|
|
- credentialTypes.add(
|
|
|
- org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType.VERIFICATION);
|
|
|
- }
|
|
|
- if (credential.isEncryptionCredential()) {
|
|
|
- credentialTypes.add(
|
|
|
- org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType.ENCRYPTION);
|
|
|
- }
|
|
|
- if (credential.isDecryptionCredential()) {
|
|
|
- credentialTypes.add(
|
|
|
- org.springframework.security.saml2.credentials.Saml2X509Credential.Saml2X509CredentialType.DECRYPTION);
|
|
|
- }
|
|
|
- return new org.springframework.security.saml2.credentials.Saml2X509Credential(privateKey, certificate,
|
|
|
- credentialTypes);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* The configuration metadata of the Asserting party
|
|
|
*
|
|
@@ -746,7 +555,7 @@ public final class RelyingPartyRegistration {
|
|
|
* Equivalent to the value found in the asserting party's <EntityDescriptor
|
|
|
* EntityID="..."/>
|
|
|
* @param entityId the asserting party's EntityID
|
|
|
- * @return the {@link ProviderDetails.Builder} for further configuration
|
|
|
+ * @return the {@link AssertingPartyDetails.Builder} for further configuration
|
|
|
*/
|
|
|
public Builder entityId(String entityId) {
|
|
|
this.entityId = entityId;
|
|
@@ -758,7 +567,7 @@ public final class RelyingPartyRegistration {
|
|
|
* preference that relying parties should sign the AuthnRequest before
|
|
|
* sending.
|
|
|
* @param wantAuthnRequestsSigned the WantAuthnRequestsSigned setting
|
|
|
- * @return the {@link ProviderDetails.Builder} for further configuration
|
|
|
+ * @return the {@link AssertingPartyDetails.Builder} for further configuration
|
|
|
*/
|
|
|
public Builder wantAuthnRequestsSigned(boolean wantAuthnRequestsSigned) {
|
|
|
this.wantAuthnRequestsSigned = wantAuthnRequestsSigned;
|
|
@@ -813,7 +622,7 @@ public final class RelyingPartyRegistration {
|
|
|
* Equivalent to the value found in <SingleSignOnService
|
|
|
* Location="..."/> in the asserting party's <IDPSSODescriptor>.
|
|
|
* @param singleSignOnServiceLocation the SingleSignOnService Location
|
|
|
- * @return the {@link ProviderDetails.Builder} for further configuration
|
|
|
+ * @return the {@link AssertingPartyDetails.Builder} for further configuration
|
|
|
*/
|
|
|
public Builder singleSignOnServiceLocation(String singleSignOnServiceLocation) {
|
|
|
this.singleSignOnServiceLocation = singleSignOnServiceLocation;
|
|
@@ -829,7 +638,7 @@ public final class RelyingPartyRegistration {
|
|
|
* Equivalent to the value found in <SingleSignOnService Binding="..."/>
|
|
|
* in the asserting party's <IDPSSODescriptor>.
|
|
|
* @param singleSignOnServiceBinding the SingleSignOnService Binding
|
|
|
- * @return the {@link ProviderDetails.Builder} for further configuration
|
|
|
+ * @return the {@link AssertingPartyDetails.Builder} for further configuration
|
|
|
*/
|
|
|
public Builder singleSignOnServiceBinding(Saml2MessageBinding singleSignOnServiceBinding) {
|
|
|
this.singleSignOnServiceBinding = singleSignOnServiceBinding;
|
|
@@ -910,126 +719,6 @@ public final class RelyingPartyRegistration {
|
|
|
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Configuration for IDP SSO endpoint configuration
|
|
|
- *
|
|
|
- * @since 5.3
|
|
|
- * @deprecated Use {@link AssertingPartyDetails} instead
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public static final class ProviderDetails {
|
|
|
-
|
|
|
- private final AssertingPartyDetails assertingPartyDetails;
|
|
|
-
|
|
|
- private ProviderDetails(AssertingPartyDetails assertingPartyDetails) {
|
|
|
- Assert.notNull("assertingPartyDetails cannot be null");
|
|
|
- this.assertingPartyDetails = assertingPartyDetails;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Returns the entity ID of the Identity Provider
|
|
|
- * @return the entity ID of the IDP
|
|
|
- */
|
|
|
- public String getEntityId() {
|
|
|
- return this.assertingPartyDetails.getEntityId();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Contains the URL for which to send the SAML 2 Authentication Request to
|
|
|
- * initiate a single sign on flow.
|
|
|
- * @return a IDP URL that accepts REDIRECT or POST binding for authentication
|
|
|
- * requests
|
|
|
- */
|
|
|
- public String getWebSsoUrl() {
|
|
|
- return this.assertingPartyDetails.getSingleSignOnServiceLocation();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return {@code true} if AuthNRequests from this relying party to the IDP should
|
|
|
- * be signed {@code false} if no signature is required.
|
|
|
- */
|
|
|
- public boolean isSignAuthNRequest() {
|
|
|
- return this.assertingPartyDetails.getWantAuthnRequestsSigned();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * @return the type of SAML 2 Binding the AuthNRequest should be sent on
|
|
|
- */
|
|
|
- public Saml2MessageBinding getBinding() {
|
|
|
- return this.assertingPartyDetails.getSingleSignOnServiceBinding();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Builder for IDP SSO endpoint configuration
|
|
|
- *
|
|
|
- * @since 5.3
|
|
|
- * @deprecated Use {@link AssertingPartyDetails.Builder} instead
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public static final class Builder {
|
|
|
-
|
|
|
- private AssertingPartyDetails.Builder assertingPartyDetailsBuilder = new AssertingPartyDetails.Builder();
|
|
|
-
|
|
|
- /**
|
|
|
- * Set the asserting party's <a href=
|
|
|
- * "https://www.oasis-open.org/committees/download.php/51890/SAML%20MD%20simplified%20overview.pdf#2.9%20EntityDescriptor">EntityID</a>.
|
|
|
- * Equivalent to the value found in the asserting party's <EntityDescriptor
|
|
|
- * EntityID="..."/>
|
|
|
- * @param entityId the asserting party's EntityID
|
|
|
- * @return the {@link Builder} for further configuration
|
|
|
- * @since 5.4
|
|
|
- */
|
|
|
- public Builder entityId(String entityId) {
|
|
|
- this.assertingPartyDetailsBuilder.entityId(entityId);
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Sets the {@code SSO URL} for the remote asserting party, the Identity
|
|
|
- * Provider.
|
|
|
- * @param url - a URL that accepts authentication requests via REDIRECT or
|
|
|
- * POST bindings
|
|
|
- * @return this object
|
|
|
- */
|
|
|
- public Builder webSsoUrl(String url) {
|
|
|
- this.assertingPartyDetailsBuilder.singleSignOnServiceLocation(url);
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Set to true if the AuthNRequest message should be signed
|
|
|
- * @param signAuthNRequest true if the message should be signed
|
|
|
- * @return this object
|
|
|
- */
|
|
|
- public Builder signAuthNRequest(boolean signAuthNRequest) {
|
|
|
- this.assertingPartyDetailsBuilder.wantAuthnRequestsSigned(signAuthNRequest);
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Sets the message binding to be used when sending an AuthNRequest message
|
|
|
- * @param binding either {@link Saml2MessageBinding#POST} or
|
|
|
- * {@link Saml2MessageBinding#REDIRECT}
|
|
|
- * @return this object
|
|
|
- */
|
|
|
- public Builder binding(Saml2MessageBinding binding) {
|
|
|
- this.assertingPartyDetailsBuilder.singleSignOnServiceBinding(binding);
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Creates an immutable ProviderDetails object representing the configuration
|
|
|
- * for an Identity Provider, IDP
|
|
|
- * @return immutable ProviderDetails object
|
|
|
- */
|
|
|
- public ProviderDetails build() {
|
|
|
- return new ProviderDetails(this.assertingPartyDetailsBuilder.build());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
public static final class Builder {
|
|
|
|
|
|
private String registrationId;
|
|
@@ -1052,9 +741,7 @@ public final class RelyingPartyRegistration {
|
|
|
|
|
|
private String nameIdFormat = null;
|
|
|
|
|
|
- private ProviderDetails.Builder providerDetails = new ProviderDetails.Builder();
|
|
|
-
|
|
|
- private Collection<org.springframework.security.saml2.credentials.Saml2X509Credential> credentials = new LinkedHashSet<>();
|
|
|
+ private AssertingPartyDetails.Builder assertingPartyDetailsBuilder = new AssertingPartyDetails.Builder();
|
|
|
|
|
|
private Builder(String registrationId) {
|
|
|
this.registrationId = registrationId;
|
|
@@ -1225,104 +912,7 @@ public final class RelyingPartyRegistration {
|
|
|
* @since 5.4
|
|
|
*/
|
|
|
public Builder assertingPartyDetails(Consumer<AssertingPartyDetails.Builder> assertingPartyDetails) {
|
|
|
- assertingPartyDetails.accept(this.providerDetails.assertingPartyDetailsBuilder);
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Modifies the collection of {@link Saml2X509Credential} objects used in
|
|
|
- * communication between IDP and SP For example: <code>
|
|
|
- * Saml2X509Credential credential = ...;
|
|
|
- * return RelyingPartyRegistration.withRegistrationId("id")
|
|
|
- * .credentials((c) -> c.add(credential))
|
|
|
- * ...
|
|
|
- * .build();
|
|
|
- * </code>
|
|
|
- * @param credentials - a consumer that can modify the collection of credentials
|
|
|
- * @return this object
|
|
|
- * @deprecated Use {@link #signingX509Credentials} or
|
|
|
- * {@link #decryptionX509Credentials} instead for relying party keys or
|
|
|
- * {@link AssertingPartyDetails.Builder#verificationX509Credentials} or
|
|
|
- * {@link AssertingPartyDetails.Builder#encryptionX509Credentials} for asserting
|
|
|
- * party keys
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public Builder credentials(
|
|
|
- Consumer<Collection<org.springframework.security.saml2.credentials.Saml2X509Credential>> credentials) {
|
|
|
- credentials.accept(this.credentials);
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * <a href=
|
|
|
- * "https://www.oasis-open.org/committees/download.php/51890/SAML%20MD%20simplified%20overview.pdf#2.3%20AttributeConsumingService">Assertion
|
|
|
- * Consumer Service</a> URL template. It can contain variables {@code baseUrl},
|
|
|
- * {@code registrationId}, {@code baseScheme}, {@code baseHost}, and
|
|
|
- * {@code basePort}.
|
|
|
- * @param assertionConsumerServiceUrlTemplate the Assertion Consumer Service URL
|
|
|
- * template (i.e. "{baseUrl}/login/saml2/sso/{registrationId}".
|
|
|
- * @return this object
|
|
|
- * @deprecated Use {@link #assertionConsumerServiceLocation} instead.
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public Builder assertionConsumerServiceUrlTemplate(String assertionConsumerServiceUrlTemplate) {
|
|
|
- this.assertionConsumerServiceLocation = assertionConsumerServiceUrlTemplate;
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Sets the {@code entityId} for the remote asserting party, the Identity
|
|
|
- * Provider.
|
|
|
- * @param entityId the IDP entityId
|
|
|
- * @return this object
|
|
|
- * @deprecated use
|
|
|
- * {@code #assertingPartyDetails(Consumer<AssertingPartyDetails.Builder >)}
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public Builder remoteIdpEntityId(String entityId) {
|
|
|
- assertingPartyDetails((idp) -> idp.entityId(entityId));
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Sets the {@code SSO URL} for the remote asserting party, the Identity Provider.
|
|
|
- * @param url - a URL that accepts authentication requests via REDIRECT or POST
|
|
|
- * bindings
|
|
|
- * @return this object
|
|
|
- * @deprecated use
|
|
|
- * {@code #assertingPartyDetails(Consumer<AssertingPartyDetails.Builder >)}
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public Builder idpWebSsoUrl(String url) {
|
|
|
- assertingPartyDetails((config) -> config.singleSignOnServiceLocation(url));
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Sets the local relying party, or Service Provider, entity Id template. can
|
|
|
- * generate it's entity ID based on possible variables of {@code baseUrl},
|
|
|
- * {@code registrationId}, {@code baseScheme}, {@code baseHost}, and
|
|
|
- * {@code basePort}, for example
|
|
|
- * {@code {baseUrl}/saml2/service-provider-metadata/{registrationId}}
|
|
|
- * @param template the entity id
|
|
|
- * @return a string containing the entity ID or entity ID template
|
|
|
- * @deprecated Use {@link #entityId} instead
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public Builder localEntityIdTemplate(String template) {
|
|
|
- this.entityId = template;
|
|
|
- return this;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * Configures the IDP SSO endpoint
|
|
|
- * @param providerDetails a consumer that configures the IDP SSO endpoint
|
|
|
- * @return this object
|
|
|
- * @deprecated Use {@link #assertingPartyDetails} instead
|
|
|
- */
|
|
|
- @Deprecated
|
|
|
- public Builder providerDetails(Consumer<ProviderDetails.Builder> providerDetails) {
|
|
|
- providerDetails.accept(this.providerDetails);
|
|
|
+ assertingPartyDetails.accept(this.assertingPartyDetailsBuilder);
|
|
|
return this;
|
|
|
}
|
|
|
|
|
@@ -1332,41 +922,13 @@ public final class RelyingPartyRegistration {
|
|
|
* @return a RelyingPartyRegistration instance
|
|
|
*/
|
|
|
public RelyingPartyRegistration build() {
|
|
|
- for (org.springframework.security.saml2.credentials.Saml2X509Credential credential : this.credentials) {
|
|
|
- Saml2X509Credential mapped = fromDeprecated(credential);
|
|
|
- if (credential.isSigningCredential()) {
|
|
|
- signingX509Credentials((c) -> c.add(mapped));
|
|
|
- }
|
|
|
- if (credential.isDecryptionCredential()) {
|
|
|
- decryptionX509Credentials((c) -> c.add(mapped));
|
|
|
- }
|
|
|
- if (credential.isSignatureVerficationCredential()) {
|
|
|
- this.providerDetails.assertingPartyDetailsBuilder.verificationX509Credentials((c) -> c.add(mapped));
|
|
|
- }
|
|
|
- if (credential.isEncryptionCredential()) {
|
|
|
- this.providerDetails.assertingPartyDetailsBuilder.encryptionX509Credentials((c) -> c.add(mapped));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for (Saml2X509Credential credential : this.signingX509Credentials) {
|
|
|
- this.credentials.add(toDeprecated(credential));
|
|
|
- }
|
|
|
- for (Saml2X509Credential credential : this.decryptionX509Credentials) {
|
|
|
- this.credentials.add(toDeprecated(credential));
|
|
|
- }
|
|
|
- for (Saml2X509Credential credential : this.providerDetails.assertingPartyDetailsBuilder.verificationX509Credentials) {
|
|
|
- this.credentials.add(toDeprecated(credential));
|
|
|
- }
|
|
|
- for (Saml2X509Credential credential : this.providerDetails.assertingPartyDetailsBuilder.encryptionX509Credentials) {
|
|
|
- this.credentials.add(toDeprecated(credential));
|
|
|
- }
|
|
|
if (this.singleLogoutServiceResponseLocation == null) {
|
|
|
this.singleLogoutServiceResponseLocation = this.singleLogoutServiceLocation;
|
|
|
}
|
|
|
return new RelyingPartyRegistration(this.registrationId, this.entityId,
|
|
|
this.assertionConsumerServiceLocation, this.assertionConsumerServiceBinding,
|
|
|
this.singleLogoutServiceLocation, this.singleLogoutServiceResponseLocation,
|
|
|
- this.singleLogoutServiceBinding, this.providerDetails.build(), this.nameIdFormat, this.credentials,
|
|
|
+ this.singleLogoutServiceBinding, this.assertingPartyDetailsBuilder.build(), this.nameIdFormat,
|
|
|
this.decryptionX509Credentials, this.signingX509Credentials);
|
|
|
}
|
|
|
|