use of org.exist.security.SecurityManager in project exist by eXist-db.
the class StoreResourceTest method cleanupDb.
@AfterClass
public static void cleanupDb() throws EXistException, PermissionDeniedException, IOException, TriggerException {
final BrokerPool pool = existWebServer.getBrokerPool();
final SecurityManager sm = pool.getSecurityManager();
try (final DBBroker broker = pool.get(Optional.of(sm.getSystemSubject()));
final Txn transaction = pool.getTransactionManager().beginTransaction()) {
removeUser(sm, USER2_NAME);
removeUser(sm, USER1_NAME);
removeGroup(sm, GROUP1_NAME);
removeCollection(broker, transaction, TEST_COLLECTION_URI);
transaction.commit();
}
}
use of org.exist.security.SecurityManager in project exist by eXist-db.
the class CopyCollectionTest method prepareDb.
@BeforeClass
public static void prepareDb() throws EXistException, PermissionDeniedException, IOException, TriggerException {
final BrokerPool pool = existWebServer.getBrokerPool();
final SecurityManager sm = pool.getSecurityManager();
try (final DBBroker broker = pool.get(Optional.of(sm.getSystemSubject()));
final Txn transaction = pool.getTransactionManager().beginTransaction()) {
final Collection collection = broker.getOrCreateCollection(transaction, TEST_COLLECTION_URI);
chmod(broker, transaction, collection.getURI(), 511);
broker.saveCollection(transaction, collection);
createUser(broker, sm, USER1_NAME, USER1_PWD);
createUser(broker, sm, USER2_NAME, USER2_PWD);
transaction.commit();
}
}
use of org.exist.security.SecurityManager in project exist by eXist-db.
the class CopyCollectionTest method cleanupDb.
@AfterClass
public static void cleanupDb() throws EXistException, PermissionDeniedException, IOException, TriggerException {
final BrokerPool pool = existWebServer.getBrokerPool();
final SecurityManager sm = pool.getSecurityManager();
try (final DBBroker broker = pool.get(Optional.of(sm.getSystemSubject()));
final Txn transaction = pool.getTransactionManager().beginTransaction()) {
removeUser(sm, USER2_NAME);
removeUser(sm, USER1_NAME);
removeCollection(broker, transaction, TEST_COLLECTION_URI);
transaction.commit();
}
}
use of org.exist.security.SecurityManager in project exist by eXist-db.
the class DocumentImplTest method isSameNode_differentDoc.
@Test
public void isSameNode_differentDoc() {
final BrokerPool mockBrokerPool = EasyMock.createMock(BrokerPool.class);
final Database mockDatabase = EasyMock.createMock(Database.class);
final DBBroker mockBroker = EasyMock.createMock(DBBroker.class);
final Subject mockCurrentSubject = EasyMock.createMock(Subject.class);
final Group mockCurrentSubjectGroup = EasyMock.createMock(Group.class);
final SecurityManager mockSecurityManager = EasyMock.createMock(SecurityManager.class);
// expectations
expect(mockBrokerPool.getSecurityManager()).andReturn(mockSecurityManager).times(2);
expect(mockSecurityManager.getDatabase()).andReturn(mockDatabase).times(2);
expect(mockDatabase.getActiveBroker()).andReturn(mockBroker).times(2);
expect(mockBroker.getCurrentSubject()).andReturn(mockCurrentSubject).times(2);
expect(mockCurrentSubject.getUserMask()).andReturn(Permission.DEFAULT_UMASK).times(2);
expect(mockCurrentSubject.getId()).andReturn(RealmImpl.SYSTEM_ACCOUNT_ID).times(2);
expect(mockCurrentSubject.getDefaultGroup()).andReturn(mockCurrentSubjectGroup).times(2);
expect(mockCurrentSubjectGroup.getId()).andReturn(RealmImpl.DBA_GROUP_ID).times(2);
replay(mockBrokerPool, mockDatabase, mockBroker, mockCurrentSubject, mockCurrentSubjectGroup, mockSecurityManager);
// test setup
final DocumentImpl doc = new DocumentImpl(mockBrokerPool, 99);
final DocumentImpl doc2 = new DocumentImpl(mockBrokerPool, 765);
assertFalse(doc.isSameNode(doc2));
verify(mockBrokerPool, mockDatabase, mockBroker, mockCurrentSubject, mockCurrentSubjectGroup, mockSecurityManager);
}
use of org.exist.security.SecurityManager in project exist by eXist-db.
the class DocumentImplTest method isSameNode_nonDoc.
@Test
public void isSameNode_nonDoc() {
final BrokerPool mockBrokerPool = EasyMock.createMock(BrokerPool.class);
final Database mockDatabase = EasyMock.createMock(Database.class);
final DBBroker mockBroker = EasyMock.createMock(DBBroker.class);
final Subject mockCurrentSubject = EasyMock.createMock(Subject.class);
final Group mockCurrentSubjectGroup = EasyMock.createMock(Group.class);
final SecurityManager mockSecurityManager = EasyMock.createMock(SecurityManager.class);
// expectations
expect(mockBrokerPool.getSecurityManager()).andReturn(mockSecurityManager);
expect(mockSecurityManager.getDatabase()).andReturn(mockDatabase);
expect(mockDatabase.getActiveBroker()).andReturn(mockBroker);
expect(mockBroker.getCurrentSubject()).andReturn(mockCurrentSubject);
expect(mockCurrentSubject.getUserMask()).andReturn(Permission.DEFAULT_UMASK);
expect(mockCurrentSubject.getId()).andReturn(RealmImpl.SYSTEM_ACCOUNT_ID);
expect(mockCurrentSubject.getDefaultGroup()).andReturn(mockCurrentSubjectGroup);
expect(mockCurrentSubjectGroup.getId()).andReturn(RealmImpl.DBA_GROUP_ID);
replay(mockBrokerPool, mockDatabase, mockBroker, mockCurrentSubject, mockCurrentSubjectGroup, mockSecurityManager);
// test setup
final DocumentImpl doc = new DocumentImpl(mockBrokerPool, 99);
final TextImpl text = new TextImpl("hello");
assertFalse(doc.isSameNode(text));
verify(mockBrokerPool, mockDatabase, mockBroker, mockCurrentSubject, mockCurrentSubjectGroup, mockSecurityManager);
}
Aggregations