use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class CourseSecurityTest method setUp.
/**
* SetUp is called before each test.
*/
@Before
public void setUp() throws Exception {
super.setUp();
conn = new RestConnection();
try {
// create course and persist as OLATResourceImpl
admin = BaseSecurityManager.getInstance().findIdentityByName("administrator");
id1 = JunitTestHelper.createAndPersistIdentityAsUser("id-c-s-0");
Assert.assertNotNull(id1);
auth1 = JunitTestHelper.createAndPersistIdentityAsAuthor("id-c-s-1");
Assert.assertNotNull(auth1);
auth2 = JunitTestHelper.createAndPersistIdentityAsAuthor("id-c-s-2");
Assert.assertNotNull(auth2);
course = CoursesWebService.createEmptyCourse(admin, "course-security-2", "Test course for the security test", null);
DBFactory.getInstance().intermediateCommit();
RepositoryManager rm = RepositoryManager.getInstance();
RepositoryEntry re = rm.lookupRepositoryEntry(course, false);
IdentitiesAddEvent identitiesAddEvent = new IdentitiesAddEvent(Collections.singletonList(auth2));
rm.addOwners(admin, identitiesAddEvent, re, null);
DBFactory.getInstance().closeSession();
} catch (Exception e) {
log.error("Exception in setUp(): " + e);
}
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class SharedFolderWebDAVMergeSource method loadMergedContainers.
@Override
protected List<VFSContainer> loadMergedContainers() {
SharedFolderManager sfm = SharedFolderManager.getInstance();
RepositoryManager repoManager = RepositoryManager.getInstance();
List<VFSContainer> containers = new ArrayList<>();
Set<Long> addedEntries = new HashSet<>();
List<RepositoryEntry> ownerEntries = repoManager.queryByMembership(getIdentity(), true, true, false, SharedFolderFileResource.TYPE_NAME);
for (RepositoryEntry entry : ownerEntries) {
VFSContainer container = sfm.getNamedSharedFolder(entry, true);
if (container != null) {
addContainerToList(container, containers);
addedEntries.add(entry.getKey());
}
}
List<RepositoryEntry> participantEntries = repoManager.queryByMembership(getIdentity(), false, false, true, SharedFolderFileResource.TYPE_NAME);
for (RepositoryEntry entry : participantEntries) {
addReadonlyFolder(entry, sfm, addedEntries, containers);
}
// see /webapp/WEB-INF/classes/org/olat/core/commons/services/webdav/webdavContext.xml
if (publiclyReadableFolders != null && publiclyReadableFolders.size() > 0) {
// Temporarily save added entries. This is needed to make sure not to add an entry twice.
String firstItem = publiclyReadableFolders.get(0);
// If the first value in the list is '*', list all resource folders.
if (firstItem != null && firstItem.equals("*")) {
// fake role that represents normally logged in user
Roles registeredUserRole = new Roles(false, false, false, false, false, false, false);
List<String> types = Collections.singletonList(SharedFolderFileResource.TYPE_NAME);
List<RepositoryEntry> allEntries = repoManager.queryByTypeLimitAccess(getIdentity(), types, registeredUserRole);
for (RepositoryEntry entry : allEntries) {
addReadonlyFolder(entry, sfm, addedEntries, containers);
}
} else {
// only list the specified folders
List<Long> publiclyReadableFoldersKeys = getSharedKeys();
List<RepositoryEntry> entries = repoManager.lookupRepositoryEntries(publiclyReadableFoldersKeys);
for (RepositoryEntry entry : entries) {
if (entry.getAccess() >= RepositoryEntry.ACC_USERS || (entry.getAccess() == RepositoryEntry.ACC_OWNERS && entry.isMembersOnly())) {
// add folder (which is a repo entry) to root container if not present
addReadonlyFolder(entry, sfm, addedEntries, containers);
} else {
log.warn("Access denied on entry::" + entry.getKey(), null);
}
}
}
}
return containers;
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class GoToMeetingCourseNode method createNodeRunConstructionResult.
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Controller controller;
Roles roles = ureq.getUserSession().getRoles();
if (roles.isGuestOnly()) {
Translator trans = Util.createPackageTranslator(GoToMeetingEditController.class, ureq.getLocale());
String title = trans.translate("guestnoaccess.title");
String message = trans.translate("guestnoaccess.message");
controller = MessageUIFactory.createInfoMessage(ureq, wControl, title, message);
} else {
// check if user is moderator of the virtual classroom
boolean admin = roles.isOLATAdmin();
boolean moderator = admin;
RepositoryEntry re = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
if (!admin) {
RepositoryManager rm = RepositoryManager.getInstance();
if (re != null) {
admin = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re) || rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), roles, re);
moderator = admin || rm.isIdentityInTutorSecurityGroup(ureq.getIdentity(), re) || isCoach(re, ureq.getIdentity());
}
}
// create run controller
RepositoryEntry courseEntry = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
controller = new GoToMeetingRunController(ureq, wControl, courseEntry, getIdent(), null, admin, moderator, userCourseEnv.isCourseReadOnly());
}
Controller ctrl = TitledWrapperHelper.getWrapper(ureq, wControl, controller, this, "o_gotomeeting_icon");
return new NodeRunConstructionResult(ctrl);
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class OpenMeetingsCourseNode method createNodeRunConstructionResult.
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Roles roles = ureq.getUserSession().getRoles();
// check if user is moderator of the virtual classroom
boolean admin = roles.isOLATAdmin();
boolean moderator = admin;
RepositoryEntry re = userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseEntry();
if (!admin) {
RepositoryManager rm = RepositoryManager.getInstance();
if (re != null) {
admin = rm.isOwnerOfRepositoryEntry(ureq.getIdentity(), re) || rm.isInstitutionalRessourceManagerFor(ureq.getIdentity(), roles, re);
moderator = admin || rm.isIdentityInTutorSecurityGroup(ureq.getIdentity(), re) || isCoach(re, ureq.getIdentity());
}
}
// create run controller
OLATResourceable ores = OresHelper.clone(userCourseEnv.getCourseEnvironment().getCourseGroupManager().getCourseResource());
Controller runCtr = new OpenMeetingsRunController(ureq, wControl, null, ores, getIdent(), admin, moderator, userCourseEnv.isCourseReadOnly());
Controller controller = TitledWrapperHelper.getWrapper(ureq, wControl, runCtr, this, "o_openmeetings_icon");
return new NodeRunConstructionResult(controller);
}
use of org.olat.repository.RepositoryManager in project OpenOLAT by OpenOLAT.
the class FeedMediaDispatcher method hasAccess.
/**
* Verifiy if the identity has access to the feed.
*
* @param identity
* @param token
* @param feed
* @return true if the identity has access.
*/
private boolean hasAccess(Identity identity, String token, OLATResourceable feed) {
boolean hasAccess = false;
RepositoryManager resMgr = RepositoryManager.getInstance();
RepositoryEntry repoEntry = resMgr.lookupRepositoryEntry(feed, false);
if (allowsGuestAccess(repoEntry)) {
hasAccess = true;
} else if (identity != null) {
if (repoEntry != null) {
final Roles roles = BaseSecurityManager.getInstance().getRoles(identity);
final boolean isAllowedToLaunch = resMgr.isAllowedToLaunch(identity, roles, repoEntry);
if (isAllowedToLaunch && validAuthentication(identity, token)) {
hasAccess = true;
}
} else {
// no repository entry -> could be a feed without a repository-entry (ePortfolio-Blog-feed)
EPFrontendManager ePFMgr = (EPFrontendManager) CoreSpringFactory.getBean("epFrontendManager");
if (ePFMgr.checkFeedAccess(feed, identity)) {
return validAuthentication(identity, token);
}
}
}
return hasAccess;
}
Aggregations