Skip to content

Commit b96e3d2

Browse files
committed
Polish gh-2134
Issue gh-2111 Closes gh-2134
1 parent a94096b commit b96e3d2

File tree

2 files changed

+17
-21
lines changed

2 files changed

+17
-21
lines changed

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/oidc/converter/RegisteredClientOidcClientRegistrationConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2023 the original author or authors.
2+
* Copyright 2020-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/config/annotation/web/configurers/OidcClientRegistrationTests.java

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2024 the original author or authors.
2+
* Copyright 2020-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -510,10 +510,7 @@ public void requestWhenClientRegistersWithCustomMetadataThenSavedToRegisteredCli
510510
assertThat(registeredClient.getClientSettings().<String>getSetting("non-registered-custom-metadata")).isNull();
511511
}
512512

513-
/**
514-
* Scenario to validate that if there's a customization that sets client secret expiration date, then the date
515-
* is persisted and returned in the registration response
516-
*/
513+
// gh-2111
517514
@Test
518515
public void requestWhenClientRegistersWithSecretExpirationThenClientRegistrationResponse() throws Exception {
519516
this.spring.register(ClientSecretExpirationConfiguration.class).autowire();
@@ -535,19 +532,16 @@ public void requestWhenClientRegistersWithSecretExpirationThenClientRegistration
535532
TemporalUnitWithinOffset allowedDelta = new TemporalUnitWithinOffset(1, ChronoUnit.MINUTES);
536533

537534
// Returned response contains expiration date
538-
assertThat(clientRegistrationResponse.getClientSecretExpiresAt())
539-
.isNotNull()
540-
.isCloseTo(expectedSecretExpiryDate, allowedDelta);
535+
assertThat(clientRegistrationResponse.getClientSecretExpiresAt()).isNotNull()
536+
.isCloseTo(expectedSecretExpiryDate, allowedDelta);
541537

542538
RegisteredClient registeredClient = this.registeredClientRepository
543-
.findByClientId(clientRegistrationResponse.getClientId());
539+
.findByClientId(clientRegistrationResponse.getClientId());
544540

545541
// Persisted RegisteredClient contains expiration date
546-
assertThat(registeredClient)
547-
.isNotNull();
548-
assertThat(registeredClient.getClientSecretExpiresAt())
549-
.isNotNull()
550-
.isCloseTo(expectedSecretExpiryDate, allowedDelta);
542+
assertThat(registeredClient).isNotNull();
543+
assertThat(registeredClient.getClientSecretExpiresAt()).isNotNull()
544+
.isCloseTo(expectedSecretExpiryDate, allowedDelta);
551545
}
552546

553547
private OidcClientRegistration registerClient(OidcClientRegistration clientRegistration) throws Exception {
@@ -899,24 +893,26 @@ public OidcClientRegistration convert(RegisteredClient registeredClient) {
899893
}
900894

901895
/**
902-
* This customization adds client secret expiration time by setting {@code RegisteredClient.clientSecretExpiresAt}
903-
* during {@code OidcClientRegistration} -> {@code RegisteredClient} conversion
896+
* This customization adds client secret expiration time by setting
897+
* {@code RegisteredClient.clientSecretExpiresAt} during
898+
* {@code OidcClientRegistration} -> {@code RegisteredClient} conversion
904899
*/
905900
private static final class ClientSecretExpirationRegisteredClientConverter
906901
implements Converter<OidcClientRegistration, RegisteredClient> {
907902

908-
private static final OidcClientRegistrationRegisteredClientConverter delegate =
909-
new OidcClientRegistrationRegisteredClientConverter();
903+
private static final OidcClientRegistrationRegisteredClientConverter delegate = new OidcClientRegistrationRegisteredClientConverter();
910904

911905
@Override
912906
public RegisteredClient convert(OidcClientRegistration clientRegistration) {
913907
RegisteredClient registeredClient = delegate.convert(clientRegistration);
914-
var registeredClientBuilder = RegisteredClient.from(registeredClient);
908+
RegisteredClient.Builder registeredClientBuilder = RegisteredClient.from(registeredClient);
915909

916-
var clientSecretExpiresAt = Instant.now().plus(Duration.ofHours(24));
910+
Instant clientSecretExpiresAt = Instant.now().plus(Duration.ofHours(24));
917911
registeredClientBuilder.clientSecretExpiresAt(clientSecretExpiresAt);
918912

919913
return registeredClientBuilder.build();
920914
}
915+
921916
}
917+
922918
}

0 commit comments

Comments
 (0)