Search in sources :

Example 56 with Account

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;
}
Also used : Account(org.exist.security.Account) Group(org.exist.security.Group) Permission(org.exist.security.Permission) PermissionDeniedException(org.exist.security.PermissionDeniedException) TerminatedException(org.exist.xquery.TerminatedException) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException)

Example 57 with Account

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

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

Example 59 with 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);
    }
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) Account(org.exist.security.Account) Collection(org.xmldb.api.base.Collection) XMLResource(org.xmldb.api.modules.XMLResource)

Example 60 with Account

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");
}
Also used : Account(org.exist.security.Account) Before(org.junit.Before)

Aggregations

Account (org.exist.security.Account)60 PermissionDeniedException (org.exist.security.PermissionDeniedException)18 SecurityManager (org.exist.security.SecurityManager)17 EXistException (org.exist.EXistException)12 XMLDBException (org.xmldb.api.base.XMLDBException)11 Group (org.exist.security.Group)10 Collection (org.xmldb.api.base.Collection)10 AuthenticationException (org.exist.security.AuthenticationException)9 DBBroker (org.exist.storage.DBBroker)9 AbstractAccount (org.exist.security.AbstractAccount)7 CollectionManagementService (org.xmldb.api.modules.CollectionManagementService)7 Txn (org.exist.storage.txn.Txn)6 DocumentImpl (org.exist.dom.persistent.DocumentImpl)5 Subject (org.exist.security.Subject)5 UserAider (org.exist.security.internal.aider.UserAider)5 UserManagementService (org.exist.xmldb.UserManagementService)5 Permission (org.exist.security.Permission)4 XPathException (org.exist.xquery.XPathException)4 Before (org.junit.Before)4 Test (org.junit.Test)4