Search in sources :

Example 6 with ManagedAcl

use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.

the class AclScannerTest method testMissingFileUpdate.

@Test
public void testMissingFileUpdate() throws Exception {
    File file1 = new File(AclScannerTest.class.getResource("/xacml_correct.xml").toURI());
    File file2 = new File(AclScannerTest.class.getResource("/xacml_correct2.xml").toURI());
    ManagedAcl acl = new ManagedAclImpl(1L, "TestAcl", "org", new AccessControlList());
    Option<ManagedAcl> managedAcl = Option.some(acl);
    EasyMock.expect(aclDb.createAcl(anyObject(Organization.class), anyObject(AccessControlList.class), anyString())).andReturn(managedAcl).times(3);
    EasyMock.expect(aclDb.getAcls(anyObject(Organization.class))).andReturn(new ArrayList<ManagedAcl>()).times(3);
    EasyMock.replay(aclDb);
    aclScanner.install(file1);
    aclScanner.update(file2);
    EasyMock.verify(aclDb);
}
Also used : AccessControlList(org.opencastproject.security.api.AccessControlList) ManagedAcl(org.opencastproject.authorization.xacml.manager.api.ManagedAcl) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Example 7 with ManagedAcl

use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.

the class OsgiJpaAclTransitionDbTest method testDeleteSeries.

@Test
public void testDeleteSeries() throws Exception {
    final ManagedAcl macl = createAcl();
    SeriesACLTransition t1 = db.storeSeriesAclTransition(ORG, "uuid", new Date(), macl.getId(), true, Option.<ConfiguredWorkflowRef>none());
    // try deletion from different org
    try {
        db.deleteSeriesAclTransition(ORG2, t1.getTransitionId());
        fail("Deleting from non-owner org should not be possible");
    } catch (NotFoundException ignore) {
    }
    db.deleteSeriesAclTransition(ORG, t1.getTransitionId());
    try {
        db.deleteSeriesAclTransition(ORG, t1.getTransitionId());
        fail("Deleting a non existing transition should throw an exception");
    } catch (NotFoundException ignore) {
    }
}
Also used : SeriesACLTransition(org.opencastproject.authorization.xacml.manager.api.SeriesACLTransition) ManagedAcl(org.opencastproject.authorization.xacml.manager.api.ManagedAcl) NotFoundException(org.opencastproject.util.NotFoundException) Date(java.util.Date) Test(org.junit.Test)

Example 8 with ManagedAcl

use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.

the class OsgiJpaAclTransitionDbTest method testGetEpisodeTransitions.

@Test
public void testGetEpisodeTransitions() throws Exception {
    final ManagedAcl macl = createAcl();
    db.storeEpisodeAclTransition(ORG, "uuid", new Date(), some(macl.getId()), Option.<ConfiguredWorkflowRef>none());
    db.storeEpisodeAclTransition(ORG, "uuid", new Date(), some(macl.getId()), Option.<ConfiguredWorkflowRef>none());
    // there should now be two transitions for episode "uuid"
    List<EpisodeACLTransition> episodes = db.getEpisodeAclTransitions(ORG, "uuid");
    assertEquals(2, episodes.size());
    // transitions shouldn't be accessible from another organization
    assertEquals(0, db.getEpisodeAclTransitions(ORG2, "uuid").size());
}
Also used : ManagedAcl(org.opencastproject.authorization.xacml.manager.api.ManagedAcl) EpisodeACLTransition(org.opencastproject.authorization.xacml.manager.api.EpisodeACLTransition) Date(java.util.Date) Test(org.junit.Test)

Example 9 with ManagedAcl

use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.

the class OsgiJpaAclTransitionDbTest method testStoreAndGetSeriesACL.

@Test
public void testStoreAndGetSeriesACL() throws Exception {
    final Date now = new Date();
    // a transition referencing a non existing ACL should not be saveable
    try {
        db.storeSeriesAclTransition(ORG, "uuid", new Date(), 1L, true, Option.<ConfiguredWorkflowRef>none());
        fail("No ACL with ID 1");
    } catch (AclTransitionDbException ignore) {
    }
    // a transition referencing an existing ACL should be saveable
    final ManagedAcl macl = createAcl();
    final SeriesACLTransition t3 = db.storeSeriesAclTransition(ORG, "uuid", now, macl.getId(), false, Option.<ConfiguredWorkflowRef>none());
    assertEquals("uuid", t3.getSeriesId());
    assertEquals(now, t3.getApplicationDate());
    assertEquals(macl.getName(), t3.getAccessControlList().getName());
    // a transition with the same properties should not be saveable
    try {
        db.storeSeriesAclTransition(ORG, "uuid", now, macl.getId(), true, Option.<ConfiguredWorkflowRef>none());
        fail("Duplicated episode ACL must not be stored");
    } catch (AclTransitionDbDuplicatedException ignore) {
    }
    List<SeriesACLTransition> ts = db.getSeriesAclTransitions(ORG, "uuid");
    assertEquals(1, ts.size());
    assertEquals("uuid", ts.get(0).getSeriesId());
    assertTrue(!ts.get(0).isOverride());
    assertTrue(!ts.get(0).isDone());
}
Also used : SeriesACLTransition(org.opencastproject.authorization.xacml.manager.api.SeriesACLTransition) ManagedAcl(org.opencastproject.authorization.xacml.manager.api.ManagedAcl) AclTransitionDbException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbException) AclTransitionDbDuplicatedException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbDuplicatedException) Date(java.util.Date) Test(org.junit.Test)

Example 10 with ManagedAcl

use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.

the class SeriesAclTransitionEntity method update.

SeriesAclTransitionEntity update(final String seriesId, final String orgId, final Date applicationDate, final ManagedAclEntity managedAcl, final Option<ConfiguredWorkflowRef> workflow, final boolean override) {
    final SeriesAclTransitionEntity self = this;
    run(SeriesACLTransition.class, new SeriesACLTransition() {

        @Override
        public String getSeriesId() {
            self.seriesId = seriesId;
            return null;
        }

        @Override
        public ManagedAcl getAccessControlList() {
            self.managedAcl = managedAcl;
            return null;
        }

        @Override
        public boolean isOverride() {
            self.override = override;
            return false;
        }

        @Override
        public long getTransitionId() {
            return 0;
        }

        @Override
        public String getOrganizationId() {
            self.organizationId = orgId;
            return null;
        }

        @Override
        public Date getApplicationDate() {
            self.applicationDate = applicationDate;
            return null;
        }

        @Override
        public Option<ConfiguredWorkflowRef> getWorkflow() {
            final Tuple<Option<String>, Option<String>> s = splitConfiguredWorkflowRef(workflow);
            self.workflowId = s.getA().getOrElseNull();
            self.workflowParams = s.getB().getOrElseNull();
            return null;
        }

        @Override
        public boolean isDone() {
            self.done = done;
            return false;
        }
    });
    return this;
}
Also used : SeriesACLTransition(org.opencastproject.authorization.xacml.manager.api.SeriesACLTransition) ManagedAcl(org.opencastproject.authorization.xacml.manager.api.ManagedAcl) Option(org.opencastproject.util.data.Option) Date(java.util.Date) Tuple(org.opencastproject.util.data.Tuple)

Aggregations

ManagedAcl (org.opencastproject.authorization.xacml.manager.api.ManagedAcl)35 Test (org.junit.Test)18 AccessControlList (org.opencastproject.security.api.AccessControlList)16 Date (java.util.Date)12 SeriesACLTransition (org.opencastproject.authorization.xacml.manager.api.SeriesACLTransition)8 ArrayList (java.util.ArrayList)7 EpisodeACLTransition (org.opencastproject.authorization.xacml.manager.api.EpisodeACLTransition)7 NotFoundException (org.opencastproject.util.NotFoundException)7 File (java.io.File)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 RestQuery (org.opencastproject.util.doc.rest.RestQuery)5 TransitionQuery (org.opencastproject.authorization.xacml.manager.api.TransitionQuery)4 AclTransitionDbException (org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbException)4 SearchIndexException (org.opencastproject.matterhorn.search.SearchIndexException)4 GET (javax.ws.rs.GET)3 WebApplicationException (javax.ws.rs.WebApplicationException)3 JSONObject (org.codehaus.jettison.json.JSONObject)3 ManagedAclImpl (org.opencastproject.authorization.xacml.manager.impl.ManagedAclImpl)3 Event (org.opencastproject.index.service.impl.index.event.Event)3