]> git.argeo.org Git - lgpl/argeo-commons.git/blob - org.argeo.security.ui.admin/src/org/argeo/security/ui/admin/commands/NewUser.java
660896de8a493cf1c0522bf037d569b8b6dfe85a
[lgpl/argeo-commons.git] / org.argeo.security.ui.admin / src / org / argeo / security / ui / admin / commands / NewUser.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.security.ui.admin.commands;
17
18 import javax.jcr.Repository;
19 import javax.jcr.Session;
20
21 import org.argeo.jcr.JcrUtils;
22 import org.argeo.security.UserAdminService;
23 import org.argeo.security.jcr.JcrSecurityModel;
24 import org.argeo.security.ui.admin.wizards.NewUserWizard;
25 import org.eclipse.core.commands.AbstractHandler;
26 import org.eclipse.core.commands.ExecutionEvent;
27 import org.eclipse.core.commands.ExecutionException;
28 import org.eclipse.jface.wizard.WizardDialog;
29 import org.eclipse.ui.handlers.HandlerUtil;
30
31 /** Launch a wizard that enables creation of a new user. */
32 public class NewUser extends AbstractHandler {
33 private Repository repository;
34 private UserAdminService userAdminService;
35 private JcrSecurityModel jcrSecurityModel;
36
37 public Object execute(ExecutionEvent event) throws ExecutionException {
38 Session session = null;
39 try {
40 session = repository.login();
41 NewUserWizard newUserWizard = new NewUserWizard(session,
42 userAdminService, jcrSecurityModel);
43 WizardDialog dialog = new WizardDialog(
44 HandlerUtil.getActiveShell(event), newUserWizard);
45 dialog.open();
46 } catch (Exception e) {
47 throw new ExecutionException("Cannot open wizard", e);
48 } finally {
49 JcrUtils.logoutQuietly(session);
50 }
51 return null;
52 }
53
54 public void setRepository(Repository repository) {
55 this.repository = repository;
56 }
57
58 public void setUserAdminService(UserAdminService userAdminService) {
59 this.userAdminService = userAdminService;
60 }
61
62 public void setJcrSecurityModel(JcrSecurityModel jcrSecurityModel) {
63 this.jcrSecurityModel = jcrSecurityModel;
64 }
65
66 }