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;
});
}
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;
});
}
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;
});
}
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;
});
}
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;
});
}
Aggregations