@Test public void shouldReturnAnEmtpySetOfScopesIfTheAuthenticationIsNotAnOAuth2Authentication() { when(context.getAuthentication()).thenReturn(testAuthentication); SecurityContextHolder.setContext(context); OAuth2AuthorizationContext ctx = new OAuth2AuthorizationContext(); assertThat(ctx.getScopes()).hasSize(0); }
public Set<String> getScopes() { OAuth2Authentication oauth = oauth2Authentication(); if (oauth == null) { return new HashSet<String>(); } Set<String> scope = oauth.getOAuth2Request().getScope(); return scope == null ? new HashSet<String>() : scope; }
OAuth2AuthorizationContext implements AuthorizationContextProvider { public Set<String> getScopes() { OAuth2Authentication oauth = oauth2Authentication(); if (oauth == null) { return new HashSet<String>(); } Set<String> scope = oauth.getOAuth2Request().getScope(); return scope == null ? new HashSet<String>() : scope; } }
OAuth2AuthorizationContext implements AuthorizationContextProvider { public Set<String> getScopes() { OAuth2Authentication oauth = oauth2Authentication(); if (oauth == null) { return new HashSet<String>(); } Set<String> scope = oauth.getOAuth2Request().getScope(); return scope == null ? new HashSet<String>() : scope; } OAuth2AuthorizationContext(); }
OAuth2AuthorizationContext implements AuthorizationContextProvider { public Set<String> getScopes() { OAuth2Authentication oauth = oauth2Authentication(); if (oauth == null) { return new HashSet<String>(); } Set<String> scope = oauth.getOAuth2Request().getScope(); return scope == null ? new HashSet<String>() : scope; } OAuth2AuthorizationContext(); boolean isAuthenticated(); Set<String> getScopes(); Set<String> getAuthorities(); Set<String> getRoles(); String getUsername(); }
OAuth2AuthorizationContext implements AuthorizationContextProvider { public Set<String> getScopes() { OAuth2Authentication oauth = oauth2Authentication(); if (oauth == null) { return new HashSet<String>(); } Set<String> scope = oauth.getOAuth2Request().getScope(); return scope == null ? new HashSet<String>() : scope; } OAuth2AuthorizationContext(); boolean isAuthenticated(); Set<String> getScopes(); Set<String> getAuthorities(); Set<String> getRoles(); String getUsername();  }