use of org.olat.core.util.UserSession in project OpenOLAT by OpenOLAT.
the class PoolPrivateMembersSecurityCallback method isAllowedToLaunchSite.
/**
* @see com.frentix.olat.coursesite.SiteSecurityCallback#isAllowedToLaunchSite(org.olat.core.gui.UserRequest)
*/
@Override
public boolean isAllowedToLaunchSite(UserRequest ureq) {
if (!questionPoolModule.isEnabled() || ureq == null || ureq.getIdentity() == null) {
return false;
}
UserSession usess = ureq.getUserSession();
if (usess == null) {
return false;
}
Roles roles = usess.getRoles();
if (roles == null || roles.isInvitee() || roles.isGuestOnly()) {
return false;
}
if (roles.isOLATAdmin() || roles.isPoolAdmin()) {
return true;
}
return qPoolService.isMemberOfPrivatePools(ureq.getIdentity());
}
use of org.olat.core.util.UserSession in project OpenOLAT by OpenOLAT.
the class UserPrefsResetForm method formOK.
@Override
protected void formOK(UserRequest ureq) {
if (resetElements.isAtLeastSelected(1)) {
// Log out user first if logged in
boolean logout = false;
Set<UserSession> sessions = sessionManager.getAuthenticatedUserSessions();
for (UserSession session : sessions) {
Identity ident = session.getIdentity();
if (ident != null && tobeChangedIdentity.equalsByPersistableKey(ident)) {
sessionManager.signOffAndClear(session);
logout = true;
break;
}
}
// Delete gui prefs
if (resetElements.isSelected(0)) {
PropertyManager pm = PropertyManager.getInstance();
pm.deleteProperties(tobeChangedIdentity, null, null, null, "v2guipreferences");
}
// Reset preferences
if (resetElements.isSelected(1)) {
UserManager um = UserManager.getInstance();
User user = um.loadUserByKey(tobeChangedIdentity.getUser().getKey());
org.olat.core.id.Preferences preferences = user.getPreferences();
preferences.setFontsize(null);
preferences.setNotificationInterval(null);
preferences.setPresenceMessagesPublic(false);
preferences.setReceiveRealMail(null);
um.updateUser(user);
PropertyManager pm = PropertyManager.getInstance();
pm.deleteProperties(tobeChangedIdentity, null, null, null, "charset");
}
// Reset history
if (resetElements.isSelected(2)) {
HistoryManager.getInstance().deleteHistory(tobeChangedIdentity);
}
// reset form buttons
resetElements.uncheckAll();
if (logout) {
// if logout, need a redirect to the login page
String lang = i18nModule.getLocaleKey(ureq.getLocale());
ureq.getDispatchResult().setResultingMediaResource(new RedirectMediaResource(WebappHelper.getServletContextPath() + "/dmz/?lang=" + lang + "&logout=true"));
}
}
}
use of org.olat.core.util.UserSession in project OpenOLAT by OpenOLAT.
the class NewBGController method event.
/* (non-Javadoc)
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
@Override
public void event(UserRequest ureq, Controller source, Event event) {
if (source == groupCreateController) {
if (event == Event.DONE_EVENT) {
String bgDesc = groupCreateController.getGroupDescription();
Integer bgMax = groupCreateController.getGroupMax();
Integer bgMin = groupCreateController.getGroupMin();
boolean enableWaitingList = groupCreateController.isWaitingListEnabled();
boolean enableAutoCloseRanks = groupCreateController.isAutoCloseRanksEnabled();
UserSession usess = ureq.getUserSession();
Object wildcard = usess.removeEntry("wild_card_new");
newGroups = new ArrayList<BusinessGroup>();
if (bulkMode) {
for (String bgName : groupCreateController.getGroupNames()) {
BusinessGroup group = businessGroupService.createBusinessGroup(getIdentity(), bgName, bgDesc, bgMin, bgMax, enableWaitingList, enableAutoCloseRanks, re);
newGroups.add(group);
}
} else {
String bgName = groupCreateController.getGroupName();
BusinessGroup group = businessGroupService.createBusinessGroup(getIdentity(), bgName, bgDesc, bgMin, bgMax, enableWaitingList, enableAutoCloseRanks, re);
newGroups.add(group);
if (wildcard != null && Boolean.TRUE.equals(wildcard)) {
usess.putEntry("wild_card_" + group.getKey(), Boolean.TRUE);
}
}
if (newGroups != null) {
for (BusinessGroup bg : newGroups) {
LoggingResourceable resourceInfo = LoggingResourceable.wrap(bg);
ThreadLocalUserActivityLogger.log(GroupLoggingAction.GROUP_CREATED, getClass(), resourceInfo);
}
// workflow successfully finished
// so far no events on the systembus to inform about new groups in BGContext
fireEvent(ureq, Event.DONE_EVENT);
}
} else if (event == Event.CANCELLED_EVENT) {
// workflow cancelled
fireEvent(ureq, Event.CANCELLED_EVENT);
}
}
}
use of org.olat.core.util.UserSession in project OpenOLAT by OpenOLAT.
the class WebDAVManagerTest method handleBasicAuthentication.
@Test
public void handleBasicAuthentication() {
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("dav-user-" + UUID.randomUUID().toString());
String credentialsClearText = id.getName() + ":" + JunitTestHelper.PWD;
String credentials = StringHelper.encodeBase64(credentialsClearText);
HttpServletRequest request = new MockHttpServletRequest();
UserSession usess = webDAVManager.handleBasicAuthentication(credentials, request);
Assert.assertNotNull(usess);
dbInstance.commit();
}
use of org.olat.core.util.UserSession in project openolat by klemens.
the class AuthHelper method doLogout.
/**
* This is a convenience method to log out. IMPORTANT: This method initiates a
* redirect and RETURN. Make sure you return the call hierarchy gracefully.
* Most of all, don't touch HttpServletRequest or the Session after you call
* this method.
*
* @param ureq
*/
public static void doLogout(UserRequest ureq) {
if (ureq == null)
return;
boolean wasGuest = false;
UserSession usess = ureq.getUserSession();
if (usess != null && usess.getRoles() != null) {
wasGuest = usess.getRoles().isGuestOnly();
}
String lang = CoreSpringFactory.getImpl(I18nModule.class).getLocaleKey(ureq.getLocale());
HttpSession session = ureq.getHttpReq().getSession(false);
// stuff on logout
if (session != null) {
try {
session.invalidate();
deleteShibsessionCookie(ureq);
} catch (IllegalStateException ise) {
// thrown when session already invalidated. fine. ignore.
}
}
// redirect to logout page in dmz realm, set info that DMZ is shown because of logout
// if it was a guest user, do not set logout=true. The parameter must be evaluated
// by the implementation of the AuthenticationProvider.
String setWarning = wasGuest ? "" : "&logout=true";
ureq.getDispatchResult().setResultingMediaResource(new RedirectMediaResource(WebappHelper.getServletContextPath() + "/dmz/?lang=" + lang + setWarning));
}
Aggregations