use of org.opencastproject.security.api.AccessControlList in project opencast by opencast.
the class AclScannerTest method testRemoveMissingFile.
@Test
public void testRemoveMissingFile() 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.uninstall(file2);
EasyMock.verify(aclDb);
}
use of org.opencastproject.security.api.AccessControlList 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);
}
use of org.opencastproject.security.api.AccessControlList in project opencast by opencast.
the class XACMLAuthorizationService method getDefaultAcl.
private Tuple<AccessControlList, AclScope> getDefaultAcl(final MediaPackage mp) {
logger.debug("Get default ACL for media package {}", mp.getIdentifier());
if (StringUtils.isNotBlank(mp.getSeries())) {
logger.debug("Falling back to acl from series {} for media package {}", mp.getSeries(), mp.getIdentifier());
try {
return tuple(seriesService.getSeriesAccessControl(mp.getSeries()), AclScope.Series);
} catch (Exception e) {
logger.debug("Unable to get acl from series '{}'", mp.getSeries());
}
}
logger.trace("Falling back to global default acl for media package '{}'", mp.getIdentifier());
return tuple(new AccessControlList(), AclScope.Global);
}
use of org.opencastproject.security.api.AccessControlList in project opencast by opencast.
the class AssetManagerItemTest method testSerializeUpdate.
@Test
public void testSerializeUpdate() throws Exception {
final Workspace workspace = EasyMock.createNiceMock(Workspace.class);
EasyMock.expect(workspace.get(EasyMock.anyObject(URI.class))).andReturn(new File(getClass().getResource("/dublincore-a.xml").toURI())).once();
EasyMock.expect(workspace.read(EasyMock.anyObject(URI.class))).andAnswer(() -> getClass().getResourceAsStream("/dublincore-a.xml")).once();
EasyMock.replay(workspace);
final MediaPackage mp = MediaPackageBuilderFactory.newInstance().newMediaPackageBuilder().createNew();
mp.add(DublinCores.mkOpencastEpisode().getCatalog());
final AccessControlList acl = new AccessControlList(new AccessControlEntry("admin", "read", true));
final Date now = new Date();
final AssetManagerItem item = AssetManagerItem.add(workspace, mp, acl, 10L, now);
final AssetManagerItem deserialized = IoSupport.serializeDeserialize(item);
assertEquals(item.getDate(), deserialized.getDate());
assertEquals(item.getType(), deserialized.getType());
assertEquals(item.decompose(TakeSnapshot.getMediaPackage, null, null).getIdentifier(), deserialized.decompose(TakeSnapshot.getMediaPackage, null, null).getIdentifier());
assertEquals(item.decompose(TakeSnapshot.getAcl, null, null).getEntries(), deserialized.decompose(TakeSnapshot.getAcl, null, null).getEntries());
assertTrue(DublinCoreUtil.equals(item.decompose(TakeSnapshot.getEpisodeDublincore, null, null).get(), deserialized.decompose(TakeSnapshot.getEpisodeDublincore, null, null).get()));
}
use of org.opencastproject.security.api.AccessControlList in project opencast by opencast.
the class AssetManagerWithSecurityTest method mkTestEnvironment.
/**
* Setup the test environment.
*/
public AssetManagerWithSecurity mkTestEnvironment() throws Exception {
final AuthorizationService authSvc = EasyMock.createNiceMock(AuthorizationService.class);
EasyMock.expect(authSvc.getActiveAcl(EasyMock.<MediaPackage>anyObject())).andAnswer(new IAnswer<Tuple<AccessControlList, AclScope>>() {
@Override
public Tuple<AccessControlList, AclScope> answer() throws Throwable {
return tuple(currentMediaPackageAcl, AclScope.Episode);
}
}).anyTimes();
EasyMock.replay(authSvc);
//
secSvc = EasyMock.createNiceMock(SecurityService.class);
EasyMock.expect(secSvc.getUser()).andAnswer(new IAnswer<User>() {
@Override
public User answer() throws Throwable {
return currentUser;
}
}).anyTimes();
EasyMock.expect(secSvc.getOrganization()).andAnswer(new IAnswer<Organization>() {
@Override
public Organization answer() throws Throwable {
return currentUser.getOrganization();
}
}).anyTimes();
EasyMock.replay(secSvc);
//
return new AssetManagerWithSecurity(mkAbstractAssetManager(), authSvc, secSvc);
}
Aggregations