Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>FirstSuccessfulStrategy</code> means that your authenticator will try all your realms to authenticate user until the first successful. Your realms was configured in order: <code>ldapRealm</code>, <code>SaltedSha512JPARealm</code>. So if <code>lapRealm</code> will fail authenticator will try second one. To solve this you can try to configure the most successful or the quickest realm to be first, e.g. you can change your realms order to be <code>SaltedSha512JPARealm</code>, <code>ldapRealm</code>:</p> <pre><code>&lt;bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager" depends-on="roleRepository,roleRightRepository,rightRepository,userRepository"&gt; &lt;property name="realms"&gt; &lt;list&gt; &lt;ref local="SaltedSha512JPARealm"/&gt; &lt;ref local="ldapRealm"/&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="authenticator.authenticationStrategy"&gt; &lt;bean class="org.apache.shiro.authc.pam.FirstSuccessfulStrategy"/&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>But you should understand that for this configuration if <code>SaltedSha512JPARealm</code> will fail, authenticator will try <code>ldapRealm</code>.</p> <p>Or you can try to use different token classes for this realms. But it will work only if you have different authentication entry points for each of them.</p> <p><strong>UPD</strong></p> <p>It seems that <code>ModularRealmAuthenticator</code> is designed so that it will always try to authenticate user by all realms. <code>FirstSuccessfulStrategy</code> can affect only on authentication result. It will return first successful <code>AuthenticationInfo</code>. To achieve your goal you need to override <code>ModularRealmAuthenticator#doMultiRealmAuthentication</code> method. It can look like this:</p> <pre><code>protected AuthenticationInfo doMultiRealmAuthentication(Collection&lt;Realm&gt; realms, AuthenticationToken token) { AuthenticationStrategy strategy = getAuthenticationStrategy(); AuthenticationInfo aggregate = strategy.beforeAllAttempts(realms, token); if (log.isTraceEnabled()) { log.trace("Iterating through {} realms for PAM authentication", realms.size()); } for (Realm realm : realms) { aggregate = strategy.beforeAttempt(realm, token, aggregate); if (realm.supports(token)) { log.trace("Attempting to authenticate token [{}] using realm [{}]", token, realm); AuthenticationInfo info = null; Throwable t = null; try { info = realm.getAuthenticationInfo(token); } catch (Throwable throwable) { t = throwable; if (log.isDebugEnabled()) { String msg = "Realm [" + realm + "] threw an exception during a multi-realm authentication attempt:"; log.debug(msg, t); } } aggregate = strategy.afterAttempt(realm, token, info, aggregate, t); // dirty dirty hack if (aggregate != null &amp;&amp; !CollectionUtils.isEmpty(aggregate.getPrincipals())) { return aggregate; } // end dirty dirty hack } else { log.debug("Realm [{}] does not support token {}. Skipping realm.", realm, token); } } aggregate = strategy.afterAllAttempts(token, aggregate); return aggregate; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload