Search in sources :

Example 1 with AclServiceFactory

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);
}
Also used : AclServiceFactory(org.opencastproject.authorization.xacml.manager.api.AclServiceFactory) SecurityService(org.opencastproject.security.api.SecurityService) ArrayList(java.util.ArrayList) AclService(org.opencastproject.authorization.xacml.manager.api.AclService) Workspace(org.opencastproject.workspace.api.Workspace) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) Before(org.junit.Before)

Example 2 with AclServiceFactory

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);
}
Also used : Organization(org.opencastproject.security.api.Organization) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) JpaOrganization(org.opencastproject.security.impl.jpa.JpaOrganization) JpaOrganization(org.opencastproject.security.impl.jpa.JpaOrganization) SeriesACLTransition(org.opencastproject.authorization.xacml.manager.api.SeriesACLTransition) MessageSender(org.opencastproject.message.broker.api.MessageSender) ArrayList(java.util.ArrayList) EasyMock.anyString(org.easymock.EasyMock.anyString) AclServiceFactory(org.opencastproject.authorization.xacml.manager.api.AclServiceFactory) SecurityService(org.opencastproject.security.api.SecurityService) EpisodeACLTransition(org.opencastproject.authorization.xacml.manager.api.EpisodeACLTransition) OrganizationDirectoryService(org.opencastproject.security.api.OrganizationDirectoryService) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization) Before(org.junit.Before)

Example 3 with AclServiceFactory

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);
}
Also used : AccessControlList(org.opencastproject.security.api.AccessControlList) AclServiceFactory(org.opencastproject.authorization.xacml.manager.api.AclServiceFactory) SecurityService(org.opencastproject.security.api.SecurityService) ManagedAcl(org.opencastproject.authorization.xacml.manager.api.ManagedAcl) ArrayList(java.util.ArrayList) ManagedAclImpl(org.opencastproject.authorization.xacml.manager.impl.ManagedAclImpl) AccessControlEntry(org.opencastproject.security.api.AccessControlEntry) AclService(org.opencastproject.authorization.xacml.manager.api.AclService) DefaultOrganization(org.opencastproject.security.api.DefaultOrganization)

Aggregations

ArrayList (java.util.ArrayList)3 AclServiceFactory (org.opencastproject.authorization.xacml.manager.api.AclServiceFactory)3 DefaultOrganization (org.opencastproject.security.api.DefaultOrganization)3 SecurityService (org.opencastproject.security.api.SecurityService)3 Before (org.junit.Before)2 AclService (org.opencastproject.authorization.xacml.manager.api.AclService)2 EasyMock.anyString (org.easymock.EasyMock.anyString)1 EpisodeACLTransition (org.opencastproject.authorization.xacml.manager.api.EpisodeACLTransition)1 ManagedAcl (org.opencastproject.authorization.xacml.manager.api.ManagedAcl)1 SeriesACLTransition (org.opencastproject.authorization.xacml.manager.api.SeriesACLTransition)1 ManagedAclImpl (org.opencastproject.authorization.xacml.manager.impl.ManagedAclImpl)1 MessageSender (org.opencastproject.message.broker.api.MessageSender)1 AccessControlEntry (org.opencastproject.security.api.AccessControlEntry)1 AccessControlList (org.opencastproject.security.api.AccessControlList)1 Organization (org.opencastproject.security.api.Organization)1 OrganizationDirectoryService (org.opencastproject.security.api.OrganizationDirectoryService)1 JpaOrganization (org.opencastproject.security.impl.jpa.JpaOrganization)1 Workspace (org.opencastproject.workspace.api.Workspace)1