use of org.opencastproject.security.api.Organization in project opencast by opencast.
the class DefaultsWorkflowOperationHandlerTest method usesEventLevelPreset.
@Test
public void usesEventLevelPreset() throws WorkflowOperationException {
Organization organization = EasyMock.createMock(Organization.class);
EasyMock.replay(organization);
String seriesID = "series-ID";
Map<String, String> workflowConfiguration = new HashMap<String, String>();
workflowConfiguration.put(OPT_KEY, WORKFLOW_PRESET_VALUE);
WorkflowInstance workflowInstance = setupInstance(organization, seriesID, workflowConfiguration, true);
DefaultsWorkflowOperationHandler handler = new DefaultsWorkflowOperationHandler();
handler.setPresetProvider(presetProvider);
WorkflowOperationResult result = handler.start(workflowInstance, null);
assertEquals(EVENT_PRESET_VALUE, result.getProperties().get(OPT_KEY));
}
use of org.opencastproject.security.api.Organization in project opencast by opencast.
the class DefaultsWorkflowOperationHandlerTest method usesOrganizationLevelPresetNullSeries.
@Test
public void usesOrganizationLevelPresetNullSeries() throws WorkflowOperationException, NotFoundException {
Organization organization = EasyMock.createMock(Organization.class);
EasyMock.replay(organization);
String seriesID = null;
presetProvider = EasyMock.createMock(PresetProvider.class);
EasyMock.expect(presetProvider.getProperty(seriesID, OPT_KEY)).andReturn(ORGANIZATION_PRESET_VALUE);
EasyMock.replay(presetProvider);
// Workflow configuration
Map<String, String> workflowConfiguration = new HashMap<String, String>();
workflowConfiguration.put(OPT_KEY, WORKFLOW_PRESET_VALUE);
WorkflowInstance workflowInstance = setupInstance(organization, seriesID, workflowConfiguration, false);
DefaultsWorkflowOperationHandler handler = new DefaultsWorkflowOperationHandler();
handler.setPresetProvider(presetProvider);
WorkflowOperationResult result = handler.start(workflowInstance, null);
assertEquals(ORGANIZATION_PRESET_VALUE, result.getProperties().get(OPT_KEY));
}
use of org.opencastproject.security.api.Organization in project opencast by opencast.
the class SecurityUtil method getUserOfOrganization.
/**
* Get a user of a certain organization by its ID.
*/
public static Option<User> getUserOfOrganization(SecurityService sec, OrganizationDirectoryService orgDir, String orgId, UserDirectoryService userDir, String userId) {
final Organization prevOrg = sec.getOrganization();
try {
final Organization org = orgDir.getOrganization(orgId);
sec.setOrganization(org);
return option(userDir.loadUser(userId));
} catch (NotFoundException e) {
return none();
} finally {
sec.setOrganization(prevOrg);
}
}
use of org.opencastproject.security.api.Organization in project opencast by opencast.
the class SeriesServiceDatabaseImpl method userHasReadAccess.
private boolean userHasReadAccess(SeriesEntity entity) throws IOException, AccessControlParsingException {
// Ensure this user is allowed to read this series
String accessControlXml = entity.getAccessControl();
if (accessControlXml != null) {
AccessControlList acl = AccessControlParser.parseAcl(accessControlXml);
User currentUser = securityService.getUser();
Organization currentOrg = securityService.getOrganization();
// There are several reasons a user may need to load a series: to read content, to edit it, or add content
if (!AccessControlUtil.isAuthorized(acl, currentUser, currentOrg, Permissions.Action.READ.toString()) && !AccessControlUtil.isAuthorized(acl, currentUser, currentOrg, Permissions.Action.CONTRIBUTE.toString()) && !AccessControlUtil.isAuthorized(acl, currentUser, currentOrg, Permissions.Action.WRITE.toString())) {
return false;
}
}
return true;
}
use of org.opencastproject.security.api.Organization in project opencast by opencast.
the class SeriesServiceDatabaseImpl method userHasWriteAccess.
private boolean userHasWriteAccess(SeriesEntity entity) throws IOException, AccessControlParsingException {
// Ensure this user is allowed to write this series
String accessControlXml = entity.getAccessControl();
if (accessControlXml != null) {
AccessControlList acl = AccessControlParser.parseAcl(accessControlXml);
User currentUser = securityService.getUser();
Organization currentOrg = securityService.getOrganization();
if (!AccessControlUtil.isAuthorized(acl, currentUser, currentOrg, Permissions.Action.WRITE.toString())) {
return false;
}
}
return true;
}
Aggregations