Search in sources :

Example 21 with ManagedAcl

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

the class OsgiJpaAclTransitionDbTest method testUpdateEpisode.

@Test
public void testUpdateEpisode() throws Exception {
    final ManagedAcl macl = createAcl();
    EpisodeACLTransition t1 = db.storeEpisodeAclTransition(ORG, "uuid", new Date(), some(macl.getId()), Option.<ConfiguredWorkflowRef>none());
    EpisodeACLTransition u1 = db.updateEpisodeAclTransition(ORG, t1.getTransitionId(), t1.getApplicationDate(), none(0L), Option.some(workflow("full")));
    assertEquals(t1.getTransitionId(), u1.getTransitionId());
    assertEquals(t1.getEpisodeId(), u1.getEpisodeId());
    assertEquals(t1.getOrganizationId(), u1.getOrganizationId());
    assertTrue(u1.getAccessControlList().isNone());
    assertNotSame(t1.isDelete(), u1.isDelete());
    assertNotSame(t1.getWorkflow(), u1.getWorkflow());
    try {
        db.updateEpisodeAclTransition(ORG2, t1.getTransitionId(), t1.getApplicationDate(), some(macl.getId()), Option.some(workflow("full")));
        fail("Updating from non-owner org should not be possible");
    } catch (AclTransitionDbException ignore1) {
    } catch (NotFoundException ignore2) {
    }
}
Also used : ManagedAcl(org.opencastproject.authorization.xacml.manager.api.ManagedAcl) NotFoundException(org.opencastproject.util.NotFoundException) AclTransitionDbException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbException) EpisodeACLTransition(org.opencastproject.authorization.xacml.manager.api.EpisodeACLTransition) Date(java.util.Date) Test(org.junit.Test)

Example 22 with ManagedAcl

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

the class OsgiJpaAclTransitionDbTest method testUpdateSeries.

@Test
public void testUpdateSeries() throws Exception {
    final ManagedAcl macl = createAcl();
    SeriesACLTransition t1 = db.storeSeriesAclTransition(ORG, "uuid", new Date(), macl.getId(), true, Option.<ConfiguredWorkflowRef>none());
    SeriesACLTransition u1 = db.updateSeriesAclTransition(ORG, t1.getTransitionId(), t1.getApplicationDate(), macl.getId(), false, Option.some(workflow("full")));
    assertEquals(t1.getTransitionId(), u1.getTransitionId());
    assertEquals(t1.getSeriesId(), u1.getSeriesId());
    assertEquals(t1.getOrganizationId(), u1.getOrganizationId());
    assertEquals(t1.getAccessControlList().getId(), u1.getAccessControlList().getId());
    assertNotSame(t1.getWorkflow(), u1.getWorkflow());
    assertNotSame(t1.isOverride(), u1.isOverride());
    try {
        db.updateSeriesAclTransition(ORG2, t1.getTransitionId(), t1.getApplicationDate(), macl.getId(), false, Option.some(workflow("full")));
        fail("Updating from non-owner org should not be possible");
    } catch (AclTransitionDbException ignore1) {
    } catch (NotFoundException ignore2) {
    }
}
Also used : SeriesACLTransition(org.opencastproject.authorization.xacml.manager.api.SeriesACLTransition) ManagedAcl(org.opencastproject.authorization.xacml.manager.api.ManagedAcl) NotFoundException(org.opencastproject.util.NotFoundException) AclTransitionDbException(org.opencastproject.authorization.xacml.manager.impl.AclTransitionDbException) Date(java.util.Date) Test(org.junit.Test)

Example 23 with ManagedAcl

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

the class OsgiJpaAclTransitionDbTest method testGetSeriesTransitions.

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

Example 24 with ManagedAcl

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

the class OsgiJpaAclTransitionDbTest method testDeleteEpisode.

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

Example 25 with ManagedAcl

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

the class AclServiceImpl method createAcl.

@Override
public Option<ManagedAcl> createAcl(AccessControlList acl, String name) {
    Option<ManagedAcl> createAcl = aclDb.createAcl(organization, acl, name);
    if (createAcl.isSome()) {
        AclItem aclItem = AclItem.create(createAcl.get().getName());
        messageSender.sendObjectMessage(AclItem.ACL_QUEUE, MessageSender.DestinationType.Queue, aclItem);
    }
    return createAcl;
}
Also used : AclItem(org.opencastproject.message.broker.api.acl.AclItem) ManagedAcl(org.opencastproject.authorization.xacml.manager.api.ManagedAcl)

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