]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - security/runtime/org.argeo.security.ldap/src/main/java/org/argeo/security/ldap/jcr/JcrLdapSynchronizer.java
Improve Security
[lgpl/argeo-commons.git] / 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);