<!-- <bean id="openArgeoUserEditor" class="org.argeo.security.ui.admin.commands.OpenArgeoUserEditor"
scope="prototype" /> -->
+
<!-- USERS -->
+ <bean id="newUser" class="org.argeo.security.ui.admin.commands.NewUser"
+ scope="prototype">
+ <property name="userAdmin" ref="userAdmin" />
+ </bean>
<!-- <bean id="newUser" class="org.argeo.security.ui.admin.commands.NewUser"
scope="prototype"> <property name="repository" ref="nodeRepository" /> <property
name="userAdminService" ref="userAdminService" /> </bean> <bean id="refreshUsersList"
name="Groups"
restorable="false">
</view>
-
- <!-- Legacy -->
- <!-- <view
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- icon="icons/users.gif"
- id="org.argeo.security.ui.admin.jcrUsersView"
- name="Users"
- restorable="false">
- </view>
- <view
- class="org.argeo.eclipse.spring.SpringExtensionFactory"
- icon="icons/role.gif"
- id="org.argeo.security.ui.admin.jcrRolesView"
- name="Roles"
- restorable="false">
- </view>-->
- </extension>
+ </extension>
<!-- Editors -->
<extension
<extension
point="org.eclipse.ui.commands">
+ <command
+ defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+ id="org.argeo.security.ui.admin.newUser"
+ name="New User">
+ </command>
+ <command
+ defaultHandler="org.argeo.security.ui.admin.commands.DeleteUsers"
+ id="org.argeo.security.ui.admin.deleteUsers"
+ name="Delete User">
+ </command>
+ <command
+ defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
+ id="org.argeo.security.ui.admin.newGroup"
+ name="New Group">
+ </command>
+ <command
+ defaultHandler="org.argeo.security.ui.admin.commands.DeleteGroups"
+ id="org.argeo.security.ui.admin.deleteGroups"
+ name="Delete Group">
+ </command>
+
+ <!-- Force the refresh when the various listener are not enough -->
+ <command
+ defaultHandler="org.argeo.security.ui.admin.commands.ForceRefresh"
+ id="org.argeo.security.ui.admin.forceRefresh"
+ name="Force Refresh">
+ </command>
<!--<command
defaultHandler="org.argeo.eclipse.spring.SpringCommandHandler"
id="org.argeo.security.ui.admin.openArgeoUserEditor"
</extension>
<extension
point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="toolbar:org.argeo.security.ui.admin.usersView">
+ <command
+ commandId="org.argeo.security.ui.admin.deleteUsers"
+ icon="icons/remove.gif"
+ label="Delete User"
+ tooltip="Delete selected users">
+ </command>
+ <command
+ commandId="org.argeo.security.ui.admin.forceRefresh"
+ icon="icons/refresh.png"
+ label="Refresh list"
+ tooltip="Force the full refresh of the user list">
+ </command>
+ <command
+ commandId="org.argeo.security.ui.admin.newUser"
+ icon="icons/add.gif"
+ label="Add User"
+ tooltip="Create a new user">
+ </command>
+ <!--<command
+ commandId="org.argeo.security.ui.admin.userBatchUpdate"
+ icon="icons/batch.gif"
+ label="Update users"
+ tooltip="Perform maintenance activities on a list of chosen users">
+ </command>-->
+ </menuContribution>
+ <menuContribution
+ locationURI="toolbar:org.argeo.security.ui.admin.groupsView">
+ <command
+ commandId="org.argeo.security.ui.admin.deleteGroups"
+ icon="icons/remove.gif"
+ label="Delete Group"
+ tooltip="Delete selected groups">
+ </command>
+ <command
+ commandId="org.argeo.security.ui.admin.forceRefresh"
+ icon="icons/refresh.png"
+ label="Refresh list"
+ tooltip="Force the full refresh of the group list">
+ </command>
+ <command
+ commandId="org.argeo.security.ui.admin.newGroup"
+ icon="icons/add.gif"
+ label="Add Group"
+ tooltip="Create a new group">
+ </command>
+ </menuContribution>
+
<!-- <menuContribution
locationURI="toolbar:org.argeo.security.ui.admin.adminRolesView">
<command
+++ /dev/null
-/*
- * 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.commands;
-
-import org.argeo.security.UserAdminService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/** Add a new role. */
-public class AddRole extends AbstractHandler {
- public final static String COMMAND_ID = "org.argeo.security.ui.admin.addRole";
- private UserAdminService userAdminService;
- private String rolePrefix = "ROLE_";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- return null;
- }
-
- public void setUserAdminService(UserAdminService userAdminService) {
- this.userAdminService = userAdminService;
- }
-}
-// JcrRolesView rolesView = (JcrRolesView) HandlerUtil
-// .getActiveWorkbenchWindow(event).getActivePage()
-// .findView(JcrRolesView.ID);
-// String role = rolesView.getNewRole();
-// if (role.trim().equals(""))
-// return null;
-// if (role.equals(rolesView.getAddNewRoleText()))
-// return null;
-// role = role.trim().toUpperCase();
-// if (!role.startsWith(rolePrefix))
-// role = rolePrefix + role;
-// if (userAdminService.listEditableRoles().contains(role))
-// throw new ArgeoException("Role " + role + " already exists");
-// userAdminService.newRole(role);
-// rolesView.refresh();
-//
-// // refresh editors
-// IEditorReference[] refs = HandlerUtil.getActiveWorkbenchWindow(event)
-// .getActivePage()
-// .findEditors(null, JcrArgeoUserEditor.ID, IWorkbenchPage.MATCH_ID);
-// for (IEditorReference ref : refs) {
-// JcrArgeoUserEditor userEditor = (JcrArgeoUserEditor) ref.getEditor(false);
-// if (userEditor != null) {
-// userEditor.refresh();
-// }
-// }
-// return null;
-// }
-//
-// public void setUserAdminService(UserAdminService userAdminService) {
-// this.userAdminService = userAdminService;
-// }
-//
-// }
--- /dev/null
+/*
+ * 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.commands;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.admin.internal.UiAdminUtils;
+import org.argeo.security.ui.admin.internal.UserAdminConstants;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.osgi.service.useradmin.Group;
+
+/** Deletes the selected groups */
+public class DeleteGroups extends AbstractHandler {
+ public final static String ID = SecurityAdminPlugin.PLUGIN_ID + ".deleteGroups";
+
+
+ @SuppressWarnings("unchecked")
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection.isEmpty())
+ return null;
+
+ Map<String, Group> toDelete = new TreeMap<String, Group>();
+ Iterator<Group> it = ((IStructuredSelection) selection).iterator();
+ groups: while (it.hasNext()) {
+ Group currGroup = it.next();
+ String groupName = UiAdminUtils.getProperty(currGroup,
+ UserAdminConstants.KEY_CN);
+
+ // TODO add checks
+ // if (userName.equals(profileNode.getSession().getUserID())) {
+ // log.warn("Cannot delete its own user: " + userName);
+ // continue groups;
+ // }
+ toDelete.put(groupName, currGroup);
+ }
+
+ if (!MessageDialog
+ .openQuestion(
+ HandlerUtil.getActiveShell(event),
+ "Delete Groups",
+ "Are you sure that you want to delete groups "
+ + toDelete.keySet()
+ + "?\n"
+ + "This might lead to inconsistencies in the application."))
+ return null;
+
+ for (String groupName : toDelete.keySet()) {
+ }
+ MessageDialog.openInformation(HandlerUtil.getActiveShell(event),
+ "Unimplemented method",
+ "The effective deletion is not yet implemented");
+ // TODO refresh?
+ // JcrUsersView view = (JcrUsersView) HandlerUtil
+ // .getActiveWorkbenchWindow(event).getActivePage()
+ // .findView(JcrUsersView.ID);
+ // view.refresh();
+ return null;
+ }
+
+ // public void setUserAdmin(UserAdmin userAdmin) {
+ // this.userAdmin = userAdmin;
+ // }
+}
\ No newline at end of file
+++ /dev/null
-/*
- * 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.commands;
-
-import org.argeo.security.UserAdminService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/** Deletes the selected roles */
-public class DeleteRole extends AbstractHandler {
- private UserAdminService userAdminService;
-
- @SuppressWarnings("unchecked")
- public Object execute(ExecutionEvent event) throws ExecutionException {
- return null;
- }
-
- public void setUserAdminService(UserAdminService userAdminService) {
- this.userAdminService = userAdminService;
- }
-}
-// ISelection selection = HandlerUtil.getCurrentSelection(event);
-// if (selection.isEmpty())
-// return null;
-//
-// List<String> toDelete = new ArrayList<String>();
-// Iterator<String> it = ((IStructuredSelection) selection).iterator();
-// while (it.hasNext()) {
-// toDelete.add(it.next());
-// }
-//
-// if (!MessageDialog
-// .openQuestion(
-// HandlerUtil.getActiveShell(event),
-// "Delete Role",
-// "Are you sure that you want to delete "
-// + toDelete
-// + "?\n"
-// + "This may lead to inconsistencies in the application."))
-// return null;
-//
-// for (String role : toDelete) {
-// userAdminService.deleteRole(role);
-// }
-//
-// JcrRolesView view = (JcrRolesView) HandlerUtil
-// .getActiveWorkbenchWindow(event).getActivePage()
-// .findView(JcrRolesView.ID);
-// view.refresh();
-// return null;
-// }
-//
-// public void setUserAdminService(UserAdminService userAdminService) {
-// this.userAdminService = userAdminService;
-// }
-// }
\ No newline at end of file
+++ /dev/null
-/*
- * 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.commands;
-
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.argeo.ArgeoException;
-import org.argeo.jcr.ArgeoNames;
-import org.argeo.jcr.JcrUtils;
-import org.argeo.security.UserAdminService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-/** Deletes the selected user nodes */
-public class DeleteUser extends AbstractHandler {
- private final static Log log = LogFactory.getLog(DeleteUser.class);
-
- private UserAdminService userAdminService;
-
- @SuppressWarnings("unchecked")
- public Object execute(ExecutionEvent event) throws ExecutionException {
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- if (selection.isEmpty())
- return null;
-
- Map<String, Node> toDelete = new TreeMap<String, Node>();
- Iterator<Node> it = ((IStructuredSelection) selection).iterator();
- nodes: while (it.hasNext()) {
- Node profileNode = it.next();
- try {
- String userName = profileNode.getProperty(
- ArgeoNames.ARGEO_USER_ID).getString();
- if (userName.equals(profileNode.getSession().getUserID())) {
- log.warn("Cannot delete its own user: " + userName);
- continue nodes;
- }
- toDelete.put(userName, profileNode);
- } catch (RepositoryException e) {
- log.warn("Cannot interpred user " + profileNode);
- }
- }
-
- if (!MessageDialog
- .openQuestion(
- HandlerUtil.getActiveShell(event),
- "Delete User",
- "Are you sure that you want to delete users "
- + toDelete.keySet()
- + "?\n"
- + "This may lead to inconsistencies in the application."))
- return null;
-
- for (String username : toDelete.keySet()) {
- Session session = null;
- try {
- Node profileNode = toDelete.get(username);
- userAdminService.deleteUser(username);
- profileNode.getParent().remove();
- session = profileNode.getSession();
- session.save();
- } catch (RepositoryException e) {
- JcrUtils.discardQuietly(session);
- throw new ArgeoException("Cannot list users", e);
- }
- }
-
- userAdminService.synchronize();
- // JcrUsersView view = (JcrUsersView) HandlerUtil
- // .getActiveWorkbenchWindow(event).getActivePage()
- // .findView(JcrUsersView.ID);
- // view.refresh();
- return null;
- }
-
- public void setUserAdminService(UserAdminService userAdminService) {
- this.userAdminService = userAdminService;
- }
-}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.commands;
+
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.argeo.security.ui.admin.internal.UiAdminUtils;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.osgi.service.useradmin.User;
+
+/** Deletes the selected users */
+public class DeleteUsers extends AbstractHandler {
+ public final static String ID = SecurityAdminPlugin.PLUGIN_ID + ".deleteUsers";
+
+ @SuppressWarnings("unchecked")
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection.isEmpty())
+ return null;
+
+ Map<String, User> toDelete = new TreeMap<String, User>();
+ Iterator<User> it = ((IStructuredSelection) selection).iterator();
+ users: while (it.hasNext()) {
+ User currUser = it.next();
+ String userName = UiAdminUtils.getUsername(currUser);
+ // check not deleting own user
+ // if (userName.equals(profileNode.getSession().getUserID())) {
+ // log.warn("Cannot delete its own user: " + userName);
+ // continue nodes;
+ // }
+ toDelete.put(userName, currUser);
+ }
+
+ if (!MessageDialog
+ .openQuestion(
+ HandlerUtil.getActiveShell(event),
+ "Delete Users",
+ "Are you sure that you want to delete users "
+ + toDelete.keySet()
+ + "?\n"
+ + "This might lead to inconsistencies in the application."))
+ return null;
+
+ for (String username : toDelete.keySet()) {
+ // TODO perform real deletion
+ }
+ MessageDialog.openInformation(HandlerUtil.getActiveShell(event),
+ "Unimplemented method",
+ "The effective deletion is not yet implemented");
+ // TODO refresh?
+ // JcrUsersView view = (JcrUsersView) HandlerUtil
+ // .getActiveWorkbenchWindow(event).getActivePage()
+ // .findView(JcrUsersView.ID);
+ // view.refresh();
+ return null;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.commands;
+
+import org.argeo.security.ui.admin.views.GroupsView;
+import org.argeo.security.ui.admin.views.UsersView;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+/** Retrieve the active view or editor and call forceRefresh method if defined */
+public class ForceRefresh extends AbstractHandler {
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ IWorkbenchWindow iww = HandlerUtil.getActiveWorkbenchWindow(event);
+ if (iww == null)
+ return null;
+ IWorkbenchPage activePage = iww.getActivePage();
+ IWorkbenchPart part = activePage.getActivePart();
+ if (part instanceof UsersView)
+ ((UsersView) part).refresh();
+ else if (part instanceof GroupsView)
+ ((GroupsView) part).refresh();
+ return null;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.commands;
+
+import org.argeo.security.ui.admin.SecurityAdminPlugin;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.osgi.service.useradmin.UserAdmin;
+
+/** Create a new group. */
+public class NewGroup extends AbstractHandler {
+ public final static String ID = SecurityAdminPlugin.PLUGIN_ID + ".newGroup";
+
+ private UserAdmin userAdmin;
+
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+
+ MessageDialog
+ .openError(HandlerUtil.getActiveShell(event),
+ "Unimplemented method",
+ "Group creation is not yet implemented");
+ return null;
+ }
+
+ /* DEPENDENCY INJECTION */
+ public void setUserAdmin(UserAdmin userAdmin) {
+ this.userAdmin = userAdmin;
+ }
+}
+
+// JcrRolesView rolesView = (JcrRolesView) HandlerUtil
+// .getActiveWorkbenchWindow(event).getActivePage()
+// .findView(JcrRolesView.ID);
+// String role = rolesView.getNewRole();
+// if (role.trim().equals(""))
+// return null;
+// if (role.equals(rolesView.getAddNewRoleText()))
+// return null;
+// role = role.trim().toUpperCase();
+// if (!role.startsWith(rolePrefix))
+// role = rolePrefix + role;
+// if (userAdminService.listEditableRoles().contains(role))
+// throw new ArgeoException("Role " + role + " already exists");
+// userAdminService.newRole(role);
+// rolesView.refresh();
+//
+// // refresh editors
+// IEditorReference[] refs = HandlerUtil.getActiveWorkbenchWindow(event)
+// .getActivePage()
+// .findEditors(null, JcrArgeoUserEditor.ID, IWorkbenchPage.MATCH_ID);
+// for (IEditorReference ref : refs) {
+// JcrArgeoUserEditor userEditor = (JcrArgeoUserEditor) ref.getEditor(false);
+// if (userEditor != null) {
+// userEditor.refresh();
+// }
+// }
+// return null;
+// }
+//
+// public void setUserAdminService(UserAdminService userAdminService) {
+// this.userAdminService = userAdminService;
+// }
+//
+// }
((UsersView) part).refresh();
}
- public void setUserAdmin(UserAdmin userAdmin) {
- this.userAdmin = userAdmin;
- }
-
private class NewUserWizard extends Wizard {
// pages
public void addPages() {
mainUserInfo = new MainUserInfoWizardPage();
addPage(mainUserInfo);
- String message = "Dummy wizard to ease user creation tests: mail, last name are automatically "
- + "generated form the uid, password are defauted to 'demo'.";
+ String message = "Dummy wizard to ease user creation tests:\n Mail and last name are automatically "
+ + "generated form the uid. Password are defauted to 'demo'.";
mainUserInfo.setMessage(message, WizardPage.WARNING);
}
}
}
-
- // Local helpers
-
+
+ /* DEPENDENCY INJECTION */
+ public void setUserAdmin(UserAdmin userAdmin) {
+ this.userAdmin = userAdmin;
+ }
}
\ No newline at end of file
+++ /dev/null
-/*
- * 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.commands;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/** Command handler to set visible or open a Argeo user. */
-public class OpenArgeoUserEditor extends AbstractHandler {
- public final static String COMMAND_ID = "org.argeo.security.ui.admin.openArgeoUserEditor";
- public final static String PARAM_USERNAME = "org.argeo.security.ui.admin.username";
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- // try {
- // ArgeoUserEditorInput editorInput = new ArgeoUserEditorInput(
- // event.getParameter(PARAM_USERNAME));
- // IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(
- // event).getActivePage();
- // activePage.openEditor(editorInput, JcrArgeoUserEditor.ID);
- // } catch (Exception e) {
- // throw new ExecutionException("Cannot open editor", e);
- // }
- return null;
- }
-}
+++ /dev/null
-/*
- * 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.commands;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/**
- * Refreshes the roles view.
- */
-public class RefreshRoles extends AbstractHandler {
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- return null;
- }
-
-}
\ No newline at end of file
+++ /dev/null
-/*
- * 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.commands;
-
-import javax.jcr.Repository;
-
-import org.argeo.security.UserAdminService;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-
-/**
- * Refreshes the main user list, removing nodes which are not referenced by user
- * admin service.
- */
-public class RefreshUsersList extends AbstractHandler {
- private UserAdminService userAdminService;
- private Repository repository;
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- // Set<String> users = userAdminService.listUsers();
- // Session session = null;
- // try {
- // session = repository.login();
- // Query query = session
- // .getWorkspace()
- // .getQueryManager()
- // .createQuery(
- // "select * from [" + ArgeoTypes.ARGEO_USER_HOME
- // + "]", Query.JCR_SQL2);
- // NodeIterator nit = query.execute().getNodes();
- // while (nit.hasNext()) {
- // Node node = nit.nextNode();
- // String username = node.getProperty(ArgeoNames.ARGEO_USER_ID)
- // .getString();
- // if (!users.contains(username))
- // node.remove();
- // }
- // session.save();
- // } catch (RepositoryException e) {
- // JcrUtils.discardQuietly(session);
- // throw new ArgeoException("Cannot list users", e);
- // } finally {
- // JcrUtils.logoutQuietly(session);
- // }
- // userAdminService.synchronize();
- //
- // // FIXME try to refresh views that extend the JcrUsersView and have
- // another
- // // ID
- // IWorkbenchPart part = HandlerUtil.getActiveWorkbenchWindow(event)
- // .getActivePage().getActivePart();
- // if (part instanceof JcrUsersView)
- // ((JcrUsersView) part).refresh();
- //
- // // Try to refresh JcrUsersView if opened
- // JcrUsersView view = (JcrUsersView) HandlerUtil
- // .getActiveWorkbenchWindow(event).getActivePage()
- // .findView(JcrUsersView.ID);
- // if (view != null)
- // view.refresh();
-
- return null;
- }
-
- public void setUserAdminService(UserAdminService userAdminService) {
- this.userAdminService = userAdminService;
- }
-
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-
-}
\ No newline at end of file
*/
package org.argeo.security.ui.admin.commands;
+import org.argeo.security.ui.admin.SecurityAdminPlugin;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
/** Save the currently edited Argeo user. */
public class SaveArgeoUser extends AbstractHandler {
- public final static String COMMAND_ID = "org.argeo.security.ui.admin.saveArgeoUser";
+ public final static String ID = SecurityAdminPlugin.PLUGIN_ID
+ + ".saveArgeoUser";
public Object execute(ExecutionEvent event) throws ExecutionException {
try {
}
return null;
}
-
-}
+}
\ No newline at end of file
*/
package org.argeo.security.ui.admin.commands;
-import javax.jcr.Repository;
-import javax.jcr.Session;
-
-import org.argeo.jcr.JcrUtils;
-import org.argeo.security.UserAdminService;
-import org.argeo.security.ui.admin.wizards.UserBatchUpdateWizard;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.wizard.WizardDialog;
-import org.eclipse.ui.handlers.HandlerUtil;
/** Launch a wizard to update various properties about users in JCR. */
public class UserBatchUpdate extends AbstractHandler {
- private Repository repository;
- private UserAdminService userAdminService;
+ // private Repository repository;
+ // private UserAdminService userAdminService;
public Object execute(ExecutionEvent event) throws ExecutionException {
- Session session = null;
- try {
- session = repository.login();
- UserBatchUpdateWizard userBatchUpdateWizard = new UserBatchUpdateWizard(
- session, userAdminService);
- WizardDialog dialog = new WizardDialog(
- HandlerUtil.getActiveShell(event), userBatchUpdateWizard);
- dialog.open();
- } catch (Exception e) {
- throw new ExecutionException("Cannot open wizard", e);
- } finally {
- JcrUtils.logoutQuietly(session);
- }
+ // Session session = null;
+ // try {
+ // session = repository.login();
+ // UserBatchUpdateWizard userBatchUpdateWizard = new
+ // UserBatchUpdateWizard(
+ // session, userAdminService);
+ // WizardDialog dialog = new WizardDialog(
+ // HandlerUtil.getActiveShell(event), userBatchUpdateWizard);
+ // dialog.open();
+ // } catch (Exception e) {
+ // throw new ExecutionException("Cannot open wizard", e);
+ // } finally {
+ // JcrUtils.logoutQuietly(session);
+ // }
return null;
}
- public void setRepository(Repository repository) {
- this.repository = repository;
- }
-
- public void setUserAdminService(UserAdminService userAdminService) {
- this.userAdminService = userAdminService;
- }
+// public void setRepository(Repository repository) {
+// this.repository = repository;
+// }
+ //
+ // public void setUserAdminService(UserAdminService userAdminService) {
+ // this.userAdminService = userAdminService;
+ // }
// public void setJcrSecurityModel(JcrSecurityModel jcrSecurityModel) {
// this.jcrSecurityModel = jcrSecurityModel;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
-/**
- * Display/edit the properties common to all Argeo users
- */
+/** Display/edit the properties common to all Argeo users */
public class DefaultUserMainPage extends FormPage implements ArgeoNames {
final static String ID = "argeoUserEditor.mainPage";
+++ /dev/null
-/*
- * 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.editors;
-
-public class JcrArgeoUserEditor{}
-/** Editor for an Argeo user. Legacy. TODO Remove*/
-// public class JcrArgeoUserEditor extends FormEditor {
-// private static final long serialVersionUID = 1933296330339252869L;
-//
-// public final static String ID = SecurityAdminPlugin.PLUGIN_ID
-// + ".adminArgeoUserEditor";
-//
-// /* DEPENDENCY INJECTION */
-// private Session session;
-// private UserAdminService userAdminService;
-//
-// // private Node userHome;
-// private Node userProfile;
-// private JcrUserDetails userDetails;
-//
-// public void init(IEditorSite site, IEditorInput input)
-// throws PartInitException {
-// super.init(site, input);
-// String username = ((ArgeoUserEditorInput) getEditorInput())
-// .getUsername();
-// userProfile = UserJcrUtils.getUserProfile(session, username);
-//
-// if (userAdminService.userExists(username)) {
-// try {
-// userDetails = (JcrUserDetails) userAdminService
-// .loadUserByUsername(username);
-// } catch (Exception e) {
-// throw new ArgeoException("Cannot retrieve userDetails for "
-// + username, e);
-// }
-// } else {
-// try {
-// userDetails = new JcrUserDetails(session, username, null,
-// new ArrayList<GrantedAuthority>());
-// } catch (RepositoryException e) {
-// throw new ArgeoException("Cannot retrieve disabled JCR profile");
-// }
-// }
-//
-// this.setPartProperty("name", username != null ? username : "<new user>");
-// setPartName(username != null ? username : "<new user>");
-// }
-//
-// protected void addPages() {
-// try {
-// addPage(new DefaultUserMainPage(this, userProfile));
-// addPage(new UserRolesPage(this, userDetails, userAdminService));
-// } catch (Exception e) {
-// throw new ArgeoException("Cannot add pages", e);
-// }
-// }
-//
-// @Override
-// public void doSave(IProgressMonitor monitor) {
-// // list pages
-// // TODO: make it more generic
-// DefaultUserMainPage defaultUserMainPage = (DefaultUserMainPage)
-// findPage(DefaultUserMainPage.ID);
-// if (defaultUserMainPage.isDirty()) {
-// defaultUserMainPage.doSave(monitor);
-// String newPassword = defaultUserMainPage.getNewPassword();
-// defaultUserMainPage.resetNewPassword();
-// if (newPassword != null)
-// userDetails = userDetails.cloneWithNewPassword(newPassword);
-// }
-//
-// UserRolesPage userRolesPage = (UserRolesPage) findPage(UserRolesPage.ID);
-// if (userRolesPage.isDirty()) {
-// userRolesPage.doSave(monitor);
-// userDetails = userDetails.cloneWithNewRoles(userRolesPage
-// .getRoles());
-// }
-//
-// userAdminService.updateUser(userDetails);
-//
-// // if (userAdminService.userExists(user.getUsername()))
-// // userAdminService.updateUser(user);
-// // else {
-// // userAdminService.newUser(user);
-// // setPartName(user.getUsername());
-// // }
-// firePropertyChange(PROP_DIRTY);
-//
-// userRolesPage.setUserDetails(userDetails);
-//
-// // FIXME rather use a refresh command. Fails when called by another
-// // view.
-// // refresh users view
-// IWorkbench iw = SecurityAdminPlugin.getDefault().getWorkbench();
-// JcrUsersView usersView = (JcrUsersView) iw.getActiveWorkbenchWindow()
-// .getActivePage().findView(JcrUsersView.ID);
-// if (usersView != null)
-// usersView.refresh();
-// }
-//
-//
-//
-// @Override
-// public void doSaveAs() {
-// }
-//
-// @Override
-// public boolean isSaveAsAllowed() {
-// return false;
-// }
-//
-// public void refresh() {
-// UserRolesPage userRolesPage = (UserRolesPage) findPage(UserRolesPage.ID);
-// userRolesPage.refresh();
-// }
-//
-// @Override
-// public void dispose() {
-// JcrUtils.logoutQuietly(session);
-// super.dispose();
-// }
-//
-// /* DEPENDENCY INJECTION */
-// public void setUserAdminService(UserAdminService userAdminService) {
-// this.userAdminService = userAdminService;
-// }
-//
-// public void setRepository(Repository repository) {
-// try {
-// session = repository.login();
-// } catch (RepositoryException re) {
-// throw new ArgeoException("Unable to initialise local session", re);
-// }
-// }
-// }
protected void addPages() {
try {
-
if (user.getType() == Role.GROUP)
addPage(new GroupMainPage(this, userAdmin));
else
addPage(new UserMainPage(this, userAdmin));
-
} catch (Exception e) {
throw new ArgeoException("Cannot add pages", e);
}
import javax.security.auth.Subject;
import javax.security.auth.x500.X500Principal;
+import org.osgi.service.useradmin.Role;
+import org.osgi.service.useradmin.User;
+
/** First effort to centralize back end methods used by the user admin UI */
public class UiAdminUtils {
public final static String getUsername() {
}
+ public final static String getUsername(User user) {
+ String cn = getProperty(user, UserAdminConstants.KEY_CN);
+ if (isEmpty(cn))
+ cn = getProperty(user, UserAdminConstants.KEY_UID);
+ return cn;
+ }
+
+ public final static String getProperty(Role role, String key) {
+ Object obj = role.getProperties().get(key);
+ if (obj != null)
+ return (String) obj;
+ else
+ return "";
+ }
+
public final static String getDefaultCn(String firstName, String lastName) {
return (firstName.trim() + " " + lastName.trim() + " ").trim();
}
return !"".equals(string.trim());
}
+ public final static boolean isEmpty(String string) {
+ if (string == null)
+ return true;
+ else
+ return "".equals(string.trim());
+ }
+
}
\ No newline at end of file
private UserAdmin userAdmin;
// UI Objects
- private UserTableViewer userTableViewerCmp;
+ private UserTableViewer groupTableViewerCmp;
private TableViewer userViewer;
private List<ColumnDefinition> columnDefs = new ArrayList<ColumnDefinition>();
"Distinguished Name", 300));
// Create and configure the table
- userTableViewerCmp = new MyUserTableViewer(parent, SWT.MULTI
+ groupTableViewerCmp = new MyUserTableViewer(parent, SWT.MULTI
| SWT.H_SCROLL | SWT.V_SCROLL, userAdmin);
- userTableViewerCmp.setColumnDefinitions(columnDefs);
- userTableViewerCmp.populate(true, false);
- userTableViewerCmp.setLayoutData(EclipseUiUtils.fillAll());
+ groupTableViewerCmp.setColumnDefinitions(columnDefs);
+ groupTableViewerCmp.populate(true, false);
+ groupTableViewerCmp.setLayoutData(EclipseUiUtils.fillAll());
// Links
- userViewer = userTableViewerCmp.getTableViewer();
+ userViewer = groupTableViewerCmp.getTableViewer();
userViewer.addDoubleClickListener(new UserTableDefaultDClickListener());
getViewSite().setSelectionProvider(userViewer);
// Really?
- userTableViewerCmp.refresh();
+ groupTableViewerCmp.refresh();
}
private class MyUserTableViewer extends UserTableViewer {
}
}
+ public void refresh() {
+ groupTableViewerCmp.refresh();
+ }
+
+
// Override generic view methods
@Override
public void dispose() {
@Override
public void setFocus() {
- userTableViewerCmp.setFocus();
+ groupTableViewerCmp.setFocus();
}
/* DEPENDENCY INJECTION */