public final class

SimpleAuthorityMapper

extends Object
implements InitializingBean GrantedAuthoritiesMapper
java.lang.Object
   ↳ org.springframework.security.core.authority.mapping.SimpleAuthorityMapper

Class Overview

Simple one-to-one GrantedAuthoritiesMapper which allows for case conversion of the authority name and the addition of a string prefix (which defaults to ROLE_).

Summary

Public Constructors
SimpleAuthorityMapper()
Public Methods
void afterPropertiesSet()
Set<GrantedAuthority> mapAuthorities(Collection<? extends GrantedAuthority> authorities)
Creates a mapping of the supplied authorities based on the case-conversion and prefix settings.
void setConvertToLowerCase(boolean convertToLowerCase)
Whether to convert the authority value to lower case in the mapping.
void setConvertToUpperCase(boolean convertToUpperCase)
Whether to convert the authority value to upper case in the mapping.
void setDefaultAuthority(String authority)
Sets a default authority to be assigned to all users
void setPrefix(String prefix)
Sets the prefix which should be added to the authority name (if it doesn't already exist)
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.springframework.beans.factory.InitializingBean
From interface org.springframework.security.core.authority.mapping.GrantedAuthoritiesMapper

Public Constructors

public SimpleAuthorityMapper ()

Public Methods

public void afterPropertiesSet ()

Throws
Exception

public Set<GrantedAuthority> mapAuthorities (Collection<? extends GrantedAuthority> authorities)

Creates a mapping of the supplied authorities based on the case-conversion and prefix settings. The mapping will be one-to-one unless duplicates are produced during the conversion. If a default authority has been set, this will also be assigned to each mapping.

Parameters
authorities the original authorities
Returns
  • the converted set of authorities

public void setConvertToLowerCase (boolean convertToLowerCase)

Whether to convert the authority value to lower case in the mapping.

Parameters
convertToLowerCase defaults to false

public void setConvertToUpperCase (boolean convertToUpperCase)

Whether to convert the authority value to upper case in the mapping.

Parameters
convertToUpperCase defaults to false

public void setDefaultAuthority (String authority)

Sets a default authority to be assigned to all users

Parameters
authority the name of the authority to be assigned to all users.

public void setPrefix (String prefix)

Sets the prefix which should be added to the authority name (if it doesn't already exist)

Parameters
prefix the prefix, typically to satisfy the behaviour of an AccessDecisionVoter.