@Test public void shouldGetEmptyAuthoritiesOnEmptyScopeClaim() throws Exception { String token = JWT.create() .withClaim("scope", " ") .sign(hmacAlgorithm); AuthenticationJsonWebToken auth = new AuthenticationJsonWebToken(token, verifier); assertThat(auth, is(notNullValue())); assertThat(auth.getAuthorities(), is(notNullValue())); assertThat(auth.getAuthorities(), is(IsEmptyCollection.empty())); }
@Override public Collection<? extends GrantedAuthority> getAuthorities() { List<SimpleGrantedAuthority> scopes = getScopeAuthorities(); List<SimpleGrantedAuthority> permissions = getPermissionAuthorities(); List<GrantedAuthority> authorities = new ArrayList<>(); authorities.addAll(scopes); authorities.addAll(permissions); return authorities; }
AuthenticationJsonWebToken implements Authentication, JwtAuthentication { @Override public Collection<? extends GrantedAuthority> getAuthorities() { List<SimpleGrantedAuthority> scopes = getScopeAuthorities(); List<SimpleGrantedAuthority> permissions = getPermissionAuthorities(); List<GrantedAuthority> authorities = new ArrayList<>(); authorities.addAll(scopes); authorities.addAll(permissions); return authorities; } }
AuthenticationJsonWebToken implements Authentication, JwtAuthentication { @Override public Collection<? extends GrantedAuthority> getAuthorities() { List<SimpleGrantedAuthority> scopes = getScopeAuthorities(); List<SimpleGrantedAuthority> permissions = getPermissionAuthorities(); List<GrantedAuthority> authorities = new ArrayList<>(); authorities.addAll(scopes); authorities.addAll(permissions); return authorities; } AuthenticationJsonWebToken(String token, JWTVerifier verifier); }
AuthenticationJsonWebToken implements Authentication, JwtAuthentication { @Override public Collection<? extends GrantedAuthority> getAuthorities() { List<SimpleGrantedAuthority> scopes = getScopeAuthorities(); List<SimpleGrantedAuthority> permissions = getPermissionAuthorities(); List<GrantedAuthority> authorities = new ArrayList<>(); authorities.addAll(scopes); authorities.addAll(permissions); return authorities; } AuthenticationJsonWebToken(String token, JWTVerifier verifier); @Override String getToken(); @Override String getKeyId(); @Override Authentication verify(JWTVerifier verifier); @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override Object getCredentials(); @Override Object getDetails(); @Override Object getPrincipal(); @Override boolean isAuthenticated(); @Override void setAuthenticated(boolean isAuthenticated); @Override String getName(); }
AuthenticationJsonWebToken implements Authentication, JwtAuthentication { @Override public Collection<? extends GrantedAuthority> getAuthorities() { List<SimpleGrantedAuthority> scopes = getScopeAuthorities(); List<SimpleGrantedAuthority> permissions = getPermissionAuthorities(); List<GrantedAuthority> authorities = new ArrayList<>(); authorities.addAll(scopes); authorities.addAll(permissions); return authorities; } AuthenticationJsonWebToken(String token, JWTVerifier verifier); @Override String getToken(); @Override String getKeyId(); @Override Authentication verify(JWTVerifier verifier); @Override Collection<? extends GrantedAuthority> getAuthorities(); @Override Object getCredentials(); @Override Object getDetails(); @Override Object getPrincipal(); @Override boolean isAuthenticated(); @Override void setAuthenticated(boolean isAuthenticated); @Override String getName();  }