Rename scope -> scopes for Set types

Fixes gh-4644
This commit is contained in:
Joe Grandja
2017-10-18 16:41:57 -04:00
parent b81c1ce2c0
commit 1e891b38ab
21 changed files with 79 additions and 81 deletions

View File

@@ -36,26 +36,26 @@ import java.util.Set;
*/
public class AccessToken extends SecurityToken {
private final TokenType tokenType;
private final Set<String> scope;
private final Set<String> scopes;
public AccessToken(TokenType tokenType, String tokenValue, Instant issuedAt, Instant expiresAt) {
this(tokenType, tokenValue, issuedAt, expiresAt, Collections.emptySet());
}
public AccessToken(TokenType tokenType, String tokenValue, Instant issuedAt, Instant expiresAt, Set<String> scope) {
public AccessToken(TokenType tokenType, String tokenValue, Instant issuedAt, Instant expiresAt, Set<String> scopes) {
super(tokenValue, issuedAt, expiresAt);
Assert.notNull(tokenType, "tokenType cannot be null");
this.tokenType = tokenType;
this.scope = Collections.unmodifiableSet(
scope != null ? scope : Collections.emptySet());
this.scopes = Collections.unmodifiableSet(
scopes != null ? scopes : Collections.emptySet());
}
public TokenType getTokenType() {
return this.tokenType;
}
public Set<String> getScope() {
return this.scope;
public Set<String> getScopes() {
return this.scopes;
}
public static final class TokenType {

View File

@@ -45,7 +45,7 @@ public final class AuthorizationRequest implements Serializable {
private ResponseType responseType;
private String clientId;
private String redirectUri;
private Set<String> scope;
private Set<String> scopes;
private String state;
private Map<String,Object> additionalParameters;
@@ -72,8 +72,8 @@ public final class AuthorizationRequest implements Serializable {
return this.redirectUri;
}
public Set<String> getScope() {
return this.scope;
public Set<String> getScopes() {
return this.scopes;
}
public String getState() {
@@ -98,7 +98,7 @@ public final class AuthorizationRequest implements Serializable {
private ResponseType responseType;
private String clientId;
private String redirectUri;
private Set<String> scope;
private Set<String> scopes;
private String state;
private Map<String,Object> additionalParameters;
@@ -127,8 +127,8 @@ public final class AuthorizationRequest implements Serializable {
return this;
}
public Builder scope(Set<String> scope) {
this.scope = scope;
public Builder scopes(Set<String> scopes) {
this.scopes = scopes;
return this;
}
@@ -156,9 +156,9 @@ public final class AuthorizationRequest implements Serializable {
authorizationRequest.clientId = this.clientId;
authorizationRequest.redirectUri = this.redirectUri;
authorizationRequest.state = this.state;
authorizationRequest.scope = Collections.unmodifiableSet(
CollectionUtils.isEmpty(this.scope) ?
Collections.emptySet() : new LinkedHashSet<>(this.scope));
authorizationRequest.scopes = Collections.unmodifiableSet(
CollectionUtils.isEmpty(this.scopes) ?
Collections.emptySet() : new LinkedHashSet<>(this.scopes));
authorizationRequest.additionalParameters = Collections.unmodifiableMap(
CollectionUtils.isEmpty(this.additionalParameters) ?
Collections.emptyMap() : new LinkedHashMap<>(this.additionalParameters));

View File

@@ -55,8 +55,8 @@ public final class TokenResponse {
return this.accessToken.getExpiresAt();
}
public Set<String> getScope() {
return this.accessToken.getScope();
public Set<String> getScopes() {
return this.accessToken.getScopes();
}
public Map<String, Object> getAdditionalParameters() {
@@ -71,7 +71,7 @@ public final class TokenResponse {
private String tokenValue;
private AccessToken.TokenType tokenType;
private long expiresIn;
private Set<String> scope;
private Set<String> scopes;
private Map<String,Object> additionalParameters;
private Builder(String tokenValue) {
@@ -88,8 +88,8 @@ public final class TokenResponse {
return this;
}
public Builder scope(Set<String> scope) {
this.scope = scope;
public Builder scopes(Set<String> scopes) {
this.scopes = scopes;
return this;
}
@@ -103,7 +103,7 @@ public final class TokenResponse {
Instant issuedAt = Instant.now();
TokenResponse tokenResponse = new TokenResponse();
tokenResponse.accessToken = new AccessToken(this.tokenType, this.tokenValue, issuedAt,
issuedAt.plusSeconds(this.expiresIn), this.scope);
issuedAt.plusSeconds(this.expiresIn), this.scopes);
tokenResponse.additionalParameters = Collections.unmodifiableMap(
CollectionUtils.isEmpty(this.additionalParameters) ? Collections.emptyMap() : this.additionalParameters);
return tokenResponse;

View File

@@ -41,7 +41,7 @@ public class AuthorizationRequestTest {
.authorizationUri(null)
.clientId(CLIENT_ID)
.redirectUri(REDIRECT_URI)
.scope(SCOPE)
.scopes(SCOPE)
.state(STATE)
.build();
}
@@ -51,7 +51,7 @@ public class AuthorizationRequestTest {
AuthorizationRequest.authorizationCode()
.clientId(CLIENT_ID)
.redirectUri(REDIRECT_URI)
.scope(SCOPE)
.scopes(SCOPE)
.state(STATE)
.build();
}
@@ -62,7 +62,7 @@ public class AuthorizationRequestTest {
.authorizationUri(AUTHORIZE_URI)
.clientId(null)
.redirectUri(REDIRECT_URI)
.scope(SCOPE)
.scopes(SCOPE)
.state(STATE)
.build();
}
@@ -72,7 +72,7 @@ public class AuthorizationRequestTest {
AuthorizationRequest.authorizationCode()
.authorizationUri(AUTHORIZE_URI)
.redirectUri(REDIRECT_URI)
.scope(SCOPE)
.scopes(SCOPE)
.state(STATE)
.build();
}
@@ -84,7 +84,7 @@ public class AuthorizationRequestTest {
.authorizationUri(AUTHORIZE_URI)
.clientId(CLIENT_ID)
.redirectUri(REDIRECT_URI)
.scope(SCOPE)
.scopes(SCOPE)
.state(STATE)
.build();
@@ -97,7 +97,7 @@ public class AuthorizationRequestTest {
.authorizationUri(AUTHORIZE_URI)
.clientId(CLIENT_ID)
.redirectUri(null)
.scope(SCOPE)
.scopes(SCOPE)
.state(STATE)
.build()).doesNotThrowAnyException();
}
@@ -107,7 +107,7 @@ public class AuthorizationRequestTest {
assertThatCode(() -> AuthorizationRequest.authorizationCode()
.authorizationUri(AUTHORIZE_URI)
.clientId(CLIENT_ID)
.scope(SCOPE)
.scopes(SCOPE)
.state(STATE)
.build()).doesNotThrowAnyException();
}
@@ -118,7 +118,7 @@ public class AuthorizationRequestTest {
.authorizationUri(AUTHORIZE_URI)
.clientId(CLIENT_ID)
.redirectUri(REDIRECT_URI)
.scope(null)
.scopes(null)
.state(STATE)
.build()).doesNotThrowAnyException();
}
@@ -139,7 +139,7 @@ public class AuthorizationRequestTest {
.authorizationUri(AUTHORIZE_URI)
.clientId(CLIENT_ID)
.redirectUri(REDIRECT_URI)
.scope(SCOPE)
.scopes(SCOPE)
.state(null)
.build()).doesNotThrowAnyException();
}
@@ -150,7 +150,7 @@ public class AuthorizationRequestTest {
.authorizationUri(AUTHORIZE_URI)
.clientId(CLIENT_ID)
.redirectUri(REDIRECT_URI)
.scope(SCOPE)
.scopes(SCOPE)
.build()).doesNotThrowAnyException();
}
}

View File

@@ -36,7 +36,7 @@ public class TokenResponseTest {
TokenResponse.withToken(null)
.expiresIn(EXPIRES_IN)
.additionalParameters(Collections.emptyMap())
.scope(Collections.emptySet())
.scopes(Collections.emptySet())
.tokenType(AccessToken.TokenType.BEARER)
.build();
}
@@ -46,7 +46,7 @@ public class TokenResponseTest {
TokenResponse.withToken(TOKEN)
.expiresIn(INVALID_EXPIRES_IN)
.additionalParameters(Collections.emptyMap())
.scope(Collections.emptySet())
.scopes(Collections.emptySet())
.tokenType(AccessToken.TokenType.BEARER)
.build();
}