Hi Stephen, I'm glad the reference guide is starting to do some good! But on to your question...
You mentioned a "default quick-start Authenticator". I'm a bit confused by this as I'm not sure to what you are referring. All authentication calls should initiate via the Subject.login method. Under the hood, the SecurityManager will use a ModularRealmAuthenticator to perform the authentication attempt. The ModularRealmAuthenticator will definitely throw an UnknownAccountException in a single-realm application if that realm returns null from the Realm.getAuthenticationInfo call. A multiple-realm application might not throw an exception though - it depends on the AuthenticationStrategy in place. By default, when multiple realms are present, an AtLeastOneSuccessfulStrategy is enabled. It will only throw an exception if none of the configured realms returned valid data. As long as 'at least one' of the realms authenticates successfully, the authentication attempt will be a success. Does this help at all? Do you have a stack trace or test case that might help us understand where/why this is happening? Best, Les On Fri, Jan 15, 2010 at 5:38 PM, Gorman, Stephen A. <[email protected]> wrote: > All, > > I just got finished reading the reference guide that Les posted. It’s > awesome, thanks Les. Reading it reminded me of a problem I am having with > catching login exceptions. In my code I use the default quick-start > Authenticator which performs the login using > SecurityUtils.subject.login(authToken). If I purposely use an account that > does not exists and break on > > > > catch ( UnknownAccountException uae ) > > > > It does not catch it. Instead it goes to > > > > catch (AuthenticationException ex) > > > > and from there I parse the ex.getMessage() to determine the error type. > > > > In the reference guide in the Subject section there is an example login that > is executed by currentUser which is of type Subject. Could it be that I am > using the wrong class to do login and that is why my exception isn’t getting > caught. > > > > > > Code sample: > > > > Inside ShiroDbRealm…. > > > > if (!user) > > { > > log.error "No such user in DB realm. Throwing Exception" > > throw new UnknownAccountException("No account found for user > [${username}]") > > } > >
