From ff0009daed223db90cb38b44056d99c5d2d7cf92 Mon Sep 17 00:00:00 2001 From: Joe Grandja Date: Mon, 23 Oct 2017 11:20:15 -0400 Subject: [PATCH] Add AuthorizationRequest.Builder.scope(String...) Fixes gh-4643 --- .../oauth2/core/endpoint/AuthorizationRequest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/AuthorizationRequest.java b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/AuthorizationRequest.java index 9d6c1c18ec..30f1ea47c0 100644 --- a/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/AuthorizationRequest.java +++ b/oauth2/oauth2-core/src/main/java/org/springframework/security/oauth2/core/endpoint/AuthorizationRequest.java @@ -21,11 +21,13 @@ import org.springframework.util.Assert; import org.springframework.util.CollectionUtils; import java.io.Serializable; +import java.util.Arrays; import java.util.Collections; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; /** * A representation of an OAuth 2.0 Authorization Request @@ -127,6 +129,14 @@ public final class AuthorizationRequest implements Serializable { return this; } + public Builder scope(String... scope) { + if (scope != null && scope.length > 0) { + return this.scopes(Arrays.stream(scope).collect( + Collectors.toCollection(LinkedHashSet::new))); + } + return this; + } + public Builder scopes(Set scopes) { this.scopes = scopes; return this;