Refactor DaoAuthenticationProvider cache model.
This commit is contained in:
@@ -892,7 +892,6 @@
|
||||
|
||||
<para><programlisting><bean id="daoAuthenticationProvider" class="net.sf.acegisecurity.providers.dao.DaoAuthenticationProvider">
|
||||
<property name="authenticationDao"><ref bean="inMemoryDaoImpl"/></property>
|
||||
<property name="key"><value>my_password</value></property>
|
||||
<property name="refreshTokenInterval"><value>60000</value></property>
|
||||
<property name="saltSource"><ref bean="saltSource"/></property>
|
||||
<property name="passwordEncoder"><ref bean="passwordEncoder"/></property>
|
||||
@@ -910,23 +909,30 @@
|
||||
<literal>SaltSource</literal> implementations are also provided:
|
||||
<literal>SystemWideSaltSource</literal> which encodes all passwords
|
||||
with the same salt, and <literal>ReflectionSaltSource</literal>, which
|
||||
inspects a given property of the returned User object to obtain the
|
||||
salt. Please refer to the JavaDocs for further details on these
|
||||
optional features.</para>
|
||||
inspects a given property of the returned <literal>User</literal>
|
||||
object to obtain the salt. Please refer to the JavaDocs for further
|
||||
details on these optional features.</para>
|
||||
|
||||
<para>The <literal>key</literal> property permits the
|
||||
<literal>DaoAuthenticationProvider</literal> to build a
|
||||
<literal>DaoAuthenticationToken</literal> that represents the
|
||||
successful authentication request. This allows the
|
||||
<literal>DaoAuthenticationProvider</literal> to avoid repeated lookups
|
||||
of the backend authentication repository. For a presented
|
||||
<literal>DaoAuthenticationToken</literal> to be accepted as valid, it
|
||||
needs to both present the expected key (to prove it was created by the
|
||||
<literal>DaoAuthenticationProvider</literal>) and that is has not
|
||||
expired. <literal>DaoAuthenticationToken</literal>s by default expire
|
||||
60 seconds after they have been created, although this can be set to
|
||||
any other millisecond value via the
|
||||
<literal>refreshTokenInterval</literal> property.</para>
|
||||
<para>In addition to the properties above, the
|
||||
<literal>DaoAuthenticationProvider</literal> supports optional caching
|
||||
of <literal>User</literal> objects. The <literal>UserCache</literal>
|
||||
interface enables the <literal>DaoAuthenticationProvider</literal> to
|
||||
place a <literal>User</literal> object into the cache, and retrieve it
|
||||
from the cache upon subsequent authentication attempts for the same
|
||||
username. By default the <literal>DaoAuthenticationProvider</literal>
|
||||
uses the <literal>NullUserCache</literal>, which performs no caching.
|
||||
A usable caching implementation is also provided,
|
||||
<literal>EhCacheBasedUserCache</literal>, which is configured as
|
||||
follows:</para>
|
||||
|
||||
<para><programlisting><bean id="daoAuthenticationProvider" class="net.sf.acegisecurity.providers.dao.DaoAuthenticationProvider">
|
||||
<property name="authenticationDao"><ref bean="authenticationDao"/></property>
|
||||
<property name="userCache"><ref bean="userCache"/></property>
|
||||
</bean>
|
||||
|
||||
<bean id="userCache" class="net.sf.acegisecurity.providers.dao.cache.EhCacheBasedUserCache">
|
||||
<property name="minutesToIdle"><value>5</value></property>
|
||||
</bean></programlisting></para>
|
||||
|
||||
<para>For a class to be able to provide the
|
||||
<literal>DaoAuthenticationProvider</literal> with access to an
|
||||
|
||||
Reference in New Issue
Block a user