001/*
002 * Copyright 2026 Revetware LLC.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package com.revetsec.oidc;
018
019import com.google.errorprone.annotations.CheckReturnValue;
020
021import org.jspecify.annotations.NonNull;
022import org.jspecify.annotations.Nullable;
023import javax.annotation.concurrent.Immutable;
024import javax.annotation.concurrent.NotThreadSafe;
025import java.net.URI;
026import java.util.*;
027import static java.util.Objects.requireNonNull;
028import com.revetsec.oauth.AuthorizationServerMetadata;
029import com.revetsec.oauth.AuthorizationServerMetadataParseResult;
030import com.revetsec.oauth.OAuthException;
031import com.revetsec.internal.oauth.OidcTransactionAccess;
032import com.revetsec.internal.Limits;
033import com.revetsec.internal.encoding.StrictUtf8;
034import com.revetsec.internal.encoding.EncodingException;
035import com.revetsec.internal.json.JsonCodec;
036import com.revetsec.internal.json.JsonLimits;
037import com.revetsec.internal.json.JsonParseException;
038import com.revetsec.json.*;
039
040/**
041 * OpenID provider metadata (OpenID Connect Discovery 1.0 section 3), from discovery or explicit configuration. It is
042 * not authenticated identity. The client validates every known requestable URI against its outbound policy.
043 *
044 * @author <a href="https://www.revetkn.com">Mark Allen</a>
045 * @since 1.0.0
046 */
047@Immutable
048public final class OidcProviderMetadata {
049        private final AuthorizationServerMetadata oauth;
050        private final String advertisedIssuer;
051        private final URI jwksUri;
052        private final @Nullable URI userInfoEndpoint;
053        private final @Nullable URI endSessionEndpoint;
054        private final Set<String> subjectTypes;
055        private final Set<String> algorithms;
056        private final Set<String> responseTypes;
057        private final @Nullable Set<String> userInfoAlgorithms;
058        private OidcProviderMetadata(@NonNull Builder builder) {
059                this.oauth = builder.oauth.build(); this.advertisedIssuer = this.oauth.getIssuer(); this.jwksUri = requireNonNull(builder.jwksUri);
060                this.userInfoEndpoint = builder.userInfoEndpoint; this.endSessionEndpoint = builder.endSessionEndpoint; this.subjectTypes = builder.subjectTypes;
061                this.algorithms = builder.algorithms; this.responseTypes = builder.responseTypes;
062                this.userInfoAlgorithms = builder.userInfoAlgorithms == null ? null : Set.copyOf(builder.userInfoAlgorithms);
063        }
064        private OidcProviderMetadata(@NonNull AuthorizationServerMetadata oauth, @NonNull URI jwksUri, @Nullable URI userInfo, @Nullable URI endSession,
065                        @NonNull Set<@NonNull String> subjects, @NonNull Set<@NonNull String> algorithms, @NonNull Set<@NonNull String> responses, @Nullable Set<@NonNull String> userInfoAlgorithms, @NonNull String advertisedIssuer) {
066                this.advertisedIssuer = advertisedIssuer; this.oauth = oauth; this.jwksUri = jwksUri; this.userInfoEndpoint = userInfo; this.endSessionEndpoint = endSession;
067                this.userInfoAlgorithms = userInfoAlgorithms == null ? null : Set.copyOf(userInfoAlgorithms);
068                this.subjectTypes = Set.copyOf(subjects); this.algorithms = Set.copyOf(algorithms); this.responseTypes = Set.copyOf(responses);
069        }
070        /**
071         * Parses a strict, bounded discovery document and compares the issuer exactly. Required OIDC fields must be
072         * present; explicit configuration defaults are never applied to a remote document. Unknown members and future
073         * algorithm names do not enlarge a client's allowlist. Discovery must advertise RS256 (Discovery section 3).
074         * The client separately checks every requestable URI.
075         * @param expectedIssuer exact configured issuer
076         * @param json metadata JSON text
077         * @return checked provider metadata, not authenticated identity
078         * @since 1.0.0
079         */
080        public static @NonNull OidcProviderMetadataParseResult fromJsonResult(@NonNull String expectedIssuer, @NonNull String json) {
081                return fromJsonResult(expectedIssuer, json, OidcIssuerPolicy.exactInstance());
082        }
083        /**
084         * Parses bounded metadata using the configured issuer policy and reports document rejection as a value.
085         * @param expectedIssuer configured trust issuer
086         * @param json metadata JSON text
087         * @param issuerPolicy selected issuer policy
088         * @return the metadata parsing outcome
089         * @throws NullPointerException if an argument is null
090         * @since 1.0.0
091         */
092        @CheckReturnValue
093        public static @NonNull OidcProviderMetadataParseResult fromJsonResult(@NonNull String expectedIssuer,
094                        @NonNull String json, @NonNull OidcIssuerPolicy issuerPolicy) {
095                requireNonNull(expectedIssuer); requireNonNull(json); requireNonNull(issuerPolicy);
096                issuerPolicy.checkConfiguredIssuer(expectedIssuer);
097                try { return OidcProviderMetadataParseResult.succeeded(parse(expectedIssuer, json, issuerPolicy)); }
098                catch (OAuthException rejected) {
099                        if (rejected.getReason() != OAuthException.Reason.DOCUMENT_MALFORMED
100                                        && rejected.getReason() != OAuthException.Reason.ISSUER_MISMATCH) throw rejected;
101                        return OidcProviderMetadataParseResult.rejected(rejected.getReason());
102                }
103        }
104
105        private static @NonNull AuthorizationServerMetadata oauthMetadata(@NonNull String expectedIssuer, @NonNull String json) {
106                AuthorizationServerMetadataParseResult result = AuthorizationServerMetadata.fromJsonResult(expectedIssuer, json);
107                if (result instanceof AuthorizationServerMetadataParseResult.Succeeded success) return success.getMetadata();
108                throw OidcTransactionAccess.get().endpointFailure(((AuthorizationServerMetadataParseResult.Rejected) result).getReason());
109        }
110
111        /**
112         * Parses bounded metadata using exact issuer validation or the selected fixed Entra template.
113         * getIssuer retains configured trust; getAdvertisedIssuer retains the received issuer string.
114         * @param expectedIssuer configured trust issuer
115         * @param json metadata JSON
116         * @param issuerPolicy selected fixed issuer policy; no predicate runs during parsing
117         * @return checked metadata, not identity
118         * @throws NullPointerException if an argument is null
119         * @since 1.0.0
120         */
121        @CheckReturnValue
122        private static @NonNull OidcProviderMetadata parse(@NonNull String expectedIssuer, @NonNull String json, @NonNull OidcIssuerPolicy issuerPolicy) {
123                requireNonNull(expectedIssuer); requireNonNull(json); requireNonNull(issuerPolicy);
124                issuerPolicy.checkConfiguredIssuer(expectedIssuer);
125                @Nullable AuthorizationServerMetadata exact = issuerPolicy.isMicrosoftEntra() ? null : oauthMetadata(expectedIssuer, json);
126                byte @Nullable [] bytes = null;
127                try {
128                        bytes = StrictUtf8.encode(json);
129                        JsonValue parsed = JsonCodec.parse(bytes, JsonLimits.protocolDocument(Limits.HTTP_RESPONSE_BODY_SIZE.getDefaultIntValue()));
130                        if (!(parsed instanceof JsonObject object)) throw new IllegalArgumentException();
131                        Map<String, JsonValue> members = object.getMembers();
132                        String advertisedIssuer = requiredString(members, "issuer");
133                        AuthorizationServerMetadata oauth;
134                        if (issuerPolicy.isMicrosoftEntra()) {
135                                if (!OidcIssuerPolicy.TEMPLATE.equals(advertisedIssuer)) throw new IllegalArgumentException();
136                                JsonObject.Builder projection = JsonObject.builder();
137                                for (Map.Entry<String, JsonValue> member : members.entrySet())
138                                        if (!member.getKey().equals("issuer")) projection = projection.put(member.getKey(), member.getValue());
139                                oauth = oauthMetadata(expectedIssuer, projection.put("issuer", expectedIssuer).build().toJson());
140                        } else oauth = requireNonNull(exact);
141                        URI jwks = URI.create(requiredString(members, "jwks_uri"));
142                        URI userInfo = members.containsKey("userinfo_endpoint") ? URI.create(requiredString(members, "userinfo_endpoint")) : null;
143                        URI endSession = members.containsKey("end_session_endpoint") ? URI.create(requiredString(members, "end_session_endpoint")) : null;
144                        Set<String> subjects = requiredSet(members, "subject_types_supported");
145                        Set<String> algorithms = requiredSet(members, "id_token_signing_alg_values_supported");
146                        Set<String> responses = requiredSet(members, "response_types_supported");
147                        if (subjects.stream().anyMatch(type -> !Set.of("public", "pairwise").contains(type)) || !responses.contains("code") || !algorithms.contains("RS256"))
148                                throw new IllegalArgumentException();
149                        Set<String> userInfoAlgorithms = members.containsKey("userinfo_signing_alg_values_supported")
150                                        ? requiredSet(members, "userinfo_signing_alg_values_supported") : null;
151                        return new OidcProviderMetadata(oauth, jwks, userInfo, endSession, subjects, algorithms, responses, userInfoAlgorithms, advertisedIssuer);
152                } catch (EncodingException | JsonParseException | IllegalArgumentException invalid) {
153                        throw OidcTransactionAccess.get().endpointFailure(OAuthException.Reason.DOCUMENT_MALFORMED);
154                } finally { if (bytes != null) Arrays.fill(bytes, (byte) 0); }
155        }
156        private static @NonNull String requiredString(@NonNull Map<@NonNull String, @NonNull JsonValue> members, @NonNull String name) {
157                if (!(members.get(name) instanceof JsonString text) || text.getValue().isEmpty()) throw new IllegalArgumentException();
158                return text.getValue();
159        }
160        private static @NonNull Set<@NonNull String> requiredSet(@NonNull Map<@NonNull String, @NonNull JsonValue> members, @NonNull String name) {
161                if (!(members.get(name) instanceof JsonArray array) || array.getElements().isEmpty()) throw new IllegalArgumentException();
162                Set<String> values = new LinkedHashSet<>();
163                for (JsonValue item : array.getElements()) {
164                        if (!(item instanceof JsonString text) || text.getValue().isEmpty() || !values.add(text.getValue()))
165                                throw new IllegalArgumentException();
166                }
167                return Set.copyOf(values);
168        }
169        /**
170         * Starts explicit provider configuration for an exact issuer.
171         * @param issuer exact issuer identifier
172         * @return the builder
173         * @since 1.0.0
174         */
175        public static @NonNull Builder withIssuer(@NonNull String issuer) { return new Builder(issuer); }
176        /**
177         * Returns the optional token_endpoint_auth_signing_alg_values_supported role policy without enabling unknown names.
178         * @return names when present, retaining empty versus absent
179         * @since 1.0.0
180         */
181        public @NonNull Optional<@NonNull Set<@NonNull String>> getTokenEndpointAuthSigningAlgValuesSupported() { return this.oauth.getTokenEndpointAuthSigningAlgValuesSupported(); }
182        /**
183         * Returns the optional revocation_endpoint_auth_methods_supported role policy without enabling unknown names.
184         * @return names when present, retaining empty versus absent
185         * @since 1.0.0
186         */
187        public @NonNull Optional<@NonNull Set<@NonNull String>> getRevocationEndpointAuthMethodsSupported() { return this.oauth.getRevocationEndpointAuthMethodsSupported(); }
188        /**
189         * Returns the optional revocation_endpoint_auth_signing_alg_values_supported role policy without enabling unknown names.
190         * @return names when present, retaining empty versus absent
191         * @since 1.0.0
192         */
193        public @NonNull Optional<@NonNull Set<@NonNull String>> getRevocationEndpointAuthSigningAlgValuesSupported() { return this.oauth.getRevocationEndpointAuthSigningAlgValuesSupported(); }
194        /**
195         * Returns the optional introspection_endpoint_auth_signing_alg_values_supported role policy without enabling unknown names.
196         * @return names when present, retaining empty versus absent
197         * @since 1.0.0
198         */
199        public @NonNull Optional<@NonNull Set<@NonNull String>> getIntrospectionEndpointAuthSigningAlgValuesSupported() { return this.oauth.getIntrospectionEndpointAuthSigningAlgValuesSupported(); }
200        /**
201         * Returns the optional introspection_endpoint_auth_methods_supported role policy without enabling unknown names.
202         * @return names when present, retaining empty versus absent
203         * @since 1.0.0
204         */
205        public @NonNull Optional<@NonNull Set<@NonNull String>> getIntrospectionEndpointAuthMethodsSupported() { return this.oauth.getIntrospectionEndpointAuthMethodsSupported(); }
206        @NonNull AuthorizationServerMetadata oauthMetadata() { return this.oauth; }
207        /**
208         * Returns the exact issuer.
209         *
210         * @return exact issuer
211         * @since 1.0.0
212         */
213        public @NonNull String getIssuer() { return this.oauth.getIssuer(); }
214        /**
215         * Returns the exact issuer string advertised by parsed metadata, or the configured issuer for explicit metadata.
216         * @return advertised issuer, possibly the selected Entra template
217         * @since 1.0.0
218         */
219        public @NonNull String getAdvertisedIssuer() { return this.advertisedIssuer; }
220        /**
221         * Returns the authorization endpoint.
222         *
223         * @return authorization endpoint
224         * @since 1.0.0
225         */
226        public @NonNull URI getAuthorizationEndpoint() { return this.oauth.getAuthorizationEndpoint(); }
227        /**
228         * Returns the token endpoint.
229         *
230         * @return token endpoint
231         * @since 1.0.0
232         */
233        public @NonNull URI getTokenEndpoint() { return this.oauth.getTokenEndpoint(); }
234        /**
235         * Returns the signing-key URI.
236         *
237         * @return signing-key URI
238         * @since 1.0.0
239         */
240        public @NonNull URI getJwksUri() { return this.jwksUri; }
241        /**
242         * Returns the optional UserInfo endpoint.
243         *
244         * @return optional UserInfo endpoint
245         * @since 1.0.0
246         */
247        public @NonNull Optional<@NonNull URI> getUserInfoEndpoint() { return Optional.ofNullable(this.userInfoEndpoint); }
248        /**
249         * Returns the provider's optional RP-Initiated Logout endpoint. A client must apply its configured URI policy
250         * before handing a logout request to a browser; this metadata accessor performs no request or logout.
251         * @return the advertised or explicitly configured logout endpoint, when present
252         * @since 1.0.0
253         */
254        public @NonNull Optional<@NonNull URI> getEndSessionEndpoint() { return Optional.ofNullable(this.endSessionEndpoint); }
255
256        /**
257         * Returns the subject types.
258         *
259         * @return subject types
260         * @since 1.0.0
261         */
262        public @NonNull Set<@NonNull String> getSubjectTypesSupported() { return this.subjectTypes; }
263        /**
264         * Returns the advertised ID-token algorithm names.
265         *
266         * @return advertised ID-token algorithm names
267         * @since 1.0.0
268         */
269        public @NonNull Set<@NonNull String> getIdTokenSigningAlgValuesSupported() { return this.algorithms; }
270        /**
271         * Returns the advertised response types.
272         *
273         * @return advertised response types
274         * @since 1.0.0
275         */
276        public @NonNull Set<@NonNull String> getResponseTypesSupported() { return this.responseTypes; }
277        /**
278         * Returns advertised signed-UserInfo algorithm names, or empty when absent. The client's registered algorithm
279         * must occur in this set when the provider advertises it.
280         * @return supported algorithm names when advertised
281         * @since 1.0.0
282         */
283        public @NonNull Optional<@NonNull Set<@NonNull String>> getUserInfoSigningAlgValuesSupported() {
284                return Optional.ofNullable(this.userInfoAlgorithms);
285        }
286        /**
287         * Redacts provider configuration.
288         * @return a redacted description
289         * @since 1.0.0
290         */
291        @Override public @NonNull String toString() { return "OidcProviderMetadata{configuration=<redacted>}"; }
292        /**
293         * Mutable explicit provider configuration.
294         * @author <a href="https://www.revetkn.com">Mark Allen</a>
295         * @since 1.0.0
296         */
297        @NotThreadSafe
298        @CheckReturnValue
299        public static final class Builder {
300                private AuthorizationServerMetadata.Builder oauth;
301                private @Nullable URI jwksUri;
302                private @Nullable URI userInfoEndpoint;
303                private @Nullable URI endSessionEndpoint;
304                private Set<String> subjectTypes = Set.of("public");
305                private Set<String> algorithms = Set.of("RS256");
306                private Set<String> responseTypes = Set.of("code");
307                private @Nullable Set<String> userInfoAlgorithms;
308                /**
309                 * Replaces the complete token_endpoint_auth_signing_alg_values_supported role policy.
310                 * @param value names, or null to restore absence
311                 * @return this builder
312                 * @since 1.0.0
313                 */
314                public @NonNull Builder tokenEndpointAuthSigningAlgValuesSupported(@Nullable Set<@NonNull String> value) { this.oauth = this.oauth.tokenEndpointAuthSigningAlgValuesSupported(value); return this; }
315                /**
316                 * Replaces the complete revocation_endpoint_auth_methods_supported role policy.
317                 * @param value names, or null to restore absence
318                 * @return this builder
319                 * @since 1.0.0
320                 */
321                public @NonNull Builder revocationEndpointAuthMethodsSupported(@Nullable Set<@NonNull String> value) { this.oauth = this.oauth.revocationEndpointAuthMethodsSupported(value); return this; }
322                /**
323                 * Replaces the complete revocation_endpoint_auth_signing_alg_values_supported role policy.
324                 * @param value names, or null to restore absence
325                 * @return this builder
326                 * @since 1.0.0
327                 */
328                public @NonNull Builder revocationEndpointAuthSigningAlgValuesSupported(@Nullable Set<@NonNull String> value) { this.oauth = this.oauth.revocationEndpointAuthSigningAlgValuesSupported(value); return this; }
329                /**
330                 * Replaces the complete introspection_endpoint_auth_signing_alg_values_supported role policy.
331                 * @param value names, or null to restore absence
332                 * @return this builder
333                 * @since 1.0.0
334                 */
335                public @NonNull Builder introspectionEndpointAuthSigningAlgValuesSupported(@Nullable Set<@NonNull String> value) { this.oauth = this.oauth.introspectionEndpointAuthSigningAlgValuesSupported(value); return this; }
336                /**
337                 * Replaces the complete introspection_endpoint_auth_methods_supported role policy.
338                 * @param value names, or null to restore absence
339                 * @return this builder
340                 * @since 1.0.0
341                 */
342                public @NonNull Builder introspectionEndpointAuthMethodsSupported(@Nullable Set<@NonNull String> value) { this.oauth = this.oauth.introspectionEndpointAuthMethodsSupported(value); return this; }
343                private Builder(@NonNull String issuer) { this.oauth = AuthorizationServerMetadata.withIssuer(issuer); }
344                /**
345                 * Sets the authorizationEndpoint.
346                 *
347                 * @param value endpoint, or null to restore the unset default
348                 * @return this builder
349                 * @since 1.0.0
350                 */
351                public @NonNull Builder authorizationEndpoint(@Nullable URI value) { this.oauth = this.oauth.authorizationEndpoint(value); return this; }
352                /**
353                 * Sets the tokenEndpoint.
354                 *
355                 * @param value endpoint, or null to restore the unset default
356                 * @return this builder
357                 * @since 1.0.0
358                 */
359                public @NonNull Builder tokenEndpoint(@Nullable URI value) { this.oauth = this.oauth.tokenEndpoint(value); return this; }
360                /**
361                 * Sets the revocationEndpoint.
362                 *
363                 * @param value endpoint, or null to restore the unset default
364                 * @return this builder
365                 * @since 1.0.0
366                 */
367                public @NonNull Builder revocationEndpoint(@Nullable URI value) { this.oauth = this.oauth.revocationEndpoint(value); return this; }
368                /**
369                 * Sets the jwksUri.
370                 *
371                 * @param value endpoint, or null to restore the unset default, or null to clear
372                 * @return this builder
373                 * @since 1.0.0
374                 */
375                public @NonNull Builder jwksUri(@Nullable URI value) { this.jwksUri = value; return this; }
376                /**
377                 * Sets the userInfoEndpoint.
378                 *
379                 * @param value endpoint, or null to restore the unset default, or null to clear
380                 * @return this builder
381                 * @since 1.0.0
382                 */
383                public @NonNull Builder userInfoEndpoint(@Nullable URI value) { this.userInfoEndpoint = value; return this; }
384                /**
385                 * Sets the optional RP-Initiated Logout endpoint without making a request. Null restores absence.
386                 * @param value the explicit provider endpoint, or null to clear it
387                 * @return this builder
388                 * @since 1.0.0
389                 */
390                public @NonNull Builder endSessionEndpoint(@Nullable URI value) { this.endSessionEndpoint = value; return this; }
391
392                /**
393                 * Replaces the complete subjectTypesSupported set. Null restores the explicit configuration default.
394                 *
395                 * @param value values, or null
396                 * @return this builder
397                 * @since 1.0.0
398                 */
399                public @NonNull Builder subjectTypesSupported(@Nullable Set<@NonNull String> value) { this.subjectTypes = value == null ? Set.of("public") : Set.copyOf(value); return this; }
400                /**
401                 * Replaces the complete idTokenSigningAlgValuesSupported set. Null restores the explicit configuration default.
402                 *
403                 * @param value values, or null
404                 * @return this builder
405                 * @since 1.0.0
406                 */
407                public @NonNull Builder idTokenSigningAlgValuesSupported(@Nullable Set<@NonNull String> value) { this.algorithms = value == null ? Set.of("RS256") : Set.copyOf(value); return this; }
408                /**
409                 * Replaces the complete responseTypesSupported set. Null restores the explicit configuration default.
410                 *
411                 * @param value values, or null
412                 * @return this builder
413                 * @since 1.0.0
414                 */
415                public @NonNull Builder responseTypesSupported(@Nullable Set<@NonNull String> value) { this.responseTypes = value == null ? Set.of("code") : Set.copyOf(value); return this; }
416                /**
417                 * Replaces the complete advertised codeChallengeMethodsSupported set.
418                 *
419                 * @param value values, or null for absent
420                 * @return this builder
421                 * @since 1.0.0
422                 */
423                public @NonNull Builder codeChallengeMethodsSupported(@Nullable Set<@NonNull String> value) { this.oauth = this.oauth.codeChallengeMethodsSupported(value); return this; }
424                /**
425                 * Replaces the complete advertised tokenEndpointAuthMethodsSupported set.
426                 *
427                 * @param value values, or null for absent
428                 * @return this builder
429                 * @since 1.0.0
430                 */
431                public @NonNull Builder tokenEndpointAuthMethodsSupported(@Nullable Set<@NonNull String> value) { this.oauth = this.oauth.tokenEndpointAuthMethodsSupported(value); return this; }
432                /**
433                 * Replaces advertised signed-UserInfo algorithms. Null denotes absent advertisement.
434                 * @param value complete supported set, or null
435                 * @return this builder
436                 * @since 1.0.0
437                 */
438                public @NonNull Builder userInfoSigningAlgValuesSupported(@Nullable Set<@NonNull String> value) {
439                        if (value != null && (value.isEmpty() || value.contains("")))
440                                throw new IllegalArgumentException("UserInfo algorithm capabilities must not be empty.");
441                        this.userInfoAlgorithms = value == null ? null : Set.copyOf(value); return this;
442                }
443                /**
444                 * Sets RFC 9207 callback issuer support.
445                 *
446                 * @param value whether advertised, or null to restore false
447                 * @return this builder
448                 * @since 1.0.0
449                 */
450                public @NonNull Builder authorizationResponseIssuerSupported(@Nullable Boolean value) { this.oauth = this.oauth.authorizationResponseIssuerSupported(Boolean.TRUE.equals(value)); return this; }
451                /**
452                 * Builds explicit provider metadata without I/O.
453                 *
454                 * @return the metadata
455                 * @since 1.0.0
456                 */
457                public @NonNull OidcProviderMetadata build() {
458                        if (this.jwksUri == null)
459                                throw new IllegalStateException("An OIDC provider requires a JWKS URI.");
460                        if (this.subjectTypes.isEmpty() || this.algorithms.isEmpty()
461                                        || this.responseTypes.isEmpty() || this.algorithms.contains("") || this.responseTypes.contains("")
462                                        || this.subjectTypes.stream().anyMatch(type -> !Set.of("public", "pairwise").contains(type)))
463                                throw new IllegalArgumentException("The OIDC provider metadata is incomplete or invalid.");
464                        return new OidcProviderMetadata(this);
465                }
466        }
467}