Search in sources :

Example 11 with SecurityManager

use of org.exist.security.SecurityManager in project exist by eXist-db.

the class LocalUserManagementService method removeGroupMember.

@Override
public void removeGroupMember(final String group, final String member) throws XMLDBException {
    withDb((broker, transaction) -> {
        final SecurityManager sm = broker.getBrokerPool().getSecurityManager();
        final Account account = sm.getAccount(member);
        account.remGroup(group);
        sm.updateAccount(account);
        return null;
    });
}
Also used : SecurityManager(org.exist.security.SecurityManager)

Example 12 with SecurityManager

use of org.exist.security.SecurityManager in project exist by eXist-db.

the class LocalUserManagementService method removeGroup.

@Override
public void removeGroup(final Group group) throws XMLDBException {
    withDb((broker, transaction) -> {
        final SecurityManager sm = broker.getBrokerPool().getSecurityManager();
        sm.deleteGroup(group.getName());
        return null;
    });
}
Also used : SecurityManager(org.exist.security.SecurityManager)

Example 13 with SecurityManager

use of org.exist.security.SecurityManager in project exist by eXist-db.

the class LocalUserManagementService method updateAccount.

@Override
public void updateAccount(final Account u) throws XMLDBException {
    withDb((broker, transaction) -> {
        final SecurityManager sm = broker.getBrokerPool().getSecurityManager();
        sm.updateAccount(u);
        return null;
    });
}
Also used : SecurityManager(org.exist.security.SecurityManager)

Example 14 with SecurityManager

use of org.exist.security.SecurityManager in project exist by eXist-db.

the class LocalUserManagementService method lockResource.

@Override
public void lockResource(final Resource resource, final Account u) throws XMLDBException {
    modify(resource).apply((document, broker, transaction) -> {
        final String resourceId = resource.getId();
        if (!document.getPermissions().validate(user, Permission.WRITE)) {
            throw new PermissionDeniedException("User is not allowed to lock resource " + resourceId);
        }
        final SecurityManager manager = broker.getBrokerPool().getSecurityManager();
        if (!(user.equals(u) || manager.hasAdminPrivileges(user))) {
            throw new PermissionDeniedException("User " + user.getName() + " is not allowed to lock resource '" + resourceId + "' for user " + u.getName());
        }
        final Account lockOwner = document.getUserLock();
        if (lockOwner != null) {
            if (lockOwner.equals(u)) {
                return null;
            } else if (!manager.hasAdminPrivileges(user)) {
                throw new PermissionDeniedException("Resource '" + resourceId + "' is already locked by user " + lockOwner.getName());
            }
        }
        document.setUserLock(u);
        return null;
    });
}
Also used : SecurityManager(org.exist.security.SecurityManager)

Example 15 with SecurityManager

use of org.exist.security.SecurityManager in project exist by eXist-db.

the class LocalUserManagementService method getGroups.

@Override
public String[] getGroups() throws XMLDBException {
    return withDb((broker, transaction) -> {
        final SecurityManager sm = broker.getBrokerPool().getSecurityManager();
        final java.util.Collection<Group> groups = sm.getGroups();
        final String[] groupNames = new String[groups.size()];
        int i = 0;
        for (final Group group : groups) {
            groupNames[i++] = group.getName();
        }
        return groupNames;
    });
}
Also used : SecurityManager(org.exist.security.SecurityManager) java.util(java.util)

Aggregations

SecurityManager (org.exist.security.SecurityManager)68 DBBroker (org.exist.storage.DBBroker)22 Txn (org.exist.storage.txn.Txn)16 Account (org.exist.security.Account)15 BrokerPool (org.exist.storage.BrokerPool)15 Subject (org.exist.security.Subject)12 EXistException (org.exist.EXistException)11 PermissionDeniedException (org.exist.security.PermissionDeniedException)9 XPathException (org.exist.xquery.XPathException)9 AuthenticationException (org.exist.security.AuthenticationException)8 GroupAider (org.exist.security.internal.aider.GroupAider)6 Collection (org.exist.collections.Collection)5 Group (org.exist.security.Group)5 Database (org.exist.Database)4 UserAider (org.exist.security.internal.aider.UserAider)4 LockedDocumentMap (org.exist.storage.lock.LockedDocumentMap)4 Test (org.junit.Test)4 java.util (java.util)2 List (java.util.List)2 HttpSession (javax.servlet.http.HttpSession)2