1
1
/*
2
- * Copyright (c) 2019-2023, FusionAuth, All Rights Reserved
2
+ * Copyright (c) 2019-2024, FusionAuth, All Rights Reserved
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
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing,
11
+ * software distributed under the License is distributed on an
12
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13
+ * either express or implied. See the License for the specific
14
+ * language governing permissions and limitations under the License.
3
15
*/
4
16
package io .fusionauth .domain ;
5
17
@@ -82,6 +94,10 @@ public class Application implements Buildable<Application>, Tenantable {
82
94
83
95
public SAMLv2Configuration samlv2Configuration = new SAMLv2Configuration ();
84
96
97
+ // Do not include the application Id for individual scopes when returning as part of the full application
98
+ @ JsonIgnoreProperties ("applicationId" )
99
+ public List <ApplicationOAuthScope > scopes = new ArrayList <>();
100
+
85
101
public ObjectState state ;
86
102
87
103
public UUID tenantId ;
@@ -127,6 +143,7 @@ public Application(Application other) {
127
143
this .registrationDeletePolicy = new ApplicationRegistrationDeletePolicy (other .registrationDeletePolicy );
128
144
this .roles .addAll (other .roles .stream ().map (ApplicationRole ::new ).collect (Collectors .toList ()));
129
145
this .samlv2Configuration = new SAMLv2Configuration (other .samlv2Configuration );
146
+ this .scopes .addAll (other .scopes .stream ().map (ApplicationOAuthScope ::new ).collect (Collectors .toList ()));
130
147
this .state = other .state ;
131
148
this .tenantId = other .tenantId ;
132
149
this .themeId = other .themeId ;
@@ -192,6 +209,7 @@ public boolean equals(Object o) {
192
209
Objects .equals (registrationDeletePolicy , that .registrationDeletePolicy ) &&
193
210
Objects .equals (roles , that .roles ) &&
194
211
Objects .equals (samlv2Configuration , that .samlv2Configuration ) &&
212
+ Objects .equals (scopes , that .scopes ) &&
195
213
state == that .state &&
196
214
Objects .equals (tenantId , that .tenantId ) &&
197
215
Objects .equals (themeId , that .themeId ) &&
@@ -210,6 +228,12 @@ public void setActive(boolean active) {
210
228
state = active ? ObjectState .Active : ObjectState .Inactive ;
211
229
}
212
230
231
+ public ApplicationOAuthScope getOAuthScope (String name ) {
232
+ return scopes .stream ()
233
+ .filter (s -> s .name .equals (name ))
234
+ .findFirst ().orElse (null );
235
+ }
236
+
213
237
public ApplicationRole getRole (String name ) {
214
238
for (ApplicationRole role : roles ) {
215
239
if (role .name .equals (name )) {
@@ -232,7 +256,7 @@ public boolean hasDefaultRole() {
232
256
@ Override
233
257
public int hashCode () {
234
258
// active is omitted
235
- return Objects .hash (accessControlConfiguration , authenticationTokenConfiguration , cleanSpeakConfiguration , data , emailConfiguration , externalIdentifierConfiguration , formConfiguration , id , insertInstant , jwtConfiguration , lambdaConfiguration , lastUpdateInstant , loginConfiguration , multiFactorConfiguration , name , oauthConfiguration , passwordlessConfiguration , registrationConfiguration , registrationDeletePolicy , roles , samlv2Configuration , state , tenantId , themeId , unverified , verificationEmailTemplateId , verificationStrategy , verifyRegistration , webAuthnConfiguration );
259
+ return Objects .hash (accessControlConfiguration , authenticationTokenConfiguration , cleanSpeakConfiguration , data , emailConfiguration , externalIdentifierConfiguration , formConfiguration , id , insertInstant , jwtConfiguration , lambdaConfiguration , lastUpdateInstant , loginConfiguration , multiFactorConfiguration , name , oauthConfiguration , passwordlessConfiguration , registrationConfiguration , registrationDeletePolicy , roles , samlv2Configuration , scopes , state , tenantId , themeId , unverified , verificationEmailTemplateId , verificationStrategy , verifyRegistration , webAuthnConfiguration );
236
260
}
237
261
238
262
public void normalize () {
@@ -251,6 +275,8 @@ public void normalize() {
251
275
252
276
roles .forEach (ApplicationRole ::normalize );
253
277
278
+ scopes .forEach (ApplicationOAuthScope ::normalize );
279
+
254
280
if (multiFactorConfiguration .loginPolicy == null ) {
255
281
multiFactorConfiguration .trustPolicy = null ;
256
282
}
@@ -264,6 +290,11 @@ public Application secure() {
264
290
return this ;
265
291
}
266
292
293
+ public Application sortOAuthScopes () {
294
+ scopes .sort (ApplicationOAuthScope ::compareTo );
295
+ return this ;
296
+ }
297
+
267
298
public Application sortRoles () {
268
299
roles .sort (ApplicationRole ::compareTo );
269
300
return this ;
@@ -419,6 +450,8 @@ public static class LambdaConfiguration {
419
450
420
451
public UUID selfServiceRegistrationValidationId ;
421
452
453
+ public UUID userinfoPopulateId ;
454
+
422
455
@ JacksonConstructor
423
456
public LambdaConfiguration () {
424
457
}
@@ -428,6 +461,7 @@ public LambdaConfiguration(LambdaConfiguration other) {
428
461
this .idTokenPopulateId = other .idTokenPopulateId ;
429
462
this .samlv2PopulateId = other .samlv2PopulateId ;
430
463
this .selfServiceRegistrationValidationId = other .selfServiceRegistrationValidationId ;
464
+ this .userinfoPopulateId = other .userinfoPopulateId ;
431
465
}
432
466
433
467
@ Override
@@ -442,12 +476,13 @@ public boolean equals(Object o) {
442
476
return Objects .equals (accessTokenPopulateId , that .accessTokenPopulateId ) &&
443
477
Objects .equals (idTokenPopulateId , that .idTokenPopulateId ) &&
444
478
Objects .equals (samlv2PopulateId , that .samlv2PopulateId ) &&
445
- Objects .equals (selfServiceRegistrationValidationId , that .selfServiceRegistrationValidationId );
479
+ Objects .equals (selfServiceRegistrationValidationId , that .selfServiceRegistrationValidationId ) &&
480
+ Objects .equals (userinfoPopulateId , that .userinfoPopulateId );
446
481
}
447
482
448
483
@ Override
449
484
public int hashCode () {
450
- return Objects .hash (accessTokenPopulateId , idTokenPopulateId , samlv2PopulateId , selfServiceRegistrationValidationId );
485
+ return Objects .hash (accessTokenPopulateId , idTokenPopulateId , samlv2PopulateId , selfServiceRegistrationValidationId , userinfoPopulateId );
451
486
}
452
487
453
488
@ Override
0 commit comments