Improve Security
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 5 Nov 2011 14:54:09 +0000 (14:54 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 5 Nov 2011 14:54:09 +0000 (14:54 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@4892 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

security/runtime/org.argeo.security.ldap/src/main/java/org/argeo/security/ldap/jcr/JcrLdapSynchronizer.java

index 0f59f1ee528c11561e8d9a67b6d4a3c13bb4b1d0..632ea58c8778e8c92fab438744faf1cfc98885be 100644 (file)
@@ -229,7 +229,7 @@ public class JcrLdapSynchronizer implements UserDetailsContextMapper,
         * 
         * @return path to user profile
         */
-       protected String mapLdapToJcr(DirContextAdapter ctx) {
+       protected synchronized String mapLdapToJcr(DirContextAdapter ctx) {
                Session session = securitySession;
                try {
                        // process
@@ -238,6 +238,20 @@ public class JcrLdapSynchronizer implements UserDetailsContextMapper,
                        Node userProfile; // = userHome.getNode(ARGEO_PROFILE);
                        if (userHome.hasNode(ARGEO_PROFILE)) {
                                userProfile = userHome.getNode(ARGEO_PROFILE);
+
+                               // compatibility with legacy, will be removed
+                               if (!userProfile.hasProperty(ARGEO_ENABLED)) {
+                                       session.getWorkspace().getVersionManager()
+                                                       .checkout(userProfile.getPath());
+                                       userProfile.setProperty(ARGEO_ENABLED, true);
+                                       userProfile.setProperty(ARGEO_ACCOUNT_NON_EXPIRED, true);
+                                       userProfile.setProperty(ARGEO_ACCOUNT_NON_LOCKED, true);
+                                       userProfile
+                                                       .setProperty(ARGEO_CREDENTIALS_NON_EXPIRED, true);
+                                       session.save();
+                                       session.getWorkspace().getVersionManager()
+                                                       .checkin(userProfile.getPath());
+                               }
                        } else {
                                userProfile = JcrUtils.createUserProfile(securitySession,
                                                username);