Class TextConfigurationRealm
- All Implemented Interfaces:
LogoutAware,Authorizer,PermissionResolverAware,RolePermissionResolverAware,org.apache.shiro.cache.CacheManagerAware,org.apache.shiro.lang.util.Initializable,org.apache.shiro.lang.util.Nameable,Realm
- Direct Known Subclasses:
IniRealm,PropertiesRealm
setUserDefinitions(java.lang.String) method and
Role-to-permission definitions are specified via the setRoleDefinitions(java.lang.String) method.- Since:
- 0.9
-
Field Summary
Fields inherited from class org.apache.shiro.realm.SimpleAccountRealm
roles, rolesLock, users, usersLock -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidonInit()Will call 'processDefinitions' on startup.protected voidprotected voidprotected voidprocessRoleDefinitions(Map<String, String> roleDefs) protected voidprotected voidprocessUserDefinitions(Map<String, String> userDefs) voidsetRoleDefinitions(String roleDefinitions) Sets a newline (\n) delimited String that defines role-to-permission definitions.voidsetUserDefinitions(String userDefinitions) Sets a newline (\n) delimited String that defines user-to-password-and-role(s) key/value pairs according to the following format:toMap(Collection<String> keyValuePairs) Methods inherited from class org.apache.shiro.realm.SimpleAccountRealm
accountExists, add, add, addAccount, addAccount, addRole, doGetAuthenticationInfo, doGetAuthorizationInfo, getRole, getUser, getUsername, getUsername, roleExists, toSetMethods inherited from class org.apache.shiro.realm.AuthorizingRealm
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, setAuthorizationCache, setAuthorizationCacheName, setAuthorizationCachingEnabled, setName, setPermissionResolver, setRolePermissionResolverMethods inherited from class org.apache.shiro.realm.AuthenticatingRealm
assertCredentialsMatch, clearCachedAuthenticationInfo, getAuthenticationCache, getAuthenticationCacheKey, getAuthenticationCacheKey, getAuthenticationCacheName, getAuthenticationInfo, getAuthenticationTokenClass, getCredentialsMatcher, init, isAuthenticationCachingEnabled, isAuthenticationCachingEnabled, setAuthenticationCache, setAuthenticationCacheName, setAuthenticationCachingEnabled, setAuthenticationTokenClass, setCredentialsMatcher, supportsMethods inherited from class org.apache.shiro.realm.CachingRealm
clearCache, getAvailablePrincipal, getCacheManager, getName, isCachingEnabled, onLogout, setCacheManager, setCachingEnabledMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.shiro.lang.util.Initializable
init
-
Constructor Details
-
TextConfigurationRealm
public TextConfigurationRealm()
-
-
Method Details
-
onInit
Will call 'processDefinitions' on startup.- Overrides:
onInitin classAuthorizingRealm- Since:
- 1.2
- See Also:
-
getUserDefinitions
-
setUserDefinitions
Sets a newline (\n) delimited String that defines user-to-password-and-role(s) key/value pairs according to the following format:
username = password, role1, role2,...Here are some examples of what these lines might look like:
root = reallyHardToGuessPassword, administrator
jsmith = jsmithsPassword, manager, engineer, employee
abrown = abrownsPassword, qa, employee
djones = djonesPassword, qa, contractor
guest = guestPassword- Parameters:
userDefinitions- the user definitions to be parsed and converted to Map.Entry elements
-
getRoleDefinitions
-
setRoleDefinitions
Sets a newline (\n) delimited String that defines role-to-permission definitions.Each line within the string must define a role-to-permission(s) key/value mapping with the equals character signifies the key/value separation, like so:
rolename = permissionDefinition1, permissionDefinition2, ...where permissionDefinition is an arbitrary String, but must people will want to use Strings that conform to the
WildcardPermissionformat for ease of use and flexibility. Note that if an individual permissionDefinition needs to be internally comma-delimited (e.g.printer:5thFloor:print,info), you will need to surround that definition with double quotes (") to avoid parsing errors (e.g."printer:5thFloor:print,info").NOTE: if you have roles that don't require permission associations, don't include them in this definition - just defining the role name in the
userDefinitionsis enough to create the role if it does not yet exist. This property is really only for configuring realms that have one or more assigned Permission.- Parameters:
roleDefinitions- the role definitions to be parsed at initialization
-
processDefinitions
-
processRoleDefinitions
- Throws:
ParseException
-
processRoleDefinitions
-
processUserDefinitions
- Throws:
ParseException
-
processUserDefinitions
-
toLines
-
toMap
- Throws:
ParseException
-