geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ammul...@apache.org
Subject svn commit: r345629 - in /geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers: CertificatePropertiesFileLoginModule.java LDAPLoginModule.java PropertiesFileLoginModule.java SQLLoginModule.java
Date Sat, 19 Nov 2005 04:12:06 GMT
Author: ammulder
Date: Fri Nov 18 20:11:58 2005
New Revision: 345629

URL: http://svn.apache.org/viewcvs?rev=345629&view=rev
Log:
Failed logins should result in an exception from login() -- GERONIMO-1201

Modified:
    geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/CertificatePropertiesFileLoginModule.java
    geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/LDAPLoginModule.java
    geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/PropertiesFileLoginModule.java
    geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/SQLLoginModule.java

Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/CertificatePropertiesFileLoginModule.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/CertificatePropertiesFileLoginModule.java?rev=345629&r1=345628&r2=345629&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/CertificatePropertiesFileLoginModule.java
(original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/CertificatePropertiesFileLoginModule.java
Fri Nov 18 20:11:58 2005
@@ -35,6 +35,7 @@
 import javax.security.auth.callback.NameCallback;
 import javax.security.auth.callback.UnsupportedCallbackException;
 import javax.security.auth.login.LoginException;
+import javax.security.auth.login.FailedLoginException;
 import javax.security.auth.spi.LoginModule;
 import javax.security.auth.x500.X500Principal;
 
@@ -149,7 +150,10 @@
         }
         principal = certificate.getSubjectX500Principal();
 
-        return users.containsKey(principal.getName());
+        if(!users.containsKey(principal.getName())) {
+            throw new FailedLoginException();
+        }
+        return true;
     }
 
     public boolean commit() throws LoginException {
@@ -184,7 +188,7 @@
 
     public boolean logout() throws LoginException {
         principal = null;
-
+        //todo: should remove principals added by commit
         return true;
     }
 

Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/LDAPLoginModule.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/LDAPLoginModule.java?rev=345629&r1=345628&r2=345629&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/LDAPLoginModule.java
(original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/LDAPLoginModule.java
Fri Nov 18 20:11:58 2005
@@ -47,6 +47,7 @@
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.callback.UnsupportedCallbackException;
 import javax.security.auth.login.LoginException;
+import javax.security.auth.login.FailedLoginException;
 import javax.security.auth.spi.LoginModule;
 
 import org.apache.commons.logging.Log;
@@ -151,7 +152,12 @@
         }
 
         try {
-            return authenticate(cbUsername, cbPassword);
+            boolean result = authenticate(cbUsername, cbPassword);
+            if(!result) {
+                throw new FailedLoginException();
+            } else {
+                return true;
+            }
         } catch (Exception e) {
             throw (LoginException) new LoginException("LDAP Error").initCause(e);
         }
@@ -160,6 +166,7 @@
     public boolean logout() throws LoginException {
         cbUsername = null;
         cbPassword = null;
+        //todo: should remove principals added by commit
         return true;
     }
 

Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/PropertiesFileLoginModule.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/PropertiesFileLoginModule.java?rev=345629&r1=345628&r2=345629&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/PropertiesFileLoginModule.java
(original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/PropertiesFileLoginModule.java
Fri Nov 18 20:11:58 2005
@@ -34,6 +34,7 @@
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.callback.UnsupportedCallbackException;
 import javax.security.auth.login.LoginException;
+import javax.security.auth.login.FailedLoginException;
 import javax.security.auth.spi.LoginModule;
 
 import org.apache.commons.logging.Log;
@@ -135,8 +136,12 @@
         String realPassword = users.getProperty(username);
         char[] entered = ((PasswordCallback) callbacks[1]).getPassword();
         password = entered == null ? null : new String(entered);
-        return (realPassword == null && password == null) ||
+        boolean result = (realPassword == null && password == null) ||
                 (realPassword != null && password != null && realPassword.equals(password));
+        if(!result) {
+            throw new FailedLoginException();
+        }
+        return true;
     }
 
     public boolean commit() throws LoginException {
@@ -171,7 +176,7 @@
     public boolean logout() throws LoginException {
         username = null;
         password = null;
-
+        //todo: should remove principals added by commit
         return true;
     }
 

Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/SQLLoginModule.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/SQLLoginModule.java?rev=345629&r1=345628&r2=345629&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/SQLLoginModule.java
(original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/realm/providers/SQLLoginModule.java
Fri Nov 18 20:11:58 2005
@@ -35,6 +35,7 @@
 import javax.security.auth.callback.PasswordCallback;
 import javax.security.auth.callback.UnsupportedCallbackException;
 import javax.security.auth.login.LoginException;
+import javax.security.auth.login.FailedLoginException;
 import javax.security.auth.spi.LoginModule;
 
 import org.apache.geronimo.security.jaas.JaasLoginModuleUse;
@@ -137,7 +138,9 @@
                     statement.close();
                 }
 
-                if (!found) return false;
+                if (!found) {
+                    throw new FailedLoginException();
+                }
 
                 statement = conn.prepareStatement(groupSelect);
                 try {
@@ -193,7 +196,7 @@
     public boolean logout() throws LoginException {
         cbUsername = null;
         cbPassword = null;
-
+        //todo: should remove principals put in by commit
         return true;
     }
 }



Mime
View raw message