title: How to get specific realm from Multiple realms for authorization in Shiro?
body: <p>I am newbie to Spring and Shiro platforms.</p>
  
  <p>I have two url sets <code>/admin/--</code> and <code>/vendor/--</code>. Both client sets are authenticating with specific realms. I have extended <code>ModularRealmAuthenticator</code> class to choose correct realm for authenticating. </p>
  
  <p>ModularRealmAuthenticator.java</p>
  
  <pre><code>@Override
  protected AuthenticationInfo doAuthenticate(AuthenticationToken authenticationToken) throws AuthenticationException {
      assertRealmsConfigured();
      MultiLoginAuthenticationToken mlat = null;
      Realm loginRealm = null;
  
      if (!(authenticationToken instanceof MultiLoginAuthenticationToken)) {
          throw new AuthenticationException("Unrecognized token , not a typeof MultiLoginAuthenticationToken ");
      } else {
          mlat = (MultiLoginAuthenticationToken) authenticationToken;
          logger.debug("realm name is : {}", mlat.getRealmName());
          loginRealm = lookupRealm(mlat.getRealmName());
      }
  
      return doSingleRealmAuthentication(loginRealm, mlat);
  
  }
  
  protected Realm lookupRealm(String realmName) throws AuthenticationException {
      Collection&lt;Realm&gt; realms = getRealms();
      for (Realm realm : realms) {
          if (realm.getName().equalsIgnoreCase(realmName)) {
              logger.debug("look up realm name is : {}", realm.getName());
              return realm;
          }
      }
      throw new AuthenticationException("No realm configured for Client " + realmName);
  }
  </code></pre>
  
  <p>But while I am assigning role and permissions from different set of datasource to both clients (Admin and vendor). It is iterating the realms in order which I have defined in applicationContext.xml file. </p>
  
  <p>My ApplicationContext.xml </p>
  
  <pre><code>&lt;bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager"&gt;
  
      &lt;property name="authenticator"&gt;
          &lt;bean class="com.yatra.mp.security.MultiLoginAuthenticator"/&gt;
      &lt;/property&gt;
  
      &lt;!-- Single realm app (realm configured next, below). If you have multiple 
          realms, use the 'realms' property instead. --&gt;
      &lt;property name="realms"&gt;
          &lt;util:list&gt;
              &lt;ref bean="adminAuthRealm" /&gt;
              &lt;ref bean="vendorAuthRealm" /&gt;              
          &lt;/util:list&gt;
      &lt;/property&gt;
  
      &lt;property name="cacheManager" ref="cacheManager" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>In both of realms are extending <strong>AuthorizingRealm</strong> class and both have <strong>doGetAuthorizationInfo</strong> and <strong>doGetAuthenticationInfo</strong> method. In which I have defined my custom implementation.</p>
  
  <p>Is it necessary to extend <strong>ModularRealmAuthorizer</strong> class? If yes, could you please tell me which method I have override?</p>