fixed scope parsing on token implementation, too

pull/650/head
Justin Richer 2013-09-06 14:28:32 -04:00
parent c98e34fc8f
commit f56a993ca9
2 changed files with 6 additions and 5 deletions

View File

@ -33,7 +33,7 @@ public class AuthorizationRequestImpl implements AuthorizationRequest {
private JsonObject token; private JsonObject token;
private String clientId; private String clientId;
private Set<String> scopes = null; private Set<String> scopes = new HashSet<String>();
public AuthorizationRequestImpl(JsonObject token) { public AuthorizationRequestImpl(JsonObject token) {
this.token = token; this.token = token;

View File

@ -30,6 +30,8 @@ import java.util.logging.Logger;
import org.springframework.security.oauth2.common.OAuth2AccessToken; import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2RefreshToken; import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import com.google.common.base.Splitter;
import com.google.common.collect.Sets;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
@ -38,16 +40,15 @@ public class OAuth2AccessTokenImpl implements OAuth2AccessToken {
private JsonObject token; private JsonObject token;
private String tokenString; private String tokenString;
private Set<String> scopes = null; private Set<String> scopes = new HashSet<String>();
private Date expireDate; private Date expireDate;
public OAuth2AccessTokenImpl(JsonObject token, String tokenString) { public OAuth2AccessTokenImpl(JsonObject token, String tokenString) {
this.token = token; this.token = token;
this.tokenString = tokenString; this.tokenString = tokenString;
scopes = new HashSet<String>(); if (token.get("scope") != null) {
for (JsonElement e : token.get("scope").getAsJsonArray()) { scopes = Sets.newHashSet(Splitter.on(" ").split(token.get("scope").getAsString()));
scopes.add(e.getAsString());
} }
DateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); DateFormat dateFormater = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");