Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8848781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:29:26+00:00 2026-06-14T12:29:26+00:00

We are using two realms (one for hashed passwords, the other one for generated

  • 0

We are using two realms (one for hashed passwords, the other one for generated plaintext keys) – this is working as expected.

With a single realm, we could throw a DisabledAccountException exception in our realm’s protected AuthenticationInfo doGetAuthenticationInfo(final AuthenticationToken authToken) and explicitly catch such an exception in our application.

Now that we have two realms, all exceptions are Shiro-internally caught; so if one realm fails, the second one can be tried as well. However, this kind of redirect will only throw generic AuthenticationExceptions to our application.

Is there any workaround with multiple realms so that we can have more specific exceptions (to know if an account is locked, the credentials are simply wrong,…)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T12:29:27+00:00Added an answer on June 14, 2026 at 12:29 pm

    You need to specify your own AuthenticationStrategy in your ModularRealmAuthenticator.
    The ModularRealmAuthenticator uses AtLeastOneSuccessfulStrategy by default and AtLeastOneSuccessfulStrategy ignores the exceptions and keeps trying to login the users using all the realms available.

    We had a similar scenario on the tynamo project and to workaround this issue I’ve implemented my own AuthenticationStrategy, called FirstExceptionStrategy, that works with multiple realms and throws the first exception it gets. This approach works fine as long as there is only one Realm per Token type.

    The implementations is rather simple:

    /**
     * {@link org.apache.shiro.authc.pam.AuthenticationStrategy} implementation that throws the first exception it gets
     * and ignores all subsequent realms. If there is no exceptions it works as the {@link FirstSuccessfulStrategy}
     *
     * WARN: This approach works fine as long as there is ONLY ONE Realm per Token type.
     *
     */
    public class FirstExceptionStrategy extends FirstSuccessfulStrategy {
    
        @Override
        public AuthenticationInfo afterAttempt(Realm realm, AuthenticationToken token, AuthenticationInfo singleRealmInfo, AuthenticationInfo aggregateInfo, Throwable t) throws AuthenticationException {
            if ((t != null) && (t instanceof AuthenticationException)) throw (AuthenticationException) t;
            return super.afterAttempt(realm, token, singleRealmInfo, aggregateInfo, t);
        }
    
    }
    

    I repeat, this only works if there is ONLY ONE Realm per Token type.

    For more info about my particular scenario see here: http://jira.codehaus.org/browse/TYNAMO-154

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using two SQL Server, one is SQL Server 2000 and the other one
I am using two jQuery scripts. One is for controlling the drop down navigation
I am using two different scripts on one page and when I call them
I am using two button s Date and Time .They are working well .
I'm using two different TapGestureRecognizer to handle both single and double tap on screen.
I am using two different perspectives in Eclipse PyDev. One is for normal development,
I am using two shared hosting companies, I want to install thebuggenie in one
I am currently using two forms in my rails app, one for a contact
Using two barcode readers connected to one machine, I have a need to store
I am currently using two XBees, one of them attached to my computer, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.