karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [2/2] karaf git commit: [KARAF-4968] LDAPLoginModule does not correctly implement login method
Date Fri, 10 Feb 2017 20:25:51 GMT
[KARAF-4968] LDAPLoginModule does not correctly implement login method

Correcting the behavior of the LDAPLoginModule's login method in case of
failed authentication


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/5087c54e
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/5087c54e
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/5087c54e

Branch: refs/heads/karaf-4.0.x
Commit: 5087c54e97d0b5b8f57237244adec89bdb644859
Parents: 3bef71a
Author: Stijn Strickx <stijn.strickx@gmail.com>
Authored: Tue Jan 31 21:21:25 2017 +0100
Committer: Guillaume Nodet <gnodet@apache.org>
Committed: Fri Feb 10 21:00:53 2017 +0100

----------------------------------------------------------------------
 .../org/apache/karaf/jaas/modules/ldap/LDAPLoginModule.java   | 2 +-
 .../apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java   | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/5087c54e/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPLoginModule.java
----------------------------------------------------------------------
diff --git a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPLoginModule.java
b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPLoginModule.java
index 9f7da5b..3266c90 100644
--- a/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPLoginModule.java
+++ b/jaas/modules/src/main/java/org/apache/karaf/jaas/modules/ldap/LDAPLoginModule.java
@@ -138,7 +138,7 @@ public class LDAPLoginModule extends AbstractKarafLoginModule {
             context.close();
         } catch (Exception e) {
             logger.warn("User " + user + " authentication failed.", e);
-            return false;
+            throw new LoginException("Authentication failed: " + e.getMessage());
         } finally {
             if (context != null) {
                 try {

http://git-wip-us.apache.org/repos/asf/karaf/blob/5087c54e/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java
----------------------------------------------------------------------
diff --git a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java
b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java
index 2c11915..ff51a31 100644
--- a/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java
+++ b/jaas/modules/src/test/java/org/apache/karaf/jaas/modules/ldap/LdapLoginModuleTest.java
@@ -246,7 +246,12 @@ public class LdapLoginModuleTest extends AbstractLdapTestUnit {
         module.initialize(subject, cb, null, options);
 
         assertEquals("Precondition", 0, subject.getPrincipals().size());
-        assertFalse(module.login());
+        try {
+            module.login();
+            fail("Should have thrown LoginException");
+        } catch (LoginException e) {
+            assertTrue(e.getMessage().startsWith("Authentication failed"));
+        }
     }
 
     @Test


Mime
View raw message