use of org.opencastproject.authorization.xacml.manager.api.EpisodeACLTransition in project opencast by opencast.
the class EpisodeAclTransitionEntity method update.
EpisodeAclTransitionEntity update(final String episodeId, final String orgId, final Date applicationDate, final Option<ManagedAclEntity> managedAcl, final Option<ConfiguredWorkflowRef> workflow) {
final EpisodeAclTransitionEntity self = this;
run(EpisodeACLTransition.class, new EpisodeACLTransition() {
@Override
public String getEpisodeId() {
self.episodeId = episodeId;
return null;
}
@Override
public Option<ManagedAcl> getAccessControlList() {
self.managedAcl = managedAcl.getOrElseNull();
return null;
}
@Override
public boolean isDelete() {
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 self;
}
use of org.opencastproject.authorization.xacml.manager.api.EpisodeACLTransition in project opencast by opencast.
the class AbstractAclServiceRestEndpoint method updateEpisodeTransition.
@PUT
@Path("/episode/{transitionId}")
@Produces(MediaType.APPLICATION_JSON)
@RestQuery(name = "updateepisodetransition", description = "Update an existing episode transition", returnDescription = "Update an existing episode transition", pathParameters = { @RestParameter(name = "transitionId", isRequired = true, description = "The transition id", type = STRING) }, restParameters = { @RestParameter(name = "applicationDate", isRequired = true, description = "The date to applicate", type = STRING), @RestParameter(name = "managedAclId", isRequired = false, description = "The managed access control list id", type = INTEGER), @RestParameter(name = "workflowDefinitionId", isRequired = false, description = "The workflow definition identifier", type = STRING), @RestParameter(name = "workflowParams", isRequired = false, description = "The workflow parameters as JSON", type = STRING) }, reponses = { @RestResponse(responseCode = SC_OK, description = "The episode transition has successfully been updated"), @RestResponse(responseCode = SC_INTERNAL_SERVER_ERROR, description = "Error during updating an episode transition") })
public String updateEpisodeTransition(@PathParam("transitionId") long transitionId, @FormParam("applicationDate") String applicationDate, @FormParam("managedAclId") Long managedAclId, @FormParam("workflowDefinitionId") String workflowDefinitionId, @FormParam("workflowParams") String workflowParams) throws NotFoundException {
try {
final Date at = new Date(DateTimeSupport.fromUTC(applicationDate));
final Option<ConfiguredWorkflowRef> workflow = createConfiguredWorkflowRef(workflowDefinitionId, workflowParams);
final EpisodeACLTransition t = aclService().updateEpisodeTransition(transitionId, option(managedAclId), at, workflow);
return JsonConv.full(t).toJson();
} catch (AclServiceException e) {
logger.warn("Error updating episode transition:", e);
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
} catch (NotFoundException e) {
throw e;
} catch (Exception e) {
logger.warn("Unable to parse the application date");
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR);
}
}
use of org.opencastproject.authorization.xacml.manager.api.EpisodeACLTransition 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());
}
use of org.opencastproject.authorization.xacml.manager.api.EpisodeACLTransition 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.EpisodeACLTransition in project opencast by opencast.
the class OsgiJpaAclTransitionDbTest method testStoreAndGetEpisodeACL.
@Test
public void testStoreAndGetEpisodeACL() throws Exception {
final Date now = new Date();
// a fallback to series transition should be saveable
db.storeEpisodeAclTransition(ORG, "uuid", now, none(0L), Option.<ConfiguredWorkflowRef>none());
// a transition referencing a non existing ACL should not be saveable
try {
db.storeEpisodeAclTransition(ORG, "uuid", new Date(), some(1L), 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 EpisodeACLTransition t3 = db.storeEpisodeAclTransition(ORG, "uuid-2", now, some(macl.getId()), Option.<ConfiguredWorkflowRef>none());
assertEquals("uuid-2", t3.getEpisodeId());
assertEquals(now, t3.getApplicationDate());
assertTrue(t3.getAccessControlList().isSome());
assertEquals(macl.getName(), t3.getAccessControlList().get().getName());
// a transition with the same properties should not be saveable
try {
db.storeEpisodeAclTransition(ORG, "uuid", now, some(macl.getId()), Option.<ConfiguredWorkflowRef>none());
fail("Duplicated episode ACL must not be stored");
} catch (AclTransitionDbDuplicatedException ignore) {
}
List<EpisodeACLTransition> ts = db.getEpisodeAclTransitions(ORG, "uuid");
assertEquals(1, ts.size());
assertEquals("uuid", ts.get(0).getEpisodeId());
assertTrue(ts.get(0).isDelete());
assertTrue(!ts.get(0).isDone());
}
Aggregations