use of org.exist.security.Account in project exist by eXist-db.
the class ConsistencyCheck method checkPermissions.
public ErrorReport checkPermissions(final DocumentImpl doc) {
try {
final Permission perms = doc.getPermissions();
final Account owner = perms.getOwner();
if (owner == null) {
return new ErrorReport.ResourceError(ErrorReport.RESOURCE_ACCESS_FAILED, "Owner account not found for document " + doc.getFileURI());
}
final Group group = perms.getGroup();
if (group == null) {
return new ErrorReport.ResourceError(ErrorReport.RESOURCE_ACCESS_FAILED, "Owner group not found for document " + doc.getFileURI());
}
} catch (final Exception e) {
return new ErrorReport.ResourceError(ErrorReport.RESOURCE_ACCESS_FAILED, "Exception caught while checking permissions on document " + doc.getFileURI(), e);
}
return null;
}
use of org.exist.security.Account 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.Account 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);
}
use of org.exist.security.Account in project exist by eXist-db.
the class ResourceTest method setUp.
@Before
public void setUp() throws XMLDBException, IOException {
// create a test collection
final CollectionManagementService cms = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
final Collection testCollection = cms.createCollection(TEST_COLLECTION);
final UserManagementService ums = (UserManagementService) testCollection.getService("UserManagementService", "1.0");
// change ownership to guest
final Account guest = ums.getAccount(GUEST_DB_USER);
ums.chown(guest, guest.getPrimaryGroup());
ums.chmod("rwxr-xr-x");
// store sample files as guest
final Collection testCollectionAsGuest = DatabaseManager.getCollection(XmldbURI.LOCAL_DB + "/" + TEST_COLLECTION);
for (final String sampleName : SAMPLES.getShakespeareXmlSampleNames()) {
final XMLResource res = (XMLResource) testCollectionAsGuest.createResource(sampleName, "XMLResource");
try (final InputStream is = SAMPLES.getShakespeareSample(sampleName)) {
res.setContent(InputStreamUtil.readString(is, UTF_8));
}
testCollectionAsGuest.storeResource(res);
}
}
use of org.exist.security.Account in project exist by eXist-db.
the class CopyMoveTest method setUp.
@Before
public void setUp() throws Exception {
final CollectionManagementService cms = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
final Collection testCollection = cms.createCollection(TEST_COLLECTION);
final UserManagementService ums = (UserManagementService) testCollection.getService("UserManagementService", "1.0");
// change ownership to guest
final Account guest = ums.getAccount(GUEST_DB_USER);
ums.chown(guest, guest.getPrimaryGroup());
ums.chmod("rwxr-xr-x");
}
Aggregations