Apply consistent naming to builder() methods

Issue gh-143 gh-81
This commit is contained in:
Joe Grandja 2020-11-30 08:15:44 -05:00
parent 4e4656f7bb
commit f97b8b2656
8 changed files with 16 additions and 16 deletions

View File

@ -62,7 +62,7 @@ public final class OidcProviderConfiguration implements OidcProviderMetadataClai
*
* @return the {@link Builder}
*/
public static Builder withClaims() {
public static Builder builder() {
return new Builder();
}

View File

@ -59,7 +59,7 @@ public final class JwtClaimsSet implements JwtClaimAccessor {
*
* @return the {@link Builder}
*/
public static Builder withClaims() {
public static Builder builder() {
return new Builder();
}

View File

@ -48,7 +48,7 @@ class OAuth2TokenIssuerUtil {
Instant issuedAt = Instant.now();
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)
.subject(subject)
.audience(Collections.singletonList(audience))

View File

@ -74,7 +74,7 @@ public class OidcProviderConfigurationEndpointFilter extends OncePerRequestFilte
return;
}
OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.withClaims()
OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
.issuer(this.providerSettings.issuer())
.authorizationEndpoint(asUrl(this.providerSettings.issuer(), this.providerSettings.authorizationEndpoint()))
.tokenEndpoint(asUrl(this.providerSettings.issuer(), this.providerSettings.tokenEndpoint()))

View File

@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
*/
public class OidcProviderConfigurationTests {
private final OidcProviderConfiguration.Builder minimalConfigurationBuilder =
OidcProviderConfiguration.withClaims()
OidcProviderConfiguration.builder()
.issuer("https://example.com/issuer1")
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
@ -45,7 +45,7 @@ public class OidcProviderConfigurationTests {
@Test
public void buildWhenAllRequiredClaimsAndAdditionalClaimsThenCreated() {
OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.withClaims()
OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
.issuer("https://example.com/issuer1")
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
@ -73,7 +73,7 @@ public class OidcProviderConfigurationTests {
@Test
public void buildWhenOnlyRequiredClaimsThenCreated() {
OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.withClaims()
OidcProviderConfiguration providerConfiguration = OidcProviderConfiguration.builder()
.issuer("https://example.com/issuer1")
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
@ -409,14 +409,14 @@ public class OidcProviderConfigurationTests {
@Test
public void claimWhenNameIsNullThenThrowIllegalArgumentException() {
assertThatThrownBy(() -> OidcProviderConfiguration.withClaims().claim(null, "value"))
assertThatThrownBy(() -> OidcProviderConfiguration.builder().claim(null, "value"))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("name cannot be empty");
}
@Test
public void claimWhenValueIsNullThenThrowIllegalArgumentException() {
assertThatThrownBy(() -> OidcProviderConfiguration.withClaims().claim("claim-name", null))
assertThatThrownBy(() -> OidcProviderConfiguration.builder().claim("claim-name", null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("value cannot be null");
}

View File

@ -145,7 +145,7 @@ public class OidcProviderConfigurationHttpMessageConverterTests {
@Test
public void writeInternalWhenProviderConfigurationThenSuccess() {
OidcProviderConfiguration providerConfiguration =
OidcProviderConfiguration.withClaims()
OidcProviderConfiguration.builder()
.issuer("https://example.com/issuer1")
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
.tokenEndpoint("https://example.com/issuer1/oauth2/token")
@ -187,7 +187,7 @@ public class OidcProviderConfigurationHttpMessageConverterTests {
this.messageConverter.setProviderConfigurationParametersConverter(failingConverter);
OidcProviderConfiguration providerConfiguration =
OidcProviderConfiguration.withClaims()
OidcProviderConfiguration.builder()
.issuer("https://example.com/issuer1")
.authorizationEndpoint("https://example.com/issuer1/oauth2/authorize")
.tokenEndpoint("https://example.com/issuer1/oauth2/token")

View File

@ -29,7 +29,7 @@ public class JwtClaimsSetTests {
@Test
public void buildWhenClaimsEmptyThenThrowIllegalArgumentException() {
assertThatThrownBy(() -> JwtClaimsSet.withClaims().build())
assertThatThrownBy(() -> JwtClaimsSet.builder().build())
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("claims cannot be empty");
}
@ -38,7 +38,7 @@ public class JwtClaimsSetTests {
public void buildWhenAllClaimsProvidedThenAllClaimsAreSet() {
JwtClaimsSet expectedJwtClaimsSet = TestJwtClaimsSets.jwtClaimsSet().build();
JwtClaimsSet jwtClaimsSet = JwtClaimsSet.withClaims()
JwtClaimsSet jwtClaimsSet = JwtClaimsSet.builder()
.issuer(expectedJwtClaimsSet.getIssuer().toExternalForm())
.subject(expectedJwtClaimsSet.getSubject())
.audience(expectedJwtClaimsSet.getAudience())
@ -76,14 +76,14 @@ public class JwtClaimsSetTests {
@Test
public void claimWhenNameNullThenThrowIllegalArgumentException() {
assertThatThrownBy(() -> JwtClaimsSet.withClaims().claim(null, "value"))
assertThatThrownBy(() -> JwtClaimsSet.builder().claim(null, "value"))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("name cannot be empty");
}
@Test
public void claimWhenValueNullThenThrowIllegalArgumentException() {
assertThatThrownBy(() -> JwtClaimsSet.withClaims().claim("name", null))
assertThatThrownBy(() -> JwtClaimsSet.builder().claim("name", null))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("value cannot be null");
}

View File

@ -30,7 +30,7 @@ public class TestJwtClaimsSets {
Instant issuedAt = Instant.now();
Instant expiresAt = issuedAt.plus(1, ChronoUnit.HOURS);
return JwtClaimsSet.withClaims()
return JwtClaimsSet.builder()
.issuer(issuer)
.subject("subject")
.audience(Collections.singletonList("client-1"))