UserDetails userDetails = (UserDetails) authentication.getPrincipal(); System.out.println("User has authorities: " + userDetails.getAuthorities());