18
18
import org .springframework .security .core .SpringSecurityCoreVersion2 ;
19
19
import org .springframework .security .oauth2 .core .AuthorizationGrantType ;
20
20
import org .springframework .security .oauth2 .core .ClientAuthenticationMethod ;
21
+ import org .springframework .security .oauth2 .server .authorization .config .ClientSettings ;
22
+ import org .springframework .security .oauth2 .server .authorization .config .TokenSettings ;
21
23
import org .springframework .util .Assert ;
22
24
import org .springframework .util .CollectionUtils ;
23
25
@@ -46,6 +48,8 @@ public class RegisteredClient implements Serializable {
46
48
private Set <AuthorizationGrantType > authorizationGrantTypes ;
47
49
private Set <String > redirectUris ;
48
50
private Set <String > scopes ;
51
+ private ClientSettings clientSettings ;
52
+ private TokenSettings tokenSettings ;
49
53
50
54
protected RegisteredClient () {
51
55
}
@@ -114,6 +118,24 @@ public Set<String> getScopes() {
114
118
return this .scopes ;
115
119
}
116
120
121
+ /**
122
+ * Returns the {@link ClientSettings client configuration settings}.
123
+ *
124
+ * @return the {@link ClientSettings}
125
+ */
126
+ public ClientSettings getClientSettings () {
127
+ return this .clientSettings ;
128
+ }
129
+
130
+ /**
131
+ * Returns the {@link TokenSettings token configuration settings}.
132
+ *
133
+ * @return the {@link TokenSettings}
134
+ */
135
+ public TokenSettings getTokenSettings () {
136
+ return this .tokenSettings ;
137
+ }
138
+
117
139
@ Override
118
140
public String toString () {
119
141
return "RegisteredClient{" +
@@ -160,6 +182,8 @@ public static class Builder implements Serializable {
160
182
private Set <AuthorizationGrantType > authorizationGrantTypes = new LinkedHashSet <>();
161
183
private Set <String > redirectUris = new LinkedHashSet <>();
162
184
private Set <String > scopes = new LinkedHashSet <>();
185
+ private ClientSettings clientSettings ;
186
+ private TokenSettings tokenSettings ;
163
187
164
188
protected Builder (String id ) {
165
189
this .id = id ;
@@ -181,6 +205,8 @@ protected Builder(RegisteredClient registeredClient) {
181
205
if (!CollectionUtils .isEmpty (registeredClient .scopes )) {
182
206
this .scopes .addAll (registeredClient .scopes );
183
207
}
208
+ this .clientSettings = new ClientSettings (registeredClient .clientSettings .settings ());
209
+ this .tokenSettings = new TokenSettings (registeredClient .tokenSettings .settings ());
184
210
}
185
211
186
212
/**
@@ -310,6 +336,28 @@ public Builder scopes(Consumer<Set<String>> scopesConsumer) {
310
336
return this ;
311
337
}
312
338
339
+ /**
340
+ * Sets the {@link ClientSettings client configuration settings}.
341
+ *
342
+ * @param clientSettings the client configuration settings
343
+ * @return the {@link Builder}
344
+ */
345
+ public Builder clientSettings (ClientSettings clientSettings ) {
346
+ this .clientSettings = clientSettings ;
347
+ return this ;
348
+ }
349
+
350
+ /**
351
+ * Sets the {@link TokenSettings token configuration settings}.
352
+ *
353
+ * @param tokenSettings the token configuration settings
354
+ * @return the {@link Builder}
355
+ */
356
+ public Builder tokenSettings (TokenSettings tokenSettings ) {
357
+ this .tokenSettings = tokenSettings ;
358
+ return this ;
359
+ }
360
+
313
361
/**
314
362
* Builds a new {@link RegisteredClient}.
315
363
*
@@ -341,6 +389,8 @@ private RegisteredClient create() {
341
389
registeredClient .authorizationGrantTypes = Collections .unmodifiableSet (this .authorizationGrantTypes );
342
390
registeredClient .redirectUris = Collections .unmodifiableSet (this .redirectUris );
343
391
registeredClient .scopes = Collections .unmodifiableSet (this .scopes );
392
+ registeredClient .clientSettings = this .clientSettings != null ? this .clientSettings : new ClientSettings ();
393
+ registeredClient .tokenSettings = this .tokenSettings != null ? this .tokenSettings : new TokenSettings ();
344
394
345
395
return registeredClient ;
346
396
}
0 commit comments