Realm

A <tt>Realm</tt> is a security component that can access application-specific security entities such as users, roles, and permissions to determine authentication and authorization operations.

<p><tt>Realm</tt>s usually have a 1-to-1 correspondence with a datasource such as a relational database, file system, or other similar resource. As such, implementations of this interface use datasource-specific APIs to determine authorization data (roles, permissions, etc), such as JDBC, File IO, Hibernate or JPA, or any other Data Access API. They are essentially security-specific <a href="http://en.wikipedia.org/wiki/Data_Access_Object" target="_blank">DAO</a>s.

<p>Because most of these datasources usually contain Subject (a.k.a. User) information such as usernames and passwords, a Realm can act as a pluggable authentication module in a <a href="http://en.wikipedia.org/wiki/Pluggable_Authentication_Modules">PAM</a> configuration. This allows a Realm to perform <i>both</i> authentication and authorization duties for a single datasource, which caters to the large majority of applications. If for some reason you don't want your Realm implementation to perform authentication duties, you should override the {@link #supports(hunt.shiro.authc.AuthenticationToken)} method to always return <tt>false</tt>.

<p>Because every application is different, security data such as users and roles can be represented in any number of ways. Shiro tries to maintain a non-intrusive development philosophy whenever possible - it does not require you to implement or extend any <tt>User</tt>, <tt>Group</tt> or <tt>Role</tt> interfaces or classes.

<p>Instead, Shiro allows applications to implement this interface to access environment-specific datasources and data model objects. The implementation can then be plugged in to the application's Shiro configuration. This modular technique abstracts away any environment/modeling details and allows Shiro to be deployed in practically any application environment.

<p>Most users will not implement the <tt>Realm</tt> interface directly, but will extend one of the subclasses, {@link hunt.shiro.realm.AuthenticatingRealm AuthenticatingRealm} or {@link hunt.shiro.realm.AuthorizingRealm}, greatly reducing the effort requird to implement a <tt>Realm</tt> from scratch.</p>

@see hunt.shiro.realm.CachingRealm CachingRealm @see hunt.shiro.realm.AuthenticatingRealm AuthenticatingRealm @see hunt.shiro.realm.AuthorizingRealm AuthorizingRealm @see hunt.shiro.authc.pam.ModularRealmAuthenticator ModularRealmAuthenticator

Members

Functions

getAuthenticationInfo
AuthenticationInfo getAuthenticationInfo(AuthenticationToken token)

Returns an account's authentication-specific information for the specified <tt>token</tt>, or <tt>null</tt> if no account could be found based on the <tt>token</tt>.

getName
string getName()

Returns the (application-unique) name assigned to this <code>Realm</code>. All realms configured for a single application must have a unique name.

supports
bool supports(AuthenticationToken token)

Returns <tt>true</tt> if this realm wishes to authenticate the Subject represented by the given {@link hunt.shiro.authc.AuthenticationToken AuthenticationToken} instance, <tt>false</tt> otherwise.

Meta