Apply consistent naming to builder() methods
Issue gh-143 gh-81
This commit is contained in:
parent
4e4656f7bb
commit
f97b8b2656
@ -62,7 +62,7 @@ public final class OidcProviderConfiguration implements OidcProviderMetadataClai
|
|||||||
*
|
*
|
||||||
* @return the {@link Builder}
|
* @return the {@link Builder}
|
||||||
*/
|
*/
|
||||||
public static Builder withClaims() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public final class JwtClaimsSet implements JwtClaimAccessor {
|
|||||||
*
|
*
|
||||||
* @return the {@link Builder}
|
* @return the {@link Builder}
|
||||||
*/
|
*/
|
||||||
public static Builder withClaims() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ class OAuth2TokenIssuerUtil {
|
|||||||
Instant issuedAt = Instant.now();
|
Instant issuedAt = Instant.now();
|
||||||
Instant expiresAt = issuedAt.plus(1, ChronoUnit.HOURS); // TODO Allow configuration for access token time-to-live
|
Instant expiresAt = issuedAt.plus(1, ChronoUnit.HOURS); // TODO Allow configuration for access token time-to-live
|
||||||
|
|
||||||
JwtClaimsSet jwtClaimsSet = JwtClaimsSet.withClaims()
|
JwtClaimsSet jwtClaimsSet = JwtClaimsSet.builder()
|
||||||
.issuer(issuer)
|
.issuer(issuer)
|
||||||
.subject(subject)
|
.subject(subject)
|
||||||
.audience(Collections.singletonList(audience))
|
.audience(Collections.singletonList(audience))
|
||||||
|
@ -74,7 +74,7 @@ public class OidcProviderConfigurationEndpointFilter extends OncePerRequestFilte
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.withClaims()
|
OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
|
||||||
.issuer(this.providerSettings.issuer())
|
.issuer(this.providerSettings.issuer())
|
||||||
.authorizationEndpoint(asUrl(this.providerSettings.issuer(), this.providerSettings.authorizationEndpoint()))
|
.authorizationEndpoint(asUrl(this.providerSettings.issuer(), this.providerSettings.authorizationEndpoint()))
|
||||||
.tokenEndpoint(asUrl(this.providerSettings.issuer(), this.providerSettings.tokenEndpoint()))
|
.tokenEndpoint(asUrl(this.providerSettings.issuer(), this.providerSettings.tokenEndpoint()))
|
||||||
|
@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|||||||
*/
|
*/
|
||||||
public class OidcProviderConfigurationTests {
|
public class OidcProviderConfigurationTests {
|
||||||
private final OidcProviderConfiguration.Builder minimalConfigurationBuilder =
|
private final OidcProviderConfiguration.Builder minimalConfigurationBuilder =
|
||||||
OidcProviderConfiguration.withClaims()
|
OidcProviderConfiguration.builder()
|
||||||
.issuer("https://example.com/issuer1")
|
.issuer("https://example.com/issuer1")
|
||||||
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
|
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
|
||||||
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
|
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
|
||||||
@ -45,7 +45,7 @@ public class OidcProviderConfigurationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void buildWhenAllRequiredClaimsAndAdditionalClaimsThenCreated() {
|
public void buildWhenAllRequiredClaimsAndAdditionalClaimsThenCreated() {
|
||||||
OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.withClaims()
|
OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
|
||||||
.issuer("https://example.com/issuer1")
|
.issuer("https://example.com/issuer1")
|
||||||
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
|
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
|
||||||
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
|
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
|
||||||
@ -73,7 +73,7 @@ public class OidcProviderConfigurationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void buildWhenOnlyRequiredClaimsThenCreated() {
|
public void buildWhenOnlyRequiredClaimsThenCreated() {
|
||||||
OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.withClaims()
|
OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
|
||||||
.issuer("https://example.com/issuer1")
|
.issuer("https://example.com/issuer1")
|
||||||
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
|
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
|
||||||
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
|
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
|
||||||
@ -409,14 +409,14 @@ public class OidcProviderConfigurationTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void claimWhenNameIsNullThenThrowIllegalArgumentException() {
|
public void claimWhenNameIsNullThenThrowIllegalArgumentException() {
|
||||||
assertThatThrownBy(() -> OidcProviderConfiguration.withClaims().claim(null, "value"))
|
assertThatThrownBy(() -> OidcProviderConfiguration.builder().claim(null, "value"))
|
||||||
.isInstanceOf(IllegalArgumentException.class)
|
.isInstanceOf(IllegalArgumentException.class)
|
||||||
.hasMessage("name cannot be empty");
|
.hasMessage("name cannot be empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void claimWhenValueIsNullThenThrowIllegalArgumentException() {
|
public void claimWhenValueIsNullThenThrowIllegalArgumentException() {
|
||||||
assertThatThrownBy(() -> OidcProviderConfiguration.withClaims().claim("claim-name", null))
|
assertThatThrownBy(() -> OidcProviderConfiguration.builder().claim("claim-name", null))
|
||||||
.isInstanceOf(IllegalArgumentException.class)
|
.isInstanceOf(IllegalArgumentException.class)
|
||||||
.hasMessage("value cannot be null");
|
.hasMessage("value cannot be null");
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ public class OidcProviderConfigurationHttpMessageConverterTests {
|
|||||||
@Test
|
@Test
|
||||||
public void writeInternalWhenProviderConfigurationThenSuccess() {
|
public void writeInternalWhenProviderConfigurationThenSuccess() {
|
||||||
OidcProviderConfiguration providerConfiguration =
|
OidcProviderConfiguration providerConfiguration =
|
||||||
OidcProviderConfiguration.withClaims()
|
OidcProviderConfiguration.builder()
|
||||||
.issuer("https://example.com/issuer1")
|
.issuer("https://example.com/issuer1")
|
||||||
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
|
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
|
||||||
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
|
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
|
||||||
@ -187,7 +187,7 @@ public class OidcProviderConfigurationHttpMessageConverterTests {
|
|||||||
this.messageConverter.setProviderConfigurationParametersConverter(failingConverter);
|
this.messageConverter.setProviderConfigurationParametersConverter(failingConverter);
|
||||||
|
|
||||||
OidcProviderConfiguration providerConfiguration =
|
OidcProviderConfiguration providerConfiguration =
|
||||||
OidcProviderConfiguration.withClaims()
|
OidcProviderConfiguration.builder()
|
||||||
.issuer("https://example.com/issuer1")
|
.issuer("https://example.com/issuer1")
|
||||||
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
|
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
|
||||||
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
|
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
|
||||||
|
@ -29,7 +29,7 @@ public class JwtClaimsSetTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void buildWhenClaimsEmptyThenThrowIllegalArgumentException() {
|
public void buildWhenClaimsEmptyThenThrowIllegalArgumentException() {
|
||||||
assertThatThrownBy(() -> JwtClaimsSet.withClaims().build())
|
assertThatThrownBy(() -> JwtClaimsSet.builder().build())
|
||||||
.isInstanceOf(IllegalArgumentException.class)
|
.isInstanceOf(IllegalArgumentException.class)
|
||||||
.hasMessage("claims cannot be empty");
|
.hasMessage("claims cannot be empty");
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ public class JwtClaimsSetTests {
|
|||||||
public void buildWhenAllClaimsProvidedThenAllClaimsAreSet() {
|
public void buildWhenAllClaimsProvidedThenAllClaimsAreSet() {
|
||||||
JwtClaimsSet expectedJwtClaimsSet = TestJwtClaimsSets.jwtClaimsSet().build();
|
JwtClaimsSet expectedJwtClaimsSet = TestJwtClaimsSets.jwtClaimsSet().build();
|
||||||
|
|
||||||
JwtClaimsSet jwtClaimsSet = JwtClaimsSet.withClaims()
|
JwtClaimsSet jwtClaimsSet = JwtClaimsSet.builder()
|
||||||
.issuer(expectedJwtClaimsSet.getIssuer().toExternalForm())
|
.issuer(expectedJwtClaimsSet.getIssuer().toExternalForm())
|
||||||
.subject(expectedJwtClaimsSet.getSubject())
|
.subject(expectedJwtClaimsSet.getSubject())
|
||||||
.audience(expectedJwtClaimsSet.getAudience())
|
.audience(expectedJwtClaimsSet.getAudience())
|
||||||
@ -76,14 +76,14 @@ public class JwtClaimsSetTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void claimWhenNameNullThenThrowIllegalArgumentException() {
|
public void claimWhenNameNullThenThrowIllegalArgumentException() {
|
||||||
assertThatThrownBy(() -> JwtClaimsSet.withClaims().claim(null, "value"))
|
assertThatThrownBy(() -> JwtClaimsSet.builder().claim(null, "value"))
|
||||||
.isInstanceOf(IllegalArgumentException.class)
|
.isInstanceOf(IllegalArgumentException.class)
|
||||||
.hasMessage("name cannot be empty");
|
.hasMessage("name cannot be empty");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void claimWhenValueNullThenThrowIllegalArgumentException() {
|
public void claimWhenValueNullThenThrowIllegalArgumentException() {
|
||||||
assertThatThrownBy(() -> JwtClaimsSet.withClaims().claim("name", null))
|
assertThatThrownBy(() -> JwtClaimsSet.builder().claim("name", null))
|
||||||
.isInstanceOf(IllegalArgumentException.class)
|
.isInstanceOf(IllegalArgumentException.class)
|
||||||
.hasMessage("value cannot be null");
|
.hasMessage("value cannot be null");
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ public class TestJwtClaimsSets {
|
|||||||
Instant issuedAt = Instant.now();
|
Instant issuedAt = Instant.now();
|
||||||
Instant expiresAt = issuedAt.plus(1, ChronoUnit.HOURS);
|
Instant expiresAt = issuedAt.plus(1, ChronoUnit.HOURS);
|
||||||
|
|
||||||
return JwtClaimsSet.withClaims()
|
return JwtClaimsSet.builder()
|
||||||
.issuer(issuer)
|
.issuer(issuer)
|
||||||
.subject("subject")
|
.subject("subject")
|
||||||
.audience(Collections.singletonList("client-1"))
|
.audience(Collections.singletonList("client-1"))
|
||||||
|
Loading…
Reference in New Issue
Block a user