Search in sources :

Example 26 with UserAider

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

Example 27 with UserAider

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);
}
Also used : Account(org.exist.security.Account) UserAider(org.exist.security.internal.aider.UserAider)

Example 28 with UserAider

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);
}
Also used : Account(org.exist.security.Account) UserAider(org.exist.security.internal.aider.UserAider)

Aggregations

UserAider (org.exist.security.internal.aider.UserAider)28 GroupAider (org.exist.security.internal.aider.GroupAider)15 UserManagementService (org.exist.xmldb.UserManagementService)9 Account (org.exist.security.Account)5 XMLDBException (org.xmldb.api.base.XMLDBException)5 EXistException (org.exist.EXistException)4 PermissionDeniedException (org.exist.security.PermissionDeniedException)4 SecurityManager (org.exist.security.SecurityManager)4 DBBroker (org.exist.storage.DBBroker)4 Test (org.junit.Test)4 Collection (org.xmldb.api.base.Collection)4 IOException (java.io.IOException)2 NamingException (javax.naming.NamingException)2 AbstractAccount (org.exist.security.AbstractAccount)2 AuthenticationException (org.exist.security.AuthenticationException)2 LockedDocumentMap (org.exist.storage.lock.LockedDocumentMap)2 EXistCollectionManagementService (org.exist.xmldb.EXistCollectionManagementService)2 Before (org.junit.Before)2 BinaryResource (org.xmldb.api.modules.BinaryResource)2 Either (com.evolvedbinary.j8fu.Either)1