use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XmldbApiSecurityTest method removeAccount.
@Override
protected void removeAccount(final String account_uid, final String uid, final String pwd) throws ApiException {
Collection col = null;
try {
col = DatabaseManager.getCollection(getBaseUri() + "/db", uid, pwd);
final UserManagementService ums = (UserManagementService) col.getService("UserManagementService", "1.0");
final Account acct = ums.getAccount(account_uid);
if (acct != null) {
ums.removeAccount(acct);
}
} catch (final XMLDBException xmldbe) {
throw new ApiException(xmldbe);
} finally {
if (col != null) {
try {
col.close();
} catch (final XMLDBException xmldbe) {
throw new ApiException(xmldbe);
}
}
}
}
use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XmldbApiSecurityTest method chmodRes.
@Override
protected void chmodRes(final String resourceUri, final String mode, final String uid, final String pwd) throws ApiException {
Collection col = null;
try {
col = DatabaseManager.getCollection(getBaseUri() + getCollectionUri(resourceUri), uid, pwd);
final Resource resource = col.getResource(getResourceName(resourceUri));
final UserManagementService ums = (UserManagementService) col.getService("UserManagementService", "1.0");
ums.chmod(resource, mode);
} catch (final XMLDBException xmldbe) {
throw new ApiException(xmldbe);
} finally {
if (col != null) {
try {
col.close();
} catch (final XMLDBException xmldbe) {
throw new ApiException(xmldbe);
}
}
}
}
use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XmldbApiSecurityTest method removeGroup.
@Override
protected void removeGroup(String group_uid, String uid, String pwd) throws ApiException {
Collection col = null;
try {
col = DatabaseManager.getCollection(getBaseUri() + "/db", uid, pwd);
final UserManagementService ums = (UserManagementService) col.getService("UserManagementService", "1.0");
final Group grp = ums.getGroup(group_uid);
if (grp != null) {
ums.removeGroup(grp);
}
} catch (final XMLDBException xmldbe) {
throw new ApiException(xmldbe);
} finally {
if (col != null) {
try {
col.close();
} catch (final XMLDBException xmldbe) {
throw new ApiException(xmldbe);
}
}
}
}
use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class BackupRestoreSecurityPrincipalsTest method createUser.
private void createUser(final String username, final String password) throws XMLDBException, PermissionDeniedException {
final UserManagementService ums = (UserManagementService) server.getRoot().getService("UserManagementService", "1.0");
final Account user = new UserAider(username);
user.setPassword(password);
// create the personal group
final Group group = new GroupAider(username);
group.setMetadataValue(EXistSchemaType.DESCRIPTION, "Personal group for " + username);
group.addManager(ums.getAccount("admin"));
ums.addGroup(group);
// add the personal group as the primary group
user.addGroup(username);
// create the account
ums.addAccount(user);
// add the new account as a manager of their personal group
ums.addGroupManager(username, group.getName());
}
use of org.exist.xmldb.UserManagementService in project exist by eXist-db.
the class XmldbApiSecurityTest method chownCol.
@Override
protected void chownCol(final String collectionUri, final String owner_uid, final String group_gid, final String uid, final String pwd) throws ApiException {
Collection col = null;
try {
col = DatabaseManager.getCollection(getBaseUri() + collectionUri, uid, pwd);
final UserManagementService ums = (UserManagementService) col.getService("UserManagementService", "1.0");
ums.chown(ums.getAccount(owner_uid), group_gid);
} catch (final XMLDBException xmldbe) {
throw new ApiException(xmldbe);
} finally {
if (col != null) {
try {
col.close();
} catch (final XMLDBException xmldbe) {
throw new ApiException(xmldbe);
}
}
}
}
Aggregations