Search in sources :

Example 16 with Group

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;
        }
    }
}
Also used : Group(org.exist.security.Group) AuthenticationException(org.exist.security.AuthenticationException) SearchResult(javax.naming.directory.SearchResult) NamingException(javax.naming.NamingException)

Example 17 with Group

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);
        }
    }
}
Also used : Group(org.exist.security.Group) XMLDBException(org.xmldb.api.base.XMLDBException)

Example 18 with Group

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);
    }
}
Also used : Group(org.exist.security.Group) XMLDBException(org.xmldb.api.base.XMLDBException)

Example 19 with Group

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();
}
Also used : Group(org.exist.security.Group) XMLDBException(org.xmldb.api.base.XMLDBException) GroupAider(org.exist.security.internal.aider.GroupAider)

Example 20 with Group

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;
}
Also used : Group(org.exist.security.Group)

Aggregations

Group (org.exist.security.Group)23 Account (org.exist.security.Account)9 PermissionDeniedException (org.exist.security.PermissionDeniedException)9 AuthenticationException (org.exist.security.AuthenticationException)6 SecurityManager (org.exist.security.SecurityManager)6 XMLDBException (org.xmldb.api.base.XMLDBException)6 EXistException (org.exist.EXistException)5 NamingException (javax.naming.NamingException)4 AXSchemaType (org.exist.security.AXSchemaType)4 SchemaType (org.exist.security.SchemaType)4 GroupAider (org.exist.security.internal.aider.GroupAider)4 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 SearchResult (javax.naming.directory.SearchResult)2 LdapContext (javax.naming.ldap.LdapContext)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 ConfigurationException (org.exist.config.ConfigurationException)2 AbstractAccount (org.exist.security.AbstractAccount)2 Permission (org.exist.security.Permission)2 Subject (org.exist.security.Subject)2