public Set < GrantedAuthority > convertGroupsToGrantedAuthorities ( final List < UserGroup > groups ) { // Map the authority information to one or more GrantedAuthority's and add it to mappedAuthorities final Set < GrantedAuthority > mappedAuthorities = groups . stream ( ) . filter ( this :: isValidUserGroupToGrantAuthority ) . map ( userGroup -> new SimpleGrantedAuthority ( DEFAULT_ROLE_PREFIX + userGroup . getDisplayName ( ) ) ) . collect ( Collectors . toCollection ( LinkedHashSet :: new ) ) ; if ( mappedAuthorities . isEmpty ( ) ) { mappedAuthorities . add ( DEFAULT_AUTHORITY ) ; } return mappedAuthorities ; }
Converts UserGroup list to Set of GrantedAutorities