IniRealm

A {@link hunt.shiro.realm.Realm Realm} implementation that creates {@link hunt.shiro.authc.SimpleAccount SimpleAccount} instances based on {@link Ini} configuration. <p/> This implementation looks for two {@link IniSection sections} in the {@code Ini} configuration: <pre> users

# One or more {@link hunt.shiro.realm.text.TextConfigurationRealm#setUserDefinitions(string) user definitions} ... roles

# One or more {@link hunt.shiro.realm.text.TextConfigurationRealm#setRoleDefinitions(string) role definitions}</pre> <p/> This class also supports setting the {@link #setResourcePath(string) resourcePath} property to create account data from an .ini resource. This will only be used if there isn't already account data in the Realm.

Constructors

this
this()
Undocumented in source.
this
this(Ini ini)

This constructor will immediately process the definitions in the {@code Ini} argument. If you need to perform additional configuration before processing (e.g. setting a permissionResolver, etc), do not call this constructor. Instead, do the following: <ol> <li>Call the default no-arg constructor</li> <li>Set the Ini instance you wish to use via {@code #setIni}</li> <li>Set any other configuration properties</li> <li>Call {@link #init()}</li> </ol>

this
this(string resourcePath)

This constructor will immediately process the definitions in the {@code Ini} resolved from the specified {@code resourcePath}. If you need to perform additional configuration before processing (e.g. setting a permissionResolver, etc), do not call this constructor. Instead, do the following: <ol> <li>Call the default no-arg constructor</li> <li>Set the Ini instance you wish to use via {@code #setIni}</li> <li>Set any other configuration properties</li> <li>Call {@link #init()}</li> </ol>

Members

Functions

getIni
Ini getIni()

Returns the Ini instance used to configure this realm. Provided for JavaBeans-style configuration of this realm, particularly useful in Dependency Injection environments.

getResourcePath
string getResourcePath()
Undocumented in source. Be warned that the author may not have intended to support it.
onInit
void onInit()
Undocumented in source. Be warned that the author may not have intended to support it.
setIni
void setIni(Ini ini)

Sets the Ini instance used to configure this realm. Provided for JavaBeans-style configuration of this realm, particularly useful in Dependency Injection environments.

setResourcePath
void setResourcePath(string resourcePath)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

ROLES_SECTION_NAME
enum string ROLES_SECTION_NAME;
Undocumented in source.
USERS_SECTION_NAME
enum string USERS_SECTION_NAME;
Undocumented in source.

Inherited Members

From TextConfigurationRealm

onInit
void onInit()

Will call 'processDefinitions' on startup.

getUserDefinitions
string getUserDefinitions()
Undocumented in source. Be warned that the author may not have intended to support it.
setUserDefinitions
void setUserDefinitions(string userDefinitions)

<p>Sets a newline (\n) delimited string that defines user-to-password-and-role(s) key/value pairs according to the following format: <p/> <p><code><em>username</em> = <em>password</em>, role1, role2,...</code></p> <p/> <p>Here are some examples of what these lines might look like:</p> <p/> <p><code>root = <em>reallyHardToGuessPassword</em>, administrator<br/> jsmith = <em>jsmithsPassword</em>, manager, engineer, employee<br/> abrown = <em>abrownsPassword</em>, qa, employee<br/> djones = <em>djonesPassword</em>, qa, contractor<br/> guest = <em>guestPassword</em></code></p>

getRoleDefinitions
string getRoleDefinitions()
Undocumented in source. Be warned that the author may not have intended to support it.
setRoleDefinitions
void setRoleDefinitions(string roleDefinitions)

Sets a newline (\n) delimited string that defines role-to-permission definitions. <p/> <p>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:</p> <p/> <p><code><em>rolename</em> = <em>permissionDefinition1</em>, <em>permissionDefinition2</em>, ...</code></p> <p/> <p>where <em>permissionDefinition</em> is an arbitrary string, but must people will want to use Strings that conform to the {@link hunt.shiro.authz.permission.WildcardPermission WildcardPermission} format for ease of use and flexibility. Note that if an individual <em>permissionDefinition</em> needs to be internally comma-delimited (e.g. <code>printer:5thFloor:print,info</code>), you will need to surround that definition with double quotes (&quot;) to avoid parsing errors (e.g. <code>&quot;printer:5thFloor:print,info&quot;</code>). <p/> <p><b>NOTE:</b> if you have roles that don't require permission associations, don't include them in this definition - just defining the role name in the {@link #setUserDefinitions(string) userDefinitions} is 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.

processDefinitions
void processDefinitions()
Undocumented in source. Be warned that the author may not have intended to support it.
processRoleDefinitions
void processRoleDefinitions()
Undocumented in source. Be warned that the author may not have intended to support it.
processRoleDefinitions
void processRoleDefinitions(Map!(string, string) roleDefs)
Undocumented in source. Be warned that the author may not have intended to support it.
processUserDefinitions
void processUserDefinitions()
Undocumented in source. Be warned that the author may not have intended to support it.
processUserDefinitions
void processUserDefinitions(Map!(string, string) userDefs)
Undocumented in source. Be warned that the author may not have intended to support it.
toLines
Set!(string) toLines(string s)
Undocumented in source. Be warned that the author may not have intended to support it.
toMap
Map!(string, string) toMap(Collection!(string) keyValuePairs)
Undocumented in source. Be warned that the author may not have intended to support it.

Meta