What do you want to save?
Add Code snippet
New code examples
-
Java 2022-01-30 22:15:12
update role spring security
Set<GrantedAuthority> authorities = new HashSet<>(); authorities.add(new SimpleGrantedAuthority("USER")); authorities.add(new SimpleGrantedAuthority("ADMIN")); Authentication reAuth = new UsernamePasswordAuthenticationToke... Add solution -
Java 2021-11-18 20:22:24
convert hashset to array
// First of all, you shouldn't use raw types. // Use : Set<Integer> set = new HashSet<>(); set.add(4); set.add(1); // Then convert to array : Integer[] arr = x.toArray(new Integer[set.size()]); // Using x.toArray() would give you an Object[]. Add solution -
Java 2021-10-09 08:22:14
how to set two different table admin and user for separate jwt token in spring boot
private Set getAuthority(User user) { Set authorities = new HashSet<>(); user.getRoles().forEach(role -> { authorities.add(new SimpleGrantedAuthority("ROLE_" + role.getName())); }); return authorities; } Add solution -
Java 2021-09-15 12:44:03
smallest positive integer not in array java
If the expected running time should be linear, you can't use a TreeSet, which sorts the input and therefore requires O(NlogN). Therefore you should use a HashSet, which requires O(N) time to add N elements. Besides, you don't need 4 loops. It's sufficien... Add solution -
Other 2021-09-09 09:38:02
Retrieve Keycloak user data using received access token
Requires import org.keycloak.KeycloakPrincipal; import org.keycloak.KeycloakSecurityContext; import org.keycloak.representations.AccessToken; private Set<String> selectResourceRoles(String keycloakResource,HttpServletRequest request ) { ... Add solution