@Test public void hasRoles() { CoffeeNetUserDetails coffeeNetUserDetails = new CoffeeNetUserDetailsStub(); assertThat(coffeeNetUserDetails.hasRoles("COFFEENET-ADMIN", "COFFEENET-USER"), is(true)); }
@Override public boolean hasRoles(String... roles) { for (String role : roles) { Assert.isTrue(!role.startsWith("ROLE_"), role + " cannot start with ROLE_ (it is automatically added)"); if (!getAuthorities().contains(new SimpleGrantedAuthority("ROLE_" + role))) { return false; } } return true; }
AbstractCoffeeNetUser implements CoffeeNetUserDetails { @Override public boolean hasRoles(String... roles) { for (String role : roles) { Assert.isTrue(!role.startsWith("ROLE_"), role + " cannot start with ROLE_ (it is automatically added)"); if (!getAuthorities().contains(new SimpleGrantedAuthority("ROLE_" + role))) { return false; } } return true; } }
AbstractCoffeeNetUser implements CoffeeNetUserDetails { @Override public boolean hasRoles(String... roles) { for (String role : roles) { Assert.isTrue(!role.startsWith("ROLE_"), role + " cannot start with ROLE_ (it is automatically added)"); if (!getAuthorities().contains(new SimpleGrantedAuthority("ROLE_" + role))) { return false; } } return true; }  }
AbstractCoffeeNetUser implements CoffeeNetUserDetails { @Override public boolean hasRoles(String... roles) { for (String role : roles) { Assert.isTrue(!role.startsWith("ROLE_"), role + " cannot start with ROLE_ (it is automatically added)"); if (!getAuthorities().contains(new SimpleGrantedAuthority("ROLE_" + role))) { return false; } } return true; }  @Override boolean hasRoles(String... roles); @Override Set<String> getAuthoritiesAsString(); }
AbstractCoffeeNetUser implements CoffeeNetUserDetails { @Override public boolean hasRoles(String... roles) { for (String role : roles) { Assert.isTrue(!role.startsWith("ROLE_"), role + " cannot start with ROLE_ (it is automatically added)"); if (!getAuthorities().contains(new SimpleGrantedAuthority("ROLE_" + role))) { return false; } } return true; }  @Override boolean hasRoles(String... roles); @Override Set<String> getAuthoritiesAsString();  }