|
| 1 | +/* |
| 2 | + * Copyright 2002-2024 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.security.saml2.provider.service.registration; |
| 18 | + |
| 19 | +import java.util.Collection; |
| 20 | +import java.util.List; |
| 21 | +import java.util.function.Consumer; |
| 22 | + |
| 23 | +import org.springframework.security.saml2.core.Saml2X509Credential; |
| 24 | + |
| 25 | +/** |
| 26 | + * An interface representing SAML 2.0 Asserting Party metadata |
| 27 | + * |
| 28 | + * @author Josh Cummings |
| 29 | + * @since 6.4 |
| 30 | + */ |
| 31 | +public interface AssertingPartyMetadata { |
| 32 | + |
| 33 | + /** |
| 34 | + * Get the asserting party's <a href= |
| 35 | + * "https://www.oasis-open.org/committees/download.php/51890/SAML%20MD%20simplified%20overview.pdf#2.9%20EntityDescriptor">EntityID</a>. |
| 36 | + * |
| 37 | + * <p> |
| 38 | + * Equivalent to the value found in the asserting party's <EntityDescriptor |
| 39 | + * EntityID="..."/> |
| 40 | + * |
| 41 | + * <p> |
| 42 | + * This value may contain a number of placeholders, which need to be resolved before |
| 43 | + * use. They are {@code baseUrl}, {@code registrationId}, {@code baseScheme}, |
| 44 | + * {@code baseHost}, and {@code basePort}. |
| 45 | + * @return the asserting party's EntityID |
| 46 | + */ |
| 47 | + String getEntityId(); |
| 48 | + |
| 49 | + /** |
| 50 | + * Get the WantAuthnRequestsSigned setting, indicating the asserting party's |
| 51 | + * preference that relying parties should sign the AuthnRequest before sending. |
| 52 | + * @return the WantAuthnRequestsSigned value |
| 53 | + */ |
| 54 | + boolean getWantAuthnRequestsSigned(); |
| 55 | + |
| 56 | + /** |
| 57 | + * Get the list of org.opensaml.saml.ext.saml2alg.SigningMethod Algorithms for this |
| 58 | + * asserting party, in preference order. |
| 59 | + * |
| 60 | + * <p> |
| 61 | + * Equivalent to the values found in <SigningMethod Algorithm="..."/> in the |
| 62 | + * asserting party's <IDPSSODescriptor>. |
| 63 | + * @return the list of SigningMethod Algorithms |
| 64 | + * @since 5.5 |
| 65 | + */ |
| 66 | + List<String> getSigningAlgorithms(); |
| 67 | + |
| 68 | + /** |
| 69 | + * Get all verification {@link Saml2X509Credential}s associated with this asserting |
| 70 | + * party |
| 71 | + * @return all verification {@link Saml2X509Credential}s associated with this |
| 72 | + * asserting party |
| 73 | + * @since 5.4 |
| 74 | + */ |
| 75 | + Collection<Saml2X509Credential> getVerificationX509Credentials(); |
| 76 | + |
| 77 | + /** |
| 78 | + * Get all encryption {@link Saml2X509Credential}s associated with this asserting |
| 79 | + * party |
| 80 | + * @return all encryption {@link Saml2X509Credential}s associated with this asserting |
| 81 | + * party |
| 82 | + * @since 5.4 |
| 83 | + */ |
| 84 | + Collection<Saml2X509Credential> getEncryptionX509Credentials(); |
| 85 | + |
| 86 | + /** |
| 87 | + * Get the <a href= |
| 88 | + * "https://www.oasis-open.org/committees/download.php/51890/SAML%20MD%20simplified%20overview.pdf#2.5%20Endpoint">SingleSignOnService</a> |
| 89 | + * Location. |
| 90 | + * |
| 91 | + * <p> |
| 92 | + * Equivalent to the value found in <SingleSignOnService Location="..."/> in the |
| 93 | + * asserting party's <IDPSSODescriptor>. |
| 94 | + * @return the SingleSignOnService Location |
| 95 | + */ |
| 96 | + String getSingleSignOnServiceLocation(); |
| 97 | + |
| 98 | + /** |
| 99 | + * Get the <a href= |
| 100 | + * "https://www.oasis-open.org/committees/download.php/51890/SAML%20MD%20simplified%20overview.pdf#2.5%20Endpoint">SingleSignOnService</a> |
| 101 | + * Binding. |
| 102 | + * |
| 103 | + * <p> |
| 104 | + * Equivalent to the value found in <SingleSignOnService Binding="..."/> in the |
| 105 | + * asserting party's <IDPSSODescriptor>. |
| 106 | + * @return the SingleSignOnService Location |
| 107 | + */ |
| 108 | + Saml2MessageBinding getSingleSignOnServiceBinding(); |
| 109 | + |
| 110 | + /** |
| 111 | + * Get the <a href= |
| 112 | + * "https://docs.oasis-open.org/security/saml/v2.0/saml-metadata-2.0-os.pdf#page=7">SingleLogoutService |
| 113 | + * Location</a> |
| 114 | + * |
| 115 | + * <p> |
| 116 | + * Equivalent to the value found in <SingleLogoutService Location="..."/> in the |
| 117 | + * asserting party's <IDPSSODescriptor>. |
| 118 | + * @return the SingleLogoutService Location |
| 119 | + * @since 5.6 |
| 120 | + */ |
| 121 | + String getSingleLogoutServiceLocation(); |
| 122 | + |
| 123 | + /** |
| 124 | + * Get the <a href= |
| 125 | + * "https://docs.oasis-open.org/security/saml/v2.0/saml-metadata-2.0-os.pdf#page=7">SingleLogoutService |
| 126 | + * Response Location</a> |
| 127 | + * |
| 128 | + * <p> |
| 129 | + * Equivalent to the value found in <SingleLogoutService Location="..."/> in the |
| 130 | + * asserting party's <IDPSSODescriptor>. |
| 131 | + * @return the SingleLogoutService Response Location |
| 132 | + * @since 5.6 |
| 133 | + */ |
| 134 | + String getSingleLogoutServiceResponseLocation(); |
| 135 | + |
| 136 | + /** |
| 137 | + * Get the <a href= |
| 138 | + * "https://docs.oasis-open.org/security/saml/v2.0/saml-metadata-2.0-os.pdf#page=7">SingleLogoutService |
| 139 | + * Binding</a> |
| 140 | + * |
| 141 | + * <p> |
| 142 | + * Equivalent to the value found in <SingleLogoutService Binding="..."/> in the |
| 143 | + * asserting party's <IDPSSODescriptor>. |
| 144 | + * @return the SingleLogoutService Binding |
| 145 | + * @since 5.6 |
| 146 | + */ |
| 147 | + Saml2MessageBinding getSingleLogoutServiceBinding(); |
| 148 | + |
| 149 | + Builder<?> mutate(); |
| 150 | + |
| 151 | + interface Builder<B extends Builder<B>> { |
| 152 | + |
| 153 | + /** |
| 154 | + * Set the asserting party's <a href= |
| 155 | + * "https://www.oasis-open.org/committees/download.php/51890/SAML%20MD%20simplified%20overview.pdf#2.9%20EntityDescriptor">EntityID</a>. |
| 156 | + * Equivalent to the value found in the asserting party's <EntityDescriptor |
| 157 | + * EntityID="..."/> |
| 158 | + * @param entityId the asserting party's EntityID |
| 159 | + * @return the {@link B} for further configuration |
| 160 | + */ |
| 161 | + B entityId(String entityId); |
| 162 | + |
| 163 | + /** |
| 164 | + * Set the WantAuthnRequestsSigned setting, indicating the asserting party's |
| 165 | + * preference that relying parties should sign the AuthnRequest before sending. |
| 166 | + * @param wantAuthnRequestsSigned the WantAuthnRequestsSigned setting |
| 167 | + * @return the {@link B} for further configuration |
| 168 | + */ |
| 169 | + B wantAuthnRequestsSigned(boolean wantAuthnRequestsSigned); |
| 170 | + |
| 171 | + /** |
| 172 | + * Apply this {@link Consumer} to the list of SigningMethod Algorithms |
| 173 | + * @param signingMethodAlgorithmsConsumer a {@link Consumer} of the list of |
| 174 | + * SigningMethod Algorithms |
| 175 | + * @return this {@link B} for further configuration |
| 176 | + * @since 5.5 |
| 177 | + */ |
| 178 | + B signingAlgorithms(Consumer<List<String>> signingMethodAlgorithmsConsumer); |
| 179 | + |
| 180 | + /** |
| 181 | + * Apply this {@link Consumer} to the list of {@link Saml2X509Credential}s |
| 182 | + * @param credentialsConsumer a {@link Consumer} of the {@link List} of |
| 183 | + * {@link Saml2X509Credential}s |
| 184 | + * @return the {@link RelyingPartyRegistration.Builder} for further configuration |
| 185 | + * @since 5.4 |
| 186 | + */ |
| 187 | + B verificationX509Credentials(Consumer<Collection<Saml2X509Credential>> credentialsConsumer); |
| 188 | + |
| 189 | + /** |
| 190 | + * Apply this {@link Consumer} to the list of {@link Saml2X509Credential}s |
| 191 | + * @param credentialsConsumer a {@link Consumer} of the {@link List} of |
| 192 | + * {@link Saml2X509Credential}s |
| 193 | + * @return the {@link RelyingPartyRegistration.Builder} for further configuration |
| 194 | + * @since 5.4 |
| 195 | + */ |
| 196 | + B encryptionX509Credentials(Consumer<Collection<Saml2X509Credential>> credentialsConsumer); |
| 197 | + |
| 198 | + /** |
| 199 | + * Set the <a href= |
| 200 | + * "https://www.oasis-open.org/committees/download.php/51890/SAML%20MD%20simplified%20overview.pdf#2.5%20Endpoint">SingleSignOnService</a> |
| 201 | + * Location. |
| 202 | + * |
| 203 | + * <p> |
| 204 | + * Equivalent to the value found in <SingleSignOnService Location="..."/> in |
| 205 | + * the asserting party's <IDPSSODescriptor>. |
| 206 | + * @param singleSignOnServiceLocation the SingleSignOnService Location |
| 207 | + * @return the {@link B} for further configuration |
| 208 | + */ |
| 209 | + B singleSignOnServiceLocation(String singleSignOnServiceLocation); |
| 210 | + |
| 211 | + /** |
| 212 | + * Set the <a href= |
| 213 | + * "https://www.oasis-open.org/committees/download.php/51890/SAML%20MD%20simplified%20overview.pdf#2.5%20Endpoint">SingleSignOnService</a> |
| 214 | + * Binding. |
| 215 | + * |
| 216 | + * <p> |
| 217 | + * Equivalent to the value found in <SingleSignOnService Binding="..."/> in |
| 218 | + * the asserting party's <IDPSSODescriptor>. |
| 219 | + * @param singleSignOnServiceBinding the SingleSignOnService Binding |
| 220 | + * @return the {@link B} for further configuration |
| 221 | + */ |
| 222 | + B singleSignOnServiceBinding(Saml2MessageBinding singleSignOnServiceBinding); |
| 223 | + |
| 224 | + /** |
| 225 | + * Set the <a href= |
| 226 | + * "https://docs.oasis-open.org/security/saml/v2.0/saml-metadata-2.0-os.pdf#page=7">SingleLogoutService |
| 227 | + * Location</a> |
| 228 | + * |
| 229 | + * <p> |
| 230 | + * Equivalent to the value found in <SingleLogoutService Location="..."/> in |
| 231 | + * the asserting party's <IDPSSODescriptor>. |
| 232 | + * @param singleLogoutServiceLocation the SingleLogoutService Location |
| 233 | + * @return the {@link B} for further configuration |
| 234 | + * @since 5.6 |
| 235 | + */ |
| 236 | + B singleLogoutServiceLocation(String singleLogoutServiceLocation); |
| 237 | + |
| 238 | + /** |
| 239 | + * Set the <a href= |
| 240 | + * "https://docs.oasis-open.org/security/saml/v2.0/saml-metadata-2.0-os.pdf#page=7">SingleLogoutService |
| 241 | + * Response Location</a> |
| 242 | + * |
| 243 | + * <p> |
| 244 | + * Equivalent to the value found in <SingleLogoutService |
| 245 | + * ResponseLocation="..."/> in the asserting party's <IDPSSODescriptor>. |
| 246 | + * @param singleLogoutServiceResponseLocation the SingleLogoutService Response |
| 247 | + * Location |
| 248 | + * @return the {@link B} for further configuration |
| 249 | + * @since 5.6 |
| 250 | + */ |
| 251 | + B singleLogoutServiceResponseLocation(String singleLogoutServiceResponseLocation); |
| 252 | + |
| 253 | + /** |
| 254 | + * Set the <a href= |
| 255 | + * "https://docs.oasis-open.org/security/saml/v2.0/saml-metadata-2.0-os.pdf#page=7">SingleLogoutService |
| 256 | + * Binding</a> |
| 257 | + * |
| 258 | + * <p> |
| 259 | + * Equivalent to the value found in <SingleLogoutService Binding="..."/> in |
| 260 | + * the asserting party's <IDPSSODescriptor>. |
| 261 | + * @param singleLogoutServiceBinding the SingleLogoutService Binding |
| 262 | + * @return the {@link B} for further configuration |
| 263 | + * @since 5.6 |
| 264 | + */ |
| 265 | + B singleLogoutServiceBinding(Saml2MessageBinding singleLogoutServiceBinding); |
| 266 | + |
| 267 | + /** |
| 268 | + * Creates an immutable ProviderDetails object representing the configuration for |
| 269 | + * an Identity Provider, IDP |
| 270 | + * @return immutable ProviderDetails object |
| 271 | + */ |
| 272 | + AssertingPartyMetadata build(); |
| 273 | + |
| 274 | + } |
| 275 | + |
| 276 | +} |
0 commit comments