Class SimpleGrantedAuthority
java.lang.Object
org.springframework.security.core.authority.SimpleGrantedAuthority
- All Implemented Interfaces:
Serializable,GrantedAuthority
Basic concrete implementation of a
GrantedAuthority.
Stores a String representation of an authority granted to the
Authentication object.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleGrantedAuthority(String authority) Constructs aSimpleGrantedAuthorityusing the provided authority. -
Method Summary
Modifier and TypeMethodDescriptionbooleanIf theGrantedAuthoritycan be represented as aStringand thatStringis sufficient in precision to be relied upon for an access control decision by anAuthorizationManager(or delegate), this method should return such aString.inthashCode()toString()
-
Constructor Details
-
SimpleGrantedAuthority
Constructs aSimpleGrantedAuthorityusing the provided authority.- Parameters:
authority- The provided authority, including any prefix; for example,ROLE_ADMIN
-
-
Method Details
-
getAuthority
Description copied from interface:GrantedAuthorityIf theGrantedAuthoritycan be represented as aStringand thatStringis sufficient in precision to be relied upon for an access control decision by anAuthorizationManager(or delegate), this method should return such aString.If the
GrantedAuthoritycannot be expressed with sufficient precision as aString,nullshould be returned. Returningnullwill require anAccessDecisionManager(or delegate) to specifically support theGrantedAuthorityimplementation, so returningnullshould be avoided unless actually required.- Specified by:
getAuthorityin interfaceGrantedAuthority- Returns:
- a representation of the granted authority (or
nullif the granted authority cannot be expressed as aStringwith sufficient precision).
-
equals
-
hashCode
public int hashCode() -
toString
-