Spring Security Framework

org.springframework.security.util
Class AuthorityUtils

java.lang.Object
  extended by org.springframework.security.util.AuthorityUtils

public abstract class AuthorityUtils
extends Object

Version:
$Id$
Author:
Luke Taylor

Field Summary
static GrantedAuthority[] NO_AUTHORITIES
           
 
Constructor Summary
AuthorityUtils()
           
 
Method Summary
static Set authorityArrayToSet(GrantedAuthority[] authorities)
          Converts an array of GrantedAuthority objects to a Set.
static GrantedAuthority[] commaSeparatedStringToAuthorityArray(String authorityString)
          Creates a array of GrantedAuthority objects from a comma-separated string representation (e.g.
static GrantedAuthority[] stringArrayToAuthorityArray(String[] roles)
           
static boolean userHasAuthority(String authority)
          Returns true if the current user has the specified authority.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_AUTHORITIES

public static final GrantedAuthority[] NO_AUTHORITIES
Constructor Detail

AuthorityUtils

public AuthorityUtils()
Method Detail

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)

Spring Security Framework

Copyright © 2004-2010 SpringSource, Inc. All Rights Reserved.