Default no-argument constructor that defaults {@link #isCachingEnabled() cachingEnabled} (for general caching) to {@code true} and sets a default {@link #getName() name} based on the class name. <p/> Note that while in general, caching may be enabled by default, subclasses have control over if specific caching is enabled.
Template method that may be implemented by subclasses should they wish to react to a {@link CacheManager} instance being set on the realm instance via the {@link #setCacheManager(hunt.shiro.cache.CacheManager)} mutator.
Clears out any cached data associated with the specified account identity/identities. <p/> This implementation will return quietly if the principals argument is null or empty. Otherwise it delegates to {@link #doClearCache(hunt.shiro.subject.PrincipalCollection)}.
This implementation does nothing - it is a template to be overridden by subclasses if necessary.
A utility method for subclasses that returns the first available principal of interest to this particular realm. The heuristic used to acquire the principal is as follows: <ul> <li>Attempt to get <em>this particular Realm's</em> 'primary' principal in the {@code PrincipalCollection} via a <code>principals.{@link PrincipalCollection#fromRealm(string) fromRealm}({@link #getName() getName()})</code> call.</li> <li>If the previous call does not result in any principals, attempt to get the overall 'primary' principal from the PrincipalCollection via {@link hunt.shiro.subject.PrincipalCollection#getPrimaryPrincipal()}.</li> <li>If there are no principals from that call (or the PrincipalCollection argument was null to begin with), return {@code null}</li> </ul>
Returns the <tt>CacheManager</tt> used for data caching to reduce EIS round trips, or <tt>null</tt> if caching is disabled.
Returns {@code true} if caching should be used if a {@link CacheManager} has been {@link #setCacheManager(hunt.shiro.cache.CacheManager) configured}, {@code false} otherwise. <p/> The default value is {@code true} since the large majority of Realms will benefit from caching if a CacheManager has been configured. However, memory-only realms should set this value to {@code false} since they would manage account data in memory already lookups would already be as efficient as possible.
If caching is enabled, this will clear any cached data associated with the specified account identity. Subclasses are free to override for additional behavior, but be sure to call {@code super.onLogout} first. <p/> This default implementation merely calls {@link #clearCache(hunt.shiro.subject.PrincipalCollection)}.
Sets the <tt>CacheManager</tt> to be used for data caching to reduce EIS round trips. <p/> This property is <tt>null</tt> by default, indicating that caching is turned off.
Sets whether or not caching should be used if a {@link CacheManager} has been {@link #setCacheManager(hunt.shiro.cache.CacheManager) configured}.
Returns the (application-unique) name assigned to this <code>Realm</code>. All realms configured for a single application must have a unique name.
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.
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>.
Sets the (preferably application unique) name for this component. @param name the preferably application unique name for this component.
Sets the available CacheManager instance on this component.
Callback triggered when a <code>Subject</code> logs out of the system.
A very basic abstract extension point for the {@link Realm} interface that provides caching support for subclasses. <p/> It also provides a convenience method, {@link #getAvailablePrincipal(hunt.shiro.subject.PrincipalCollection)}, which is useful across all realm subclasses for obtaining a realm-specific principal/identity. <p/> All actual Realm method implementations are left to subclasses.
@see #clearCache(hunt.shiro.subject.PrincipalCollection) @see #onLogout(hunt.shiro.subject.PrincipalCollection) @see #getAvailablePrincipal(hunt.shiro.subject.PrincipalCollection)