Browse Source

Allow JBoss adapter to handle new exceptions (thanks to Sergio Berna).

Ben Alex 21 years ago
parent
commit
607ba82522

+ 13 - 1
adapters/jboss/src/main/java/org/acegisecurity/adapters/jboss/JbossAcegiLoginModule.java

@@ -17,6 +17,8 @@ package net.sf.acegisecurity.adapters.jboss;
 
 import net.sf.acegisecurity.Authentication;
 import net.sf.acegisecurity.AuthenticationException;
+import net.sf.acegisecurity.CredentialsExpiredException;
+import net.sf.acegisecurity.AccountExpiredException;
 import net.sf.acegisecurity.AuthenticationManager;
 import net.sf.acegisecurity.adapters.PrincipalAcegiUserToken;
 import net.sf.acegisecurity.providers.UsernamePasswordAuthenticationToken;
@@ -210,7 +212,17 @@ public class JbossAcegiLoginModule extends AbstractServerLoginModule {
                 if (super.log.isDebugEnabled()) {
                     super.log.debug("authentication succeded");
                 }
-            } catch (AuthenticationException failed) {
+            }catch(CredentialsExpiredException cee){
+                if (super.log.isDebugEnabled()) {
+                    super.log.debug("Credential has expired");
+                }
+                throw new javax.security.auth.login.CredentialExpiredException("The credential used to identify the user has expired");
+			}catch(AccountExpiredException cee){
+                if (super.log.isDebugEnabled()) {
+                    super.log.debug("Account has expired, throwing jaas exception");
+                }
+                throw new javax.security.auth.login.AccountExpiredException("The account specified in login has expired");
+			}catch (AuthenticationException failed) {
                 if (super.log.isDebugEnabled()) {
                     super.log.debug("Bad password for username=" + username);
                 }

+ 1 - 0
doc/xdocs/changes.xml

@@ -47,6 +47,7 @@
       <action dev="benalex" type="add">Added attempted username to view if processed by AuthenticationProcessingFilter</action>
       <action dev="benalex" type="add">Added UserDetails account and credentials expiration methods</action>
       <action dev="benalex" type="add">Added exceptions and events to support new UserDetails methods</action>
+      <action dev="benalex" type="add">Added new exceptions to JBoss container adapter</action>
       <action dev="benalex" type="update">Improved BasicAclProvider to only respond to specified ACL object requests</action>
       <action dev="benalex" type="update">Refactored MethodDefinitionSource to work with Method, not MethodInvocation</action>
       <action dev="benalex" type="update">Refactored AbstractFilterInvocationDefinitionSource to work with URL Strings alone</action>

+ 3 - 0
project.xml

@@ -133,6 +133,9 @@
     <contributor>
       <name>Joni Suominen</name>
     </contributor>
+    <contributor>
+      <name>Sergio Berna</name>
+    </contributor>
   </contributors>
   <dependencies>
     <dependency>