public class SimpleAccountRealm extends AuthorizingRealm
Realm
interface that
uses a set of configured user accounts and roles to support authentication and authorization. Each account entry
specifies the username, password, and roles for a user. Roles can also be mapped
to permissions and associated with users.
User accounts and roles are stored in two Map
s in memory, so it is expected that the total number of either
is not sufficiently large.Modifier and Type | Field and Description |
---|---|
protected Map<String,SimpleRole> |
roles |
protected ReadWriteLock |
ROLES_LOCK |
protected Map<String,SimpleAccount> |
users |
protected ReadWriteLock |
USERS_LOCK |
Constructor and Description |
---|
SimpleAccountRealm() |
SimpleAccountRealm(String name) |
Modifier and Type | Method and Description |
---|---|
boolean |
accountExists(String username) |
protected void |
add(SimpleAccount account) |
protected void |
add(SimpleRole role) |
void |
addAccount(String username,
String password) |
void |
addAccount(String username,
String password,
String... roles) |
void |
addRole(String name) |
protected AuthenticationInfo |
doGetAuthenticationInfo(AuthenticationToken token)
Retrieves authentication data from an implementation-specific datasource (RDBMS, LDAP, etc) for the given
authentication token.
|
protected AuthorizationInfo |
doGetAuthorizationInfo(PrincipalCollection principals)
Retrieves the AuthorizationInfo for the given principals from the underlying data store.
|
protected SimpleRole |
getRole(String rolename) |
protected SimpleAccount |
getUser(String username) |
protected String |
getUsername(PrincipalCollection principals) |
protected String |
getUsername(SimpleAccount account) |
boolean |
roleExists(String name) |
protected static Set<String> |
toSet(String delimited,
String delimiter) |
afterCacheManagerSet, checkPermission, checkPermission, checkPermission, checkPermissions, checkPermissions, checkPermissions, checkRole, checkRole, checkRoles, checkRoles, checkRoles, clearCachedAuthorizationInfo, doClearCache, getAuthorizationCache, getAuthorizationCacheKey, getAuthorizationCacheName, getAuthorizationInfo, getPermissionResolver, getPermissions, getRolePermissionResolver, hasAllRoles, hasRole, hasRole, hasRoles, hasRoles, isAuthorizationCachingEnabled, isPermitted, isPermitted, isPermitted, isPermitted, isPermitted, isPermitted, isPermittedAll, isPermittedAll, isPermittedAll, onInit, setAuthorizationCache, setAuthorizationCacheName, setAuthorizationCachingEnabled, setName, setPermissionResolver, setRolePermissionResolver
assertCredentialsMatch, clearCachedAuthenticationInfo, getAuthenticationCache, getAuthenticationCacheKey, getAuthenticationCacheKey, getAuthenticationCacheName, getAuthenticationInfo, getAuthenticationTokenClass, getCredentialsMatcher, init, isAuthenticationCachingEnabled, isAuthenticationCachingEnabled, setAuthenticationCache, setAuthenticationCacheName, setAuthenticationCachingEnabled, setAuthenticationTokenClass, setCredentialsMatcher, supports
clearCache, getAvailablePrincipal, getCacheManager, getName, isCachingEnabled, onLogout, setCacheManager, setCachingEnabled
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
init
protected final Map<String,SimpleAccount> users
protected final Map<String,SimpleRole> roles
protected final ReadWriteLock USERS_LOCK
protected final ReadWriteLock ROLES_LOCK
public SimpleAccountRealm()
public SimpleAccountRealm(String name)
protected SimpleAccount getUser(String username)
public boolean accountExists(String username)
public void addAccount(String username, String password)
public void addAccount(String username, String password, String... roles)
protected String getUsername(SimpleAccount account)
protected String getUsername(PrincipalCollection principals)
protected void add(SimpleAccount account)
protected SimpleRole getRole(String rolename)
public boolean roleExists(String name)
protected void add(SimpleRole role)
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token) throws AuthenticationException
AuthenticatingRealm
null
return value means that no account could be associated with the specified token.doGetAuthenticationInfo
in class AuthenticatingRealm
token
- the authentication token containing the user's principal and credentials.AuthenticationInfo
object containing account data resulting from the
authentication ONLY if the lookup is successful (i.e. account exists and is valid, etc.)AuthenticationException
- if there is an error acquiring data or performing
realm-specific authentication logic for the specified tokenprotected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals)
AuthorizingRealm
SimpleAuthorizationInfo
, as it is suitable in most cases.doGetAuthorizationInfo
in class AuthorizingRealm
principals
- the primary identifying principals of the AuthorizationInfo that should be retrieved.SimpleAuthorizationInfo
Copyright © 2004-2016 The Apache Software Foundation. All Rights Reserved.