use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class AclServiceImpl method deleteAcl.
@Override
public boolean deleteAcl(long id) throws AclServiceException, NotFoundException {
final TransitionQuery query = TransitionQuery.query().withDone(false).withAclId(id);
final TransitionResult result = persistence.getByQuery(organization, query);
if (result.getEpisodeTransistions().size() > 0 || result.getSeriesTransistions().size() > 0)
return false;
Option<ManagedAcl> deletedAcl = getAcl(id);
if (aclDb.deleteAcl(organization, id)) {
if (deletedAcl.isSome()) {
AclItem aclItem = AclItem.delete(deletedAcl.get().getName());
messageSender.sendObjectMessage(AclItem.ACL_QUEUE, MessageSender.DestinationType.Queue, aclItem);
}
return true;
}
throw new NotFoundException("Managed acl with id " + id + " not found.");
}
use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class OsgiAclServiceFactory method repopulate.
@Override
public void repopulate(final String indexName) {
final String destinationId = AclItem.ACL_QUEUE_PREFIX + WordUtils.capitalize(indexName);
for (final Organization organization : organizationDirectoryService.getOrganizations()) {
SecurityUtil.runAs(securityService, organization, SecurityUtil.createSystemUser(cc, organization), new Effect0() {
@Override
protected void run() {
AclService aclService = serviceFor(organization);
List<ManagedAcl> acls = aclService.getAcls();
int total = aclService.getAcls().size();
logger.info("Re-populating index with acls. There are {} acls(s) to add to the index.", total);
int current = 1;
for (ManagedAcl acl : acls) {
logger.trace("Adding acl '{}' for org '{}'", acl.getName(), organization.getId());
messageSender.sendObjectMessage(destinationId, MessageSender.DestinationType.Queue, AclItem.create(acl.getName()));
messageSender.sendObjectMessage(IndexProducer.RESPONSE_QUEUE, MessageSender.DestinationType.Queue, IndexRecreateObject.update(indexName, IndexRecreateObject.Service.Acl, total, current));
current++;
}
}
});
}
Organization organization = new DefaultOrganization();
SecurityUtil.runAs(securityService, organization, SecurityUtil.createSystemUser(cc, organization), new Effect0() {
@Override
protected void run() {
messageSender.sendObjectMessage(IndexProducer.RESPONSE_QUEUE, MessageSender.DestinationType.Queue, IndexRecreateObject.end(indexName, IndexRecreateObject.Service.Acl));
}
});
}
use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class AccessInformationUtilTest method testSerializeEpisodeACLTransition.
/**
* Test method for {@link AccessInformationUtil#serializeEpisodeACLTransition(EpisodeACLTransition)}
*/
@Test
public void testSerializeEpisodeACLTransition() throws Exception {
ManagedAcl acl = createNiceMock(ManagedAcl.class);
expect(acl.getId()).andStubReturn(TRANSITION_ACL_ID);
replay(acl);
EpisodeACLTransition trans = createNiceMock(EpisodeACLTransition.class);
expect(trans.getTransitionId()).andStubReturn(TRANSITION_ID);
expect(trans.getApplicationDate()).andStubReturn(TRANSITION_APPLICATION_DATE);
expect(trans.getWorkflow()).andStubReturn(TRANSITION_WORKFLOW_ID);
expect(trans.isDone()).andStubReturn(TRANSITION_DONE);
expect(trans.getAccessControlList()).andStubReturn(Option.some(acl));
expect(trans.isDelete()).andStubReturn(TRANSITION_IS_DELETED);
replay(trans);
JSONObject t = AccessInformationUtil.serializeEpisodeACLTransition(trans);
assertEquals(TRANSITION_ID, t.getLong("id"));
assertEquals(TRANSITION_APPLICATION_DATE, new Date(DateTimeSupport.fromUTC(t.getString("application_date"))));
assertEquals(TRANSITION_WORKFLOW_ID, Option.some(ConfiguredWorkflowRef.workflow(t.getString("workflow_id"))));
assertEquals(TRANSITION_IS_DELETED, t.getBoolean("is_deleted"));
assertEquals(TRANSITION_ACL_ID, t.getLong("acl_id"));
}
use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class AccessInformationUtilTest method testSerializeManagedAcl.
/**
* Test method for {@link AccessInformationUtil#serializeManagedAcl(ManagedAcl)}
*/
@Test
public void testSerializeManagedAcl() throws Exception {
AccessControlList acl = new AccessControlList();
acl.getEntries().add(ACE_ROLE_ADMIN_ALLOW_ACTION_READ);
ManagedAcl manAcl = new ManagedAclImpl(1L, MANAGED_ACL_1_NAME, ORGANISATION_1_ID, acl);
JSONObject aclJson = AccessInformationUtil.serializeManagedAcl(manAcl);
assertEquals(1L, aclJson.getLong("id"));
assertEquals(MANAGED_ACL_1_NAME, aclJson.getString("name"));
}
use of org.opencastproject.authorization.xacml.manager.api.ManagedAcl in project opencast by opencast.
the class AccessInformationUtilTest method testSerializeSeriesACLTransition.
/**
* Test method for {@link AccessInformationUtil#serializeSeriesACLTransition(SeriesACLTransition)}
*/
@Test
public void testSerializeSeriesACLTransition() throws Exception {
ManagedAcl acl = createNiceMock(ManagedAcl.class);
expect(acl.getId()).andStubReturn(TRANSITION_ACL_ID);
replay(acl);
SeriesACLTransition trans = createNiceMock(SeriesACLTransition.class);
expect(trans.getTransitionId()).andStubReturn(TRANSITION_ID);
expect(trans.getApplicationDate()).andStubReturn(TRANSITION_APPLICATION_DATE);
expect(trans.getWorkflow()).andStubReturn(TRANSITION_WORKFLOW_ID);
expect(trans.isDone()).andStubReturn(TRANSITION_DONE);
expect(trans.getAccessControlList()).andStubReturn(acl);
expect(trans.isOverride()).andStubReturn(TRANSITION_OVERRIDE_EPISODES);
replay(trans);
JSONObject t = AccessInformationUtil.serializeSeriesACLTransition(trans);
assertEquals(TRANSITION_ID, t.getLong("id"));
assertEquals(TRANSITION_APPLICATION_DATE, new Date(DateTimeSupport.fromUTC(t.getString("application_date"))));
assertEquals(TRANSITION_WORKFLOW_ID, Option.some(ConfiguredWorkflowRef.workflow(t.getString("workflow_id"))));
assertEquals(TRANSITION_DONE, t.getBoolean("done"));
assertEquals(TRANSITION_ACL_ID, t.getLong("acl_id"));
assertEquals(TRANSITION_OVERRIDE_EPISODES, t.getBoolean("override_episodes"));
}
Aggregations