use of org.exist.security.internal.aider.UserAider in project exist by eXist-db.
the class RemoteUserManagementService method getAccount.
@Override
public Account getAccount(final String name) throws XMLDBException {
try {
final List<Object> params = new ArrayList<>();
params.add(name);
final Map tab = (Map) collection.execute("getAccount", params);
if (tab == null || tab.isEmpty()) {
return null;
}
final UserAider u;
if (tab.get("default-group-id") != null) {
final GroupAider defaultGroup = new GroupAider((Integer) tab.get("default-group-id"), (String) tab.get("default-group-realmId"), (String) tab.get("default-group-name"));
u = new UserAider((String) tab.get("realmId"), (String) tab.get("name"), defaultGroup);
} else {
u = new UserAider((String) tab.get("realmId"), (String) tab.get("name"));
}
final Object[] groups = (Object[]) tab.get("groups");
for (final Object group : groups) {
u.addGroup((String) group);
}
u.setEnabled(Boolean.parseBoolean((String) tab.get("enabled")));
u.setUserMask((Integer) tab.get("umask"));
final Map<String, String> metadata = (Map<String, String>) tab.get("metadata");
for (final Map.Entry<String, String> m : metadata.entrySet()) {
if (AXSchemaType.valueOfNamespace(m.getKey()) != null) {
u.setMetadataValue(AXSchemaType.valueOfNamespace(m.getKey()), m.getValue());
} else if (EXistSchemaType.valueOfNamespace(m.getKey()) != null) {
u.setMetadataValue(EXistSchemaType.valueOfNamespace(m.getKey()), m.getValue());
}
}
return u;
} catch (final XMLDBException e) {
return null;
}
}
use of org.exist.security.internal.aider.UserAider in project exist by eXist-db.
the class RemoteUserManagementService method addUser.
@Override
public void addUser(final User user) throws XMLDBException {
final Account account = new UserAider(user.getName());
addAccount(account);
}
use of org.exist.security.internal.aider.UserAider in project exist by eXist-db.
the class RemoteUserManagementService method updateUser.
@Override
public void updateUser(final User user) throws XMLDBException {
final Account account = new UserAider(user.getName());
account.setPassword(user.getPassword());
// TODO: groups
updateAccount(account);
}
Aggregations