]> git.argeo.org Git - lgpl/argeo-commons.git/blobdiff - security/plugins/org.argeo.security.ui.admin/src/main/java/org/argeo/security/ui/admin/wizards/NewUserWizard.java
Add dep folder
[lgpl/argeo-commons.git] / security / plugins / org.argeo.security.ui.admin / src / main / java / org / argeo / security / ui / admin / wizards / NewUserWizard.java
index 3af4fa954f7ee87d3537e95cc98ea6b264dc2777..c2d041f56832bf07f6ddc92bb6440983fe1d6e36 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2007-2012 Argeo GmbH
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *         http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package org.argeo.security.ui.admin.wizards;
 
 import javax.jcr.Node;
@@ -8,7 +23,9 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.argeo.eclipse.ui.ErrorFeedback;
 import org.argeo.jcr.JcrUtils;
+import org.argeo.jcr.UserJcrUtils;
 import org.argeo.security.UserAdminService;
+import org.argeo.security.jcr.JcrSecurityModel;
 import org.argeo.security.jcr.JcrUserDetails;
 import org.eclipse.jface.wizard.Wizard;
 import org.springframework.security.GrantedAuthority;
@@ -18,13 +35,16 @@ public class NewUserWizard extends Wizard {
        private final static Log log = LogFactory.getLog(NewUserWizard.class);
        private Session session;
        private UserAdminService userAdminService;
+       private JcrSecurityModel jcrSecurityModel;
 
        // pages
        private MainUserInfoWizardPage mainUserInfo;
 
-       public NewUserWizard(Session session, UserAdminService userAdminService) {
+       public NewUserWizard(Session session, UserAdminService userAdminService,
+                       JcrSecurityModel jcrSecurityModel) {
                this.session = session;
                this.userAdminService = userAdminService;
+               this.jcrSecurityModel = jcrSecurityModel;
        }
 
        @Override
@@ -40,9 +60,11 @@ public class NewUserWizard extends Wizard {
 
                String username = mainUserInfo.getUsername();
                try {
-                       Node userProfile = JcrUtils.createUserProfile(session, username);
-                       // session.getWorkspace().getVersionManager()
-                       // .checkout(userProfile.getPath());
+                       // Node userProfile = SecurityJcrUtils.createUserProfile(session,
+                       // username);
+                       Node userProfile = jcrSecurityModel.sync(session, username, null);
+                       session.getWorkspace().getVersionManager()
+                                       .checkout(userProfile.getPath());
                        mainUserInfo.mapToProfileNode(userProfile);
                        String password = mainUserInfo.getPassword();
                        // TODO add roles
@@ -55,7 +77,7 @@ public class NewUserWizard extends Wizard {
                        return true;
                } catch (Exception e) {
                        JcrUtils.discardQuietly(session);
-                       Node userHome = JcrUtils.getUserHome(session, username);
+                       Node userHome = UserJcrUtils.getUserHome(session, username);
                        if (userHome != null) {
                                try {
                                        userHome.remove();