001/*-
002 * #%L
003 * Smile CDR - CDR
004 * %%
005 * Copyright (C) 2016 - 2025 Smile CDR, Inc.
006 * %%
007 * All rights reserved.
008 * #L%
009 */
010package ca.cdr.api.model.json.oauth;
011
012import ca.cdr.api.model.json.IModelJson;
013import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
014import com.fasterxml.jackson.annotation.JsonAnySetter;
015import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
016import com.fasterxml.jackson.annotation.JsonProperty;
017import com.fasterxml.jackson.core.JsonProcessingException;
018import com.fasterxml.jackson.databind.ObjectMapper;
019import io.swagger.v3.oas.annotations.media.Schema;
020
021import java.lang.reflect.Field;
022import java.util.ArrayList;
023import java.util.HashMap;
024import java.util.List;
025import java.util.Map;
026
027/**
028 * @deprecated Use ca.cdr.api.model.json.oauth.OpenIdWellKnownOpenIdConfigurationResponseJson
029 */
030@JsonIgnoreProperties(ignoreUnknown = true)
031@Schema(
032                name = "OpenIdWellKnownOpenIdConfigurationResponse",
033                description = "This object represents the response from an Identity Provider's .well-known endpoint.")
034public class OpenIdWellKnownOpenIdConfigurationResponseJson implements IModelJson {
035
036        /* CHECKSTYLE.OFF: RegexpSingleLine - these json property names are spec compliant and should not be changed */
037
038        /**
039         * Authorization server's issuer identifier url
040         */
041        @JsonProperty(value = "issuer", required = true)
042        private String myIssuer;
043
044        /**
045         * URL of the authorization server's authorization endpoint
046         * REQUIRED unless no grant types are supported that use authorization endpoint
047         */
048        @JsonProperty("authorization_endpoint")
049        private String myAuthorizationEndpoint;
050
051        /**
052         * URL of the auth server's token endpoint
053         * REQUIRED unless only the implicit grant type is supported
054         */
055        @JsonProperty("token_endpoint")
056        private String myTokenEndpoint;
057
058        /**
059         * JSON array of subject identifier types that this OP supports
060         * (pairwise, public)
061         */
062        @JsonProperty(value = "subject_types_supported", required = true)
063        private List<String> mySubjectTypesSupported;
064
065        /**
066         * URL of the auth server's JWK Set document
067         */
068        @JsonProperty(value = "jwks_uri", required = false)
069        private String myJwkUri;
070
071        /**
072         * URL of the auth server's OAuth 2.0 Dynamic Client Registration Endpoint
073         */
074        @JsonProperty(value = "registration_endpoint", required = false)
075        private String myDynamicClientRegistrationEndpoint;
076
077        /**
078         * JSON array containing a list of the OAuth 2.0 "scopes" values that this auth
079         * server supports.
080         * RECOMMENDED
081         */
082        @JsonProperty("scopes_supported")
083        private List<String> mySupportedScopes;
084
085        /**
086         * JSON array containing a list of the oauth 2.0 "response_type" values
087         * that this auth server supports.
088         */
089        @JsonProperty(value = "response_types_supported", required = true)
090        private List<String> mySupportedResponseTypes;
091
092        /**
093         * JSON array containing a list of the oauth 2.0 "response_mode" values that this
094         * auth server supports
095         */
096        @JsonProperty(value = "response_modes_supported", required = false)
097        private List<String> mySupportedResponseModes;
098
099        /**
100         * JSON array containing a list of the oauth
101         * 2.0 grant type values that this auth server supports
102         */
103        @JsonProperty(value = "grant_types_supported", required = false)
104        private List<String> mySupportedGrantTypes;
105
106        /**
107         * JSON array containing a list of the client authentication methods supported by this token
108         * endpoint
109         */
110        @JsonProperty(value = "token_endpoint_auth_methods_supported", required = false)
111        private List<String> mySupportedAuthenticationMethods;
112
113        /**
114         * JSON array of list of the JWS Signing algorithms supported by
115         * the token endpoint for the signature on the JWT used
116         * to authenticate the client at the token endpoint
117         */
118        @JsonProperty(value = "token_endpoint_auth_signing_alg_values_supported", required = false)
119        private List<String> mySupportedJWSSigningAlgorithms;
120
121        /**
122         * URL of the auth server's oauth 2.0
123         * revocation endpoint
124         */
125        @JsonProperty(value = "revocation_endpoint", required = false)
126        private String myRevocationEndpoint;
127
128        /**
129         * JSON array of client auth methods supported by this
130         * revocation endpoint.
131         */
132        @JsonProperty(value = "revocation_endpoint_auth_methods_supported", required = false)
133        private List<String> mySupportedAuthMethodsForRevocation;
134
135        /**
136         * JSON array of the JWS signing algorithms supported by the
137         * revocation endpoint for the signature on the JWT used to authenticate the client.
138         */
139        @JsonProperty(value = "revocation_endpoint_auth_signing_alg_values_supported", required = false)
140        private List<String> myRevocationEndpointSigningAlgorithms;
141
142        /**
143         * URL of the auth server's oauth2.0 introspection endpoint
144         */
145        @JsonProperty(value = "introspection_endpoint", required = false)
146        private String myIntrospectionEndpoint;
147
148        /**
149         * JSON array of the client auth methods supported by this introspection
150         * endpoint.
151         */
152        @JsonProperty(value = "introspection_endpoint_auth_methods_supported", required = false)
153        private List<String> mySupportedIntrospectionEndpointAuthMethods;
154
155        /**
156         * User info url.
157         * RECOMMENDED
158         */
159        @JsonProperty("userinfo_endpoint")
160        private String myUserInfoEndpoint;
161
162        /**
163         * JSON array of signing algs supported for id token
164         */
165        @JsonProperty(value = "id_token_signing_alg_values_supported", required = true)
166        private List<String> mySupportedIdTokenSigningAlgs;
167
168        /**
169         * JSON array containing a list of proof key for code exchange (PCKE flow) code
170         * challenge methods supported by this auth server
171         */
172        @JsonProperty(value = "code_challenge_methods_supported", required = false)
173        private List<String> myCodeChallengeMethodsSupported;
174
175        /* CHECKSTYLE.ON: RegexpSingleLine */
176
177        /**
178         * We will store all unknown properties in a map during deserialization;
179         * if these properties are not in fact "unknown" but part of the spec,
180         * please add them above, but leave this map.
181         */
182        private final Map<String, Object> myUnknownProperties = new HashMap<>();
183
184        public String getIssuer() {
185                return myIssuer;
186        }
187
188        public void setIssuer(String theIssuer) {
189                myIssuer = theIssuer;
190        }
191
192        public String getAuthorizationEndpoint() {
193                return myAuthorizationEndpoint;
194        }
195
196        public void setAuthorizationEndpoint(String theAuthorizationEndpoint) {
197                myAuthorizationEndpoint = theAuthorizationEndpoint;
198        }
199
200        public String getTokenEndpoint() {
201                return myTokenEndpoint;
202        }
203
204        public void setTokenEndpoint(String theTokenEndpoint) {
205                myTokenEndpoint = theTokenEndpoint;
206        }
207
208        public String getJwkUri() {
209                return myJwkUri;
210        }
211
212        public void setJwkUri(String theJwkUri) {
213                myJwkUri = theJwkUri;
214        }
215
216        public String getDynamicClientRegistrationEndpoint() {
217                return myDynamicClientRegistrationEndpoint;
218        }
219
220        public void setDynamicClientRegistrationEndpoint(String theDynamicClientRegistrationEndpoint) {
221                myDynamicClientRegistrationEndpoint = theDynamicClientRegistrationEndpoint;
222        }
223
224        public List<String> getSupportedScopes() {
225                if (mySupportedScopes == null) {
226                        mySupportedScopes = new ArrayList<>();
227                }
228                return mySupportedScopes;
229        }
230
231        public void setSupportedScopes(List<String> theSupportedScopes) {
232                mySupportedScopes = theSupportedScopes;
233        }
234
235        public void addSupportedScope(String theScope) {
236                getSupportedScopes().add(theScope);
237        }
238
239        public List<String> getSupportedResponseTypes() {
240                if (mySupportedResponseTypes == null) {
241                        mySupportedResponseTypes = new ArrayList<>();
242                }
243                return mySupportedResponseTypes;
244        }
245
246        public void setSupportedResponseTypes(List<String> theSupportedResponseTypes) {
247                mySupportedResponseTypes = theSupportedResponseTypes;
248        }
249
250        public void addSupportedResponseType(String theResponseType) {
251                getSupportedResponseTypes().add(theResponseType);
252        }
253
254        public List<String> getSupportedResponseModes() {
255                if (mySupportedResponseModes == null) {
256                        mySupportedResponseModes = new ArrayList<>();
257                }
258                return mySupportedResponseModes;
259        }
260
261        public void setSupportedResponseModes(List<String> theSupportedResponseModes) {
262                mySupportedResponseModes = theSupportedResponseModes;
263        }
264
265        public void addSupportedResponseMode(String theMode) {
266                getSupportedResponseModes().add(theMode);
267        }
268
269        public List<String> getSupportedGrantTypes() {
270                if (mySupportedGrantTypes == null) {
271                        mySupportedGrantTypes = new ArrayList<>();
272                }
273                return mySupportedGrantTypes;
274        }
275
276        public void setSupportedGrantTypes(List<String> theSupportedGrantTypes) {
277                mySupportedGrantTypes = theSupportedGrantTypes;
278        }
279
280        public void addSupportedGrantType(String theGrantType) {
281                getSupportedGrantTypes().add(theGrantType);
282        }
283
284        public List<String> getSupportedAuthenticationMethods() {
285                if (mySupportedAuthenticationMethods == null) {
286                        mySupportedAuthenticationMethods = new ArrayList<>();
287                }
288                return mySupportedAuthenticationMethods;
289        }
290
291        public void setSupportedAuthenticationMethods(List<String> theSupportedAuthenticationMethods) {
292                mySupportedAuthenticationMethods = theSupportedAuthenticationMethods;
293        }
294
295        public void addSupportedAuthenticationMethod(String theMethod) {
296                getSupportedAuthenticationMethods().add(theMethod);
297        }
298
299        public List<String> getSupportedJWSSigningAlgorithms() {
300                if (mySupportedJWSSigningAlgorithms == null) {
301                        mySupportedJWSSigningAlgorithms = new ArrayList<>();
302                }
303                return mySupportedJWSSigningAlgorithms;
304        }
305
306        public void setSupportedJWSSigningAlgorithms(List<String> theSupportedJWSSigningAlgorithms) {
307                mySupportedJWSSigningAlgorithms = theSupportedJWSSigningAlgorithms;
308        }
309
310        public void addSupportedJWSSigningAlgorithm(String theAlg) {
311                getSupportedJWSSigningAlgorithms().add(theAlg);
312        }
313
314        public String getRevocationEndpoint() {
315                return myRevocationEndpoint;
316        }
317
318        public void setRevocationEndpoint(String theRevocationEndpoint) {
319                myRevocationEndpoint = theRevocationEndpoint;
320        }
321
322        public List<String> getSupportedAuthMethodsForRevocation() {
323                if (mySupportedAuthMethodsForRevocation == null) {
324                        mySupportedAuthMethodsForRevocation = new ArrayList<>();
325                }
326                return mySupportedAuthMethodsForRevocation;
327        }
328
329        public void setSupportedAuthMethodsForRevocation(List<String> theSupportedAuthMethodsForRevocation) {
330                mySupportedAuthMethodsForRevocation = theSupportedAuthMethodsForRevocation;
331        }
332
333        public void addSupportedAuthMethodForRevocation(String theMethod) {
334                getSupportedAuthenticationMethods().add(theMethod);
335        }
336
337        public List<String> getRevocationEndpointSigningAlgorithms() {
338                if (myRevocationEndpointSigningAlgorithms == null) {
339                        myRevocationEndpointSigningAlgorithms = new ArrayList<>();
340                }
341                return myRevocationEndpointSigningAlgorithms;
342        }
343
344        public void setRevocationEndpointSigningAlgorithms(List<String> theRevocationEndpointSigningAlgorithms) {
345                myRevocationEndpointSigningAlgorithms = theRevocationEndpointSigningAlgorithms;
346        }
347
348        public void addRevocationEndpointSigningAlgorithm(String theAlg) {
349                getRevocationEndpointSigningAlgorithms().add(theAlg);
350        }
351
352        public String getIntrospectionEndpoint() {
353                return myIntrospectionEndpoint;
354        }
355
356        public void setIntrospectionEndpoint(String theIntrospectionEndpoint) {
357                myIntrospectionEndpoint = theIntrospectionEndpoint;
358        }
359
360        public List<String> getSupportedIntrospectionEndpointAuthMethods() {
361                if (mySupportedIntrospectionEndpointAuthMethods == null) {
362                        mySupportedIntrospectionEndpointAuthMethods = new ArrayList<>();
363                }
364                return mySupportedIntrospectionEndpointAuthMethods;
365        }
366
367        public void setSupportedIntrospectionEndpointAuthMethods(
368                        List<String> theSupportedIntrospectionEndpointAuthMethods) {
369                mySupportedIntrospectionEndpointAuthMethods = theSupportedIntrospectionEndpointAuthMethods;
370        }
371
372        public void addSupportedIntrospectionEndpointAuthMethod(String theMethod) {
373                getSupportedIntrospectionEndpointAuthMethods().add(theMethod);
374        }
375
376        public String getUserInfoEndpoint() {
377                return myUserInfoEndpoint;
378        }
379
380        public void setUserInfoEndpoint(String theUserInfoEndpoint) {
381                myUserInfoEndpoint = theUserInfoEndpoint;
382        }
383
384        public List<String> getSupportedIdTokenSigningAlgs() {
385                if (mySupportedIdTokenSigningAlgs == null) {
386                        mySupportedIdTokenSigningAlgs = new ArrayList<>();
387                }
388                return mySupportedIdTokenSigningAlgs;
389        }
390
391        public void setSupportedIdTokenSigningAlgs(List<String> theSupportedIdTokenSigningAlgs) {
392                mySupportedIdTokenSigningAlgs = theSupportedIdTokenSigningAlgs;
393        }
394
395        public void addSupportedIdTokenSigningAlg(String theAlg) {
396                getSupportedIdTokenSigningAlgs().add(theAlg);
397        }
398
399        public List<String> getCodeChallengeMethodsSupported() {
400                if (myCodeChallengeMethodsSupported == null) {
401                        myCodeChallengeMethodsSupported = new ArrayList<>();
402                }
403                return myCodeChallengeMethodsSupported;
404        }
405
406        public void setCodeChallengeMethodsSupported(List<String> theCodeChallengeMethodsSupported) {
407                myCodeChallengeMethodsSupported = theCodeChallengeMethodsSupported;
408        }
409
410        public void addCodeChallengeMethodSupported(String theCode) {
411                getCodeChallengeMethodsSupported().add(theCode);
412        }
413
414        public List<String> getSubjectTypesSupported() {
415                if (mySubjectTypesSupported == null) {
416                        mySubjectTypesSupported = new ArrayList<>();
417                }
418                return mySubjectTypesSupported;
419        }
420
421        public void setSubjectTypesSupported(List<String> theSubjectTypesSupported) {
422                mySubjectTypesSupported = theSubjectTypesSupported;
423        }
424
425        public void addSubjectTypeSupported(String theType) {
426                getSubjectTypesSupported().add(theType);
427        }
428
429        @JsonAnySetter
430        public void add(String theProp, Object theVal) {
431                myUnknownProperties.put(theProp, theVal);
432        }
433
434        Map<String, Object> getUnknownProperties() {
435                return myUnknownProperties;
436        }
437
438        Map<String, Object> toMap() {
439                Map<String, Object> map = new HashMap<>();
440                Field[] fields = OpenIdWellKnownOpenIdConfigurationResponseJson.class.getDeclaredFields();
441
442                try {
443                        for (Field field : fields) {
444                                if (field.isAnnotationPresent(JsonProperty.class)) {
445                                        Object value = field.get(this);
446                                        if (value != null) {
447                                                // we want the names to be whatever's in the json annotation
448                                                JsonProperty jsonProperty = field.getAnnotation(JsonProperty.class);
449                                                String name = jsonProperty.value();
450                                                map.put(name, value);
451                                        }
452                                }
453                        }
454                } catch (IllegalAccessException ex) {
455                        throw new InternalErrorException(ex);
456                }
457
458                map.putAll(myUnknownProperties);
459
460                return map;
461        }
462
463        @Override
464        public String toString() {
465                ObjectMapper mapper = new ObjectMapper();
466                Map<String, Object> map = toMap();
467
468                try {
469                        return mapper.writeValueAsString(map);
470                } catch (JsonProcessingException ex) {
471                        throw new InternalErrorException(ex);
472                }
473        }
474}
475
476@Deprecated(since = "2025.11.R01", forRemoval = true)
477class OpenIdWellKnownOpenIdConfigurationResponse extends OpenIdWellKnownOpenIdConfigurationResponseJson {}