Package org.springframework.security.core.authority

# Class AuthorityUtils

java.lang.Object
org.springframework.security.core.authority.AuthorityUtils

public final class AuthorityUtils extends Object
Utility method for manipulating `GrantedAuthority` collections etc.

Mainly intended for internal use.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final List<GrantedAuthority>`
`NO_AUTHORITIES`

## Method Summary

Modifier and Type
Method
Description
`static Set<String>`
`authorityListToSet(Collection<? extends GrantedAuthority> userAuthorities)`
Converts an array of GrantedAuthority objects to a Set.
`static List<GrantedAuthority>`
`commaSeparatedStringToAuthorityList(String authorityString)`
Creates a array of GrantedAuthority objects from a comma-separated string representation (e.g.
`static List<GrantedAuthority>`
`createAuthorityList(String... authorities)`
Converts authorities into a List of GrantedAuthority objects.
`static List<GrantedAuthority>`
`createAuthorityList(Collection<String> authorities)`
Converts authorities into a List of GrantedAuthority objects.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### NO_AUTHORITIES

public static final List<GrantedAuthority> NO_AUTHORITIES

## Method Details

### commaSeparatedStringToAuthorityList

public static List<GrantedAuthority> commaSeparatedStringToAuthorityList(String authorityString)
Creates a array of GrantedAuthority objects from a comma-separated string representation (e.g. "ROLE_A, ROLE_B, ROLE_C").

Parameters:
  `authorityString` - the comma-separated string
Returns:
  the authorities created by tokenizing the string

### authorityListToSet

public static Set<String> authorityListToSet(Collection<? extends GrantedAuthority> userAuthorities)
Converts an array of GrantedAuthority objects to a Set.

Returns:
  a Set of the Strings obtained from each call to GrantedAuthority.getAuthority()

### createAuthorityList

public static List<GrantedAuthority> createAuthorityList(String... authorities)
Converts authorities into a List of GrantedAuthority objects.

Parameters:
  `authorities` - the authorities to convert
Returns:
  a List of GrantedAuthority objects

### createAuthorityList

public static List<GrantedAuthority> createAuthorityList(Collection<String> authorities)
Converts authorities into a List of GrantedAuthority objects.

Parameters:
  `authorities` - the authorities to convert
Returns:
  a List of GrantedAuthority objects
Since:
  6.1