use of org.olat.resource.accesscontrol.AccessResult in project OpenOLAT by OpenOLAT.
the class TokenAccessController method formOK.
@Override
protected void formOK(UserRequest ureq) {
String token = tokenEl.getValue();
AccessResult result = acService.accessResource(getIdentity(), link, token);
if (result.isAccessible()) {
fireEvent(ureq, AccessEvent.ACCESS_OK_EVENT);
} else {
String msg = translate("invalid.token");
fireEvent(ureq, new AccessEvent(AccessEvent.ACCESS_FAILED, msg));
}
}
use of org.olat.resource.accesscontrol.AccessResult in project OpenOLAT by OpenOLAT.
the class ACFrontendManager method isAccessible.
/**
* The rule to access the repository entry:<br/>
* -No offer, access is free<br/>
* -Owners have always access to the resource<br/>
* -Tutors have access to the resource<br/>
* -Participants have access to the resource<br/>
* @param entry
* @param forId
* @param knowMember give it if already know as a member
* @return
*/
@Override
public AccessResult isAccessible(RepositoryEntry entry, Identity forId, Boolean knowMember, boolean allowNonInteractiveAccess) {
if (!accessModule.isEnabled()) {
return new AccessResult(true);
}
boolean member;
if (knowMember == null) {
member = repositoryService.isMember(forId, entry);
} else {
member = knowMember.booleanValue();
}
if (member) {
return new AccessResult(true);
}
Date now = dateNow();
List<Offer> offers = accessManager.findOfferByResource(entry.getOlatResource(), true, now);
if (offers.isEmpty()) {
if (methodManager.isValidMethodAvailable(entry.getOlatResource(), null)) {
// not open for the moment: no valid offer at this date but some methods are defined
return new AccessResult(false);
} else {
return new AccessResult(true);
}
}
return isAccessible(forId, offers, allowNonInteractiveAccess);
}
use of org.olat.resource.accesscontrol.AccessResult in project OpenOLAT by OpenOLAT.
the class MainAccessController method doAccessResource.
protected void doAccessResource(UserRequest ureq, OfferAccess link) {
AccessResult result = acService.accessResource(getIdentity(), link, null);
if (result.isAccessible()) {
fireEvent(ureq, AccessEvent.ACCESS_OK_EVENT);
} else {
fireEvent(ureq, new AccessEvent(AccessEvent.ACCESS_FAILED));
showError("error.accesscontrol");
}
}
use of org.olat.resource.accesscontrol.AccessResult in project OpenOLAT by OpenOLAT.
the class CoursesWebService method isCourseAccessible.
public static boolean isCourseAccessible(ICourse course, boolean authorRightsMandatory, HttpServletRequest request) {
if (authorRightsMandatory && !isAuthor(request)) {
return false;
}
Identity identity = getIdentity(request);
RepositoryEntry entry = RepositoryManager.getInstance().lookupRepositoryEntry(course, true);
ACService acManager = CoreSpringFactory.getImpl(ACService.class);
AccessResult result = acManager.isAccessible(entry, identity, false);
if (result.isAccessible()) {
return true;
}
return false;
}
use of org.olat.resource.accesscontrol.AccessResult in project OpenOLAT by OpenOLAT.
the class CoursesInfosWebService method collect.
private CourseInfoVO collect(final Identity identity, final Roles roles, final RepositoryEntry entry, final Set<Long> forumNotified, final Map<Long, Set<String>> courseNotified) {
CourseInfoVO info = new CourseInfoVO();
info.setRepoEntryKey(entry.getKey());
info.setSoftKey(entry.getSoftkey());
info.setDisplayName(entry.getDisplayname());
ACService acManager = CoreSpringFactory.getImpl(ACService.class);
AccessResult result = acManager.isAccessible(entry, identity, false);
if (result.isAccessible()) {
try {
final ICourse course = CourseFactory.loadCourse(entry);
final List<FolderVO> folders = new ArrayList<FolderVO>();
final List<ForumVO> forums = new ArrayList<ForumVO>();
final IdentityEnvironment ienv = new IdentityEnvironment(identity, roles);
new CourseTreeVisitor(course, ienv).visit(new Visitor() {
@Override
public void visit(INode node) {
if (node instanceof BCCourseNode) {
BCCourseNode bcNode = (BCCourseNode) node;
folders.add(BCWebService.createFolderVO(ienv, course, bcNode, courseNotified.get(course.getResourceableId())));
} else if (node instanceof FOCourseNode) {
FOCourseNode forumNode = (FOCourseNode) node;
forums.add(ForumCourseNodeWebService.createForumVO(course, forumNode, forumNotified));
}
}
}, new VisibleTreeFilter());
info.setKey(course.getResourceableId());
info.setTitle(course.getCourseTitle());
info.setFolders(folders.toArray(new FolderVO[folders.size()]));
info.setForums(forums.toArray(new ForumVO[forums.size()]));
} catch (Exception e) {
log.error("", e);
}
}
return info;
}
Aggregations