jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ang...@apache.org
Subject svn commit: r1547799 - in /jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap: JndiLdapSearch.java LdapLoginModule.java LdapSearch.java
Date Wed, 04 Dec 2013 14:04:14 GMT
Author: angela
Date: Wed Dec  4 14:04:13 2013
New Revision: 1547799

URL: http://svn.apache.org/r1547799
Log:
OAK-516 : Create LdapLoginModule based on ExternalLoginModule

- update sharedstate upon successful login
- minor improvement

Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/JndiLdapSearch.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapLoginModule.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapSearch.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/JndiLdapSearch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/JndiLdapSearch.java?rev=1547799&r1=1547798&r2=1547799&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/JndiLdapSearch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/JndiLdapSearch.java
Wed Dec  4 14:04:13 2013
@@ -224,7 +224,7 @@ public class JndiLdapSearch implements L
     }
 
     @Override
-    public void authenticate(LdapUser user) throws LoginException {
+    public boolean authenticate(LdapUser user) throws LoginException {
         try {
             Hashtable<String,String> env = new Hashtable<String,String>(ldapEnvironment);
             env.put(Context.SECURITY_PRINCIPAL, user.getDN());
@@ -232,6 +232,7 @@ public class JndiLdapSearch implements L
             //TODO
             env.put(Context.SECURITY_AUTHENTICATION, "simple");
             new InitialDirContext(env).close();
+            return true;
         } catch (NamingException e) {
             throw new LoginException("Could not create initial LDAP context for user " +
user.getDN() + ": " + e.getMessage());
         }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapLoginModule.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapLoginModule.java?rev=1547799&r1=1547798&r2=1547799&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapLoginModule.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapLoginModule.java
Wed Dec  4 14:04:13 2013
@@ -74,8 +74,14 @@ public final class LdapLoginModule exten
     public boolean login() throws LoginException {
         ldapUser = getExternalUser();
         if (ldapUser != null && search.findUser(ldapUser)) {
-            search.authenticate(ldapUser);
-            success = true;
+            if (search.authenticate(ldapUser)) {
+                success = true;
+                log.debug("Adding Credentials to shared state.");
+                sharedState.put(SHARED_KEY_CREDENTIALS, credentials);
+
+                log.debug("Adding login name to shared state.");
+                sharedState.put(SHARED_KEY_LOGIN_NAME, ldapUser.getId());
+            }
         }
         return success;
     }

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapSearch.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapSearch.java?rev=1547799&r1=1547798&r2=1547799&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapSearch.java
(original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/security/authentication/ldap/LdapSearch.java
Wed Dec  4 14:04:13 2013
@@ -17,13 +17,15 @@
 package org.apache.jackrabbit.oak.security.authentication.ldap;
 
 import java.util.Set;
+import javax.annotation.Nonnull;
 import javax.security.auth.login.LoginException;
 
 public interface LdapSearch {
 
-    boolean findUser(LdapUser user);
+    boolean findUser(@Nonnull LdapUser user);
 
-    Set<LdapGroup> findGroups(LdapUser user);
+    @Nonnull
+    Set<LdapGroup> findGroups(@Nonnull LdapUser user);
 
-    void authenticate(LdapUser user) throws LoginException;
+    boolean authenticate(@Nonnull LdapUser user) throws LoginException;
 }



Mime
View raw message