@ Override public boolean isUserInRole ( String role ) { boolean inRole = false ; Authentication authentication = getAuthentication ( ) ; if ( authentication != null ) { Collection < ? extends GrantedAuthority > authorities = authentication . getAuthorities ( ) ; for ( GrantedAuthority authority : authorities ) { if ( role . equals ( authority . getAuthority ( ) ) ) { inRole = true ; break ; } } } return inRole ; }
Determine if the currently authenticated user has the role provided . Note that role comparisons are case sensitive .