org.springframework.security.util
Class AuthorityUtils
java.lang.Object
org.springframework.security.util.AuthorityUtils
public abstract class AuthorityUtils
- extends Object
- Version:
- $Id$
- Author:
- Luke Taylor
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NO_AUTHORITIES
public static final GrantedAuthority[] NO_AUTHORITIES
AuthorityUtils
public AuthorityUtils()
userHasAuthority
public static boolean userHasAuthority(String authority)
- Returns true if the current user has the specified authority.
- Parameters:
authority
- the authority to test for (e.g. "ROLE_A").
- Returns:
- true if a GrantedAuthority object with the same string representation as the supplied authority
name exists in the current user's list of authorities. False otherwise, or if the user in not authenticated.
commaSeparatedStringToAuthorityArray
public static GrantedAuthority[] commaSeparatedStringToAuthorityArray(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
authorityArrayToSet
public static Set authorityArrayToSet(GrantedAuthority[] authorities)
- Converts an array of GrantedAuthority objects to a Set.
- Returns:
- a Set of the Strings obtained from each call to GrantedAuthority.getAuthority()
stringArrayToAuthorityArray
public static GrantedAuthority[] stringArrayToAuthorityArray(String[] roles)
Copyright © 2004-2010 SpringSource, Inc. All Rights Reserved.