use of org.exist.security.Group in project exist by eXist-db.
the class LDAPRealm method getGroup.
private synchronized Group getGroup(final LdapContext ctx, final DBBroker broker, final String name) {
if (name == null) {
return null;
}
final String gName = ensureCase(name);
final Group grp = getGroup(gName);
if (grp != null) {
return grp;
} else {
// if the group is not cached, we should try and find it in LDAP and cache it if it exists
try {
// do the lookup
final SearchResult ldapGroup = findGroupByGroupName(ctx, removeDomainPostfix(gName));
if (ldapGroup == null) {
return null;
} else {
// found a group from ldap so cache them and return
try {
return createGroupInDatabase(broker, gName);
// registerGroup(grp); //TODO do we need to do this?
} catch (final AuthenticationException ae) {
LOG.error(ae.getMessage(), ae);
return null;
}
}
} catch (final NamingException ne) {
LOG.error(new AuthenticationException(AuthenticationException.UNNOWN_EXCEPTION, ne.getMessage()));
return null;
}
}
}
use of org.exist.security.Group in project exist by eXist-db.
the class UserManagerDialog method tblGroupsMouseClicked.
// GEN-LAST:event_miRemoveGroupActionPerformed
private void tblGroupsMouseClicked(java.awt.event.MouseEvent evt) {
// GEN-FIRST:event_tblGroupsMouseClicked
final boolean groupSelected = tblGroups.getSelectedRow() > -1;
final String selectedGroup = getSelectedGroup();
boolean canDelete = groupSelected && !(selectedGroup.equals(SecurityManager.DBA_GROUP) || selectedGroup.equals(SecurityManager.GUEST_GROUP));
miRemoveGroup.setEnabled(canDelete);
if (evt.getClickCount() == 2) {
try {
final Group group = userManagementService.getGroup(selectedGroup);
showEditGroupDialog(group);
} catch (final XMLDBException xmldbe) {
JOptionPane.showMessageDialog(this, "Could not edit group '" + selectedGroup + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
}
}
}
use of org.exist.security.Group in project exist by eXist-db.
the class UserManagerDialog method miRemoveGroupActionPerformed.
// GEN-LAST:event_miEditGroupActionPerformed
private void miRemoveGroupActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_miRemoveGroupActionPerformed
final String selectedGroup = getSelectedGroup();
try {
final Group group = userManagementService.getGroup(selectedGroup);
userManagementService.removeGroup(group);
groupsTableModel.removeRow(tblGroups.getSelectedRow());
} catch (final XMLDBException xmldbe) {
JOptionPane.showMessageDialog(this, "Could not remove group '" + selectedGroup + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
}
}
use of org.exist.security.Group in project exist by eXist-db.
the class GroupDialog method createGroup.
// GEN-LAST:event_btnCreateActionPerformed
protected void createGroup() {
// 1 - create the group
Group group = null;
try {
final GroupAider groupAider = new GroupAider(txtGroupName.getText());
groupAider.setMetadataValue(EXistSchemaType.DESCRIPTION, txtDescription.getText());
getUserManagementService().addGroup(groupAider);
// get the created group
group = getUserManagementService().getGroup(txtGroupName.getText());
} catch (final XMLDBException xmldbe) {
JOptionPane.showMessageDialog(this, "Could not create group '" + txtGroupName.getText() + "': " + xmldbe.getMessage(), "Create Group Error", JOptionPane.ERROR_MESSAGE);
return;
}
// 2 - add the users to the group and set managers
for (int i = 0; i < getGroupMembersTableModel().getRowCount(); i++) {
final String member = (String) getGroupMembersTableModel().getValueAt(i, 0);
try {
getUserManagementService().addAccountToGroup(member, group.getName());
final boolean isManager = (Boolean) getGroupMembersTableModel().getValueAt(i, 1);
if (isManager) {
getUserManagementService().addGroupManager(member, group.getName());
}
} catch (final XMLDBException xmldbe) {
JOptionPane.showMessageDialog(this, "Could not add user '" + member + "' to group '" + group.getName() + "': " + xmldbe.getMessage(), "Create Group Error", JOptionPane.ERROR_MESSAGE);
return;
}
}
setVisible(false);
dispose();
}
use of org.exist.security.Group in project exist by eXist-db.
the class UserAider method addGroup.
@Override
public Group addGroup(final String name) {
final Group group = new GroupAider(realmId, name);
groups.put(name, group);
return group;
}
Aggregations