use of org.opencastproject.authorization.xacml.manager.api.AclServiceFactory in project opencast by opencast.
the class AssetManagerMessageReceiverImplTest method setUp.
@Before
public void setUp() throws Exception {
workspace = createNiceMock(Workspace.class);
expect(workspace.read(EasyMock.anyObject(URI.class))).andAnswer(() -> getClass().getResourceAsStream("/dublincore.xml")).anyTimes();
replay(workspace);
AclService aclService = createNiceMock(AclService.class);
expect(aclService.getAcls()).andReturn(new ArrayList<>()).anyTimes();
replay(aclService);
DefaultOrganization organization = new DefaultOrganization();
AclServiceFactory aclServiceFactory = createNiceMock(AclServiceFactory.class);
expect(aclServiceFactory.serviceFor(organization)).andReturn(aclService).anyTimes();
replay(aclServiceFactory);
SecurityService securityService = TestSearchIndex.createSecurityService(organization);
assetManager = new AssetManagerMessageReceiverImpl();
assetManager.setAclServiceFactory(aclServiceFactory);
assetManager.setSecurityService(securityService);
assetManager.setSearchIndex(index);
}
use of org.opencastproject.authorization.xacml.manager.api.AclServiceFactory in project opencast by opencast.
the class AclScannerTest method setUp.
@Before
public void setUp() throws Exception {
Organization org1 = new JpaOrganization("org1", "org1", new HashMap<String, Integer>(), "ADMIN", "ANONYMOUS", new HashMap<String, String>());
Organization org2 = new JpaOrganization("org2", "org2", new HashMap<String, Integer>(), "ADMIN", "ANONYMOUS", new HashMap<String, String>());
Organization org3 = new JpaOrganization("org3", "org3", new HashMap<String, Integer>(), "ADMIN", "ANONYMOUS", new HashMap<String, String>());
List<Organization> orgs = new ArrayList<>();
orgs.add(org1);
orgs.add(org2);
orgs.add(org3);
aclDb = EasyMock.createNiceMock(AclDb.class);
orgService = EasyMock.createNiceMock(OrganizationDirectoryService.class);
EasyMock.expect(orgService.getOrganizations()).andReturn(orgs).anyTimes();
final SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
final MessageSender messageSender = EasyMock.createNiceMock(MessageSender.class);
final AclTransitionDb aclTransitionDb = EasyMock.createNiceMock(AclTransitionDb.class);
List<EpisodeACLTransition> episodeTransitions = new ArrayList<>();
List<SeriesACLTransition> seriesTransitions = new ArrayList<>();
EasyMock.expect(aclTransitionDb.getByQuery(EasyMock.anyObject(Organization.class), EasyMock.anyObject(TransitionQuery.class))).andReturn(new TransitionResultImpl(episodeTransitions, seriesTransitions)).anyTimes();
// EasyMock.replay(aclDb);
EasyMock.replay(orgService, messageSender, aclTransitionDb, securityService);
AclServiceFactory aclServiceFactory = new AclServiceFactory() {
@Override
public AclService serviceFor(Organization org) {
return new AclServiceImpl(new DefaultOrganization(), aclDb, aclTransitionDb, null, null, null, null, messageSender, null);
}
};
aclScanner = new AclScanner();
aclScanner.setAclServiceFactory(aclServiceFactory);
aclScanner.setOrganizationDirectoryService(orgService);
aclScanner.setSecurityService(securityService);
}
use of org.opencastproject.authorization.xacml.manager.api.AclServiceFactory in project opencast by opencast.
the class TestAclEndpoint method setupServices.
private void setupServices() {
final DefaultOrganization org = new DefaultOrganization();
AccessControlEntry ace1 = new AccessControlEntry("ROLE_ADMIN", "read", true);
AccessControlEntry ace2 = new AccessControlEntry("ROLE_ANONYMOUS", "read", true);
AccessControlEntry ace3 = new AccessControlEntry("ROLE_ADMIN", "read", false);
AccessControlEntry ace4 = new AccessControlEntry("ROLE_ANONYMOUS", "read", false);
AccessControlList publicAcl = new AccessControlList(ace1, ace2);
AccessControlList privateAcl = new AccessControlList(ace3, ace4);
List<ManagedAcl> managedAcls = new ArrayList<ManagedAcl>();
managedAcls.add(new ManagedAclImpl(1L, "public", org.getId(), publicAcl));
managedAcls.add(new ManagedAclImpl(2L, "private", org.getId(), privateAcl));
AclService aclService = EasyMock.createNiceMock(AclService.class);
EasyMock.expect(aclService.getAcls()).andReturn(managedAcls).anyTimes();
EasyMock.expect(aclService.getAcl(EasyMock.anyLong())).andReturn(Option.some(managedAcls.get(0))).anyTimes();
EasyMock.replay(aclService);
AclServiceFactory aclServiceFactory = EasyMock.createNiceMock(AclServiceFactory.class);
EasyMock.expect(aclServiceFactory.serviceFor(EasyMock.anyObject(Organization.class))).andReturn(aclService).anyTimes();
EasyMock.replay(aclServiceFactory);
SecurityService securityService = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(securityService.getOrganization()).andReturn(org).anyTimes();
EasyMock.replay(securityService);
this.setAclServiceFactory(aclServiceFactory);
this.setSecurityService(securityService);
}
Aggregations