use of org.exist.security.Account in project exist by eXist-db.
the class EditGroupDialog method setGroupFromFormProperties.
private void setGroupFromFormProperties() throws PermissionDeniedException, XMLDBException {
getGroup().setMetadataValue(EXistSchemaType.DESCRIPTION, txtDescription.getText());
// set managers
// 1) remove all managers
final List<Account> currentManagers = getGroup().getManagers();
for (final Account currentManager : currentManagers) {
getUserManagementService().removeGroupManager(group.getName(), currentManager.getName());
}
// 2) only add those in this dialog
for (int i = 0; i < getGroupMembersTableModel().getRowCount(); i++) {
final boolean isManager = (Boolean) getGroupMembersTableModel().getValueAt(i, 1);
if (isManager) {
final String manager = (String) getGroupMembersTableModel().getValueAt(i, 0);
getUserManagementService().addGroupManager(manager, getGroup().getName());
}
}
}
use of org.exist.security.Account in project exist by eXist-db.
the class UserManagerDialog method refreshUsersTableModel.
public void refreshUsersTableModel() {
final int rowCount = usersTableModel.getRowCount();
for (int i = 0; i < rowCount; i++) {
usersTableModel.removeRow(0);
}
try {
final Account[] accounts = userManagementService.getAccounts();
Arrays.sort(accounts, new AccountComparator());
for (Account account : accounts) {
usersTableModel.addRow(new String[] { account.getName(), account.getMetadataValue(AXSchemaType.FULLNAME), account.getMetadataValue(EXistSchemaType.DESCRIPTION) });
}
} catch (final XMLDBException xmldbe) {
JOptionPane.showMessageDialog(this, "Could not get users list: " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
}
}
use of org.exist.security.Account in project exist by eXist-db.
the class UserManagerDialog method showEditUserDialog.
private void showEditUserDialog(final Account account) {
final UserManagerDialog that = this;
final DialogCompleteWithResponse<String> callback = response -> {
// get client to reconnect with edited users new password
try {
System.out.println("Detected logged-in user password change, reconnecting to server...");
that.userManagementService = reconnectClientAndUserManager(response);
System.out.println("Reconnected.");
} catch (final XMLDBException xmldbe) {
JOptionPane.showMessageDialog(that, "Could not edit user '" + getSelectedUsername() + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
}
};
final EditUserDialog userDialog = new EditUserDialog(userManagementService, account);
if (getSelectedUsername().equals(currentUser)) {
// register for password update event, if we are changing the password
// of the current user
userDialog.addDialogCompleteWithResponseCallback(callback);
}
userDialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(final WindowEvent e) {
refreshUsersTableModel();
}
});
userDialog.setVisible(true);
}
use of org.exist.security.Account in project exist by eXist-db.
the class UserManagerDialog method tblUsersMouseClicked.
// GEN-LAST:event_btnCreateActionPerformed
private void tblUsersMouseClicked(java.awt.event.MouseEvent evt) {
// GEN-FIRST:event_tblUsersMouseClicked
final boolean userSelected = tblUsers.getSelectedRow() > -1;
final String selectedUsername = getSelectedUsername();
boolean canModify = userSelected && !selectedUsername.equals(SecurityManager.SYSTEM);
boolean canDelete = userSelected && !(selectedUsername.equals(SecurityManager.SYSTEM) || selectedUsername.equals(SecurityManager.DBA_USER) || selectedUsername.equals(SecurityManager.GUEST_USER));
miEditUser.setEnabled(canModify);
miRemoveUser.setEnabled(canDelete);
if (evt.getClickCount() == 2 && canModify) {
try {
final Account account = userManagementService.getAccount(selectedUsername);
showEditUserDialog(account);
} catch (final XMLDBException xmldbe) {
JOptionPane.showMessageDialog(this, "Could not edit user '" + selectedUsername + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
}
}
}
use of org.exist.security.Account in project exist by eXist-db.
the class UserManagerDialog method miEditUserActionPerformed.
// GEN-LAST:event_miRemoveUserActionPerformed
private void miEditUserActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_miEditUserActionPerformed
final String selectedUsername = getSelectedUsername();
try {
final Account account = userManagementService.getAccount(selectedUsername);
showEditUserDialog(account);
} catch (final XMLDBException xmldbe) {
JOptionPane.showMessageDialog(this, "Could not edit user '" + selectedUsername + "': " + xmldbe.getMessage(), "User Manager Error", JOptionPane.ERROR_MESSAGE);
}
}
Aggregations