use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.
the class GoToMeetingController method doJoin.
private void doJoin(UserRequest ureq) {
boolean join = false;
GoToError error = new GoToError();
if (registrant == null) {
registrant = meetingMgr.registerTraining(meeting, getIdentity(), error);
}
if (registrant != null) {
String joinUrl = registrant.getJoinUrl();
if (joinUrl != null) {
RedirectMediaResource redirect = new RedirectMediaResource(joinUrl);
ureq.getDispatchResult().setResultingMediaResource(redirect);
join = true;
}
}
if (!join) {
final String errorMessage;
if (error.hasError()) {
if (error.getError() != null) {
errorMessage = translate(error.getError().i18nKey());
} else {
errorMessage = translate("error.code.unkown");
}
} else {
errorMessage = translate("error.code.unkown");
}
ControllerCreator creator = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, new ControllerCreator() {
@Override
public Controller createController(UserRequest lureq, WindowControl lwControl) {
// Wrap in column layout, popup window needs a layout controller
String title = "";
String text = errorMessage;
Controller ctr = MessageUIFactory.createErrorMessage(lureq, lwControl, title, text);
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, ctr);
layoutCtr.addDisposableChildController(ctr);
return layoutCtr;
}
});
openInNewBrowserWindow(ureq, creator);
}
updateButtons();
}
use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.
the class IQManager method createLockedMessageController.
private GenericMainController createLockedMessageController(UserRequest ureq, WindowControl wControl, String fullName) {
// wrap simple message into mainLayout
GenericMainController glc = new GenericMainController(ureq, wControl) {
@Override
public void init(UserRequest uureq) {
Panel empty = new Panel("empty");
setTranslator(Util.createPackageTranslator(this.getClass(), uureq.getLocale()));
Controller contentCtr = MessageUIFactory.createInfoMessage(uureq, getWindowControl(), translate("status.currently.locked.title"), translate("status.currently.locked", fullName));
// auto dispose later
listenTo(contentCtr);
Component resComp = contentCtr.getInitialComponent();
LayoutMain3ColsController columnLayoutCtr = new LayoutMain3ColsController(uureq, getWindowControl(), empty, resComp, /*do not save no prefs*/
null);
// auto dispose later
listenTo(columnLayoutCtr);
putInitialPanel(columnLayoutCtr.getInitialComponent());
}
@Override
protected Controller handleOwnMenuTreeEvent(Object uobject, UserRequest uureq) {
// no menutree means no menu events.
return null;
}
};
glc.init(ureq);
return glc;
}
use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.
the class QuickstartPortletRunController method event.
public void event(UserRequest ureq, Component source, Event event) {
if (source == quickstartVC) {
String cmd = event.getCommand();
String businessPath = null;
if (cmd.equals("cmd.repo.course")) {
businessPath = "[MyCoursesSite:0]";
} else if (cmd.equals("cmd.repo.catalog")) {
businessPath = "[MyCoursesSite:0][Catalog:0]";
} else if (cmd.equals("cmd.settings")) {
businessPath = "[HomeSite:" + ureq.getIdentity().getKey() + "][mysettings:0]";
} else if (cmd.equals("cmd.buddygroup.new")) {
businessPath = "[GroupsSite:0]";
}
if (StringHelper.containsNonWhitespace(businessPath)) {
NewControllerFactory.getInstance().launch(businessPath, ureq, getWindowControl());
}
} else if (source == helpLink) {
ControllerCreator ctrlCreator = new ControllerCreator() {
public Controller createController(UserRequest lureq, WindowControl lwControl) {
return CourseFactory.createHelpCourseLaunchController(lureq, lwControl);
}
};
// wrap the content controller into a full header layout
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
// open in new browser window
PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
pbw.open(ureq);
//
}
}
use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.
the class OlatFooterController method doOpenImpressum.
protected void doOpenImpressum(UserRequest ureq) {
ControllerCreator impressumControllerCreator = new ControllerCreator() {
@Override
public Controller createController(UserRequest lureq, WindowControl lwControl) {
return new ImpressumMainController(lureq, lwControl);
}
};
PopupBrowserWindow popupBrowserWindow;
if (ureq.getUserSession().isAuthenticated()) {
popupBrowserWindow = Windows.getWindows(ureq).getWindowManager().createNewPopupBrowserWindowFor(ureq, impressumControllerCreator);
} else {
popupBrowserWindow = Windows.getWindows(ureq).getWindowManager().createNewUnauthenticatedPopupWindowFor(ureq, impressumControllerCreator);
}
popupBrowserWindow.open(ureq);
}
use of org.olat.core.gui.UserRequest in project OpenOLAT by OpenOLAT.
the class OAuthDispatcher method execute.
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String uri = request.getRequestURI();
try {
uri = URLDecoder.decode(uri, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new AssertException("UTF-8 encoding not supported!!!!");
}
String uriPrefix = DispatcherModule.getLegacyUriPrefix(request);
uri = uri.substring(uriPrefix.length());
UserRequest ureq = null;
try {
// upon creation URL is checked for
ureq = new UserRequestImpl(uriPrefix, request, response);
} catch (NumberFormatException nfe) {
if (log.isDebug()) {
log.debug("Bad Request " + request.getPathInfo());
}
DispatcherModule.sendBadRequest(request.getPathInfo(), response);
return;
}
String error = request.getParameter("error");
if (null != error) {
error(ureq, translateOauthError(ureq, error));
return;
}
String problem = request.getParameter("oauth_problem");
if (problem != null && "token_rejected".equals(problem.trim())) {
error(ureq, translateOauthError(ureq, error));
return;
}
try {
HttpSession sess = request.getSession();
// OAuth 2.0 hasn't any request token
Token requestToken = (Token) sess.getAttribute(OAuthConstants.REQUEST_TOKEN);
OAuthService service = (OAuthService) sess.getAttribute(OAuthConstants.OAUTH_SERVICE);
OAuthSPI provider = (OAuthSPI) sess.getAttribute(OAuthConstants.OAUTH_SPI);
Token accessToken;
if (provider == null) {
log.audit("OAuth Login failed, no provider in request");
DispatcherModule.redirectToDefaultDispatcher(response);
return;
} else if (provider.isImplicitWorkflow()) {
String idToken = ureq.getParameter("id_token");
if (idToken == null) {
redirectImplicitWorkflow(ureq);
return;
} else {
Verifier verifier = OpenIDVerifier.create(ureq, sess);
accessToken = service.getAccessToken(requestToken, verifier);
}
} else {
String requestVerifier = request.getParameter("oauth_verifier");
if (requestVerifier == null) {
// OAuth 2.0 as a code
requestVerifier = request.getParameter("code");
}
accessToken = service.getAccessToken(requestToken, new Verifier(requestVerifier));
}
OAuthUser infos = provider.getUser(service, accessToken);
if (infos == null || !StringHelper.containsNonWhitespace(infos.getId())) {
error(ureq, translate(ureq, "error.no.id"));
log.error("OAuth Login failed, no infos extracted from access token: " + accessToken);
return;
}
OAuthRegistration registration = new OAuthRegistration(provider.getProviderName(), infos);
login(infos, registration);
if (provider instanceof OAuthUserCreator) {
Identity newIdentity;
OAuthUserCreator userCreator = (OAuthUserCreator) provider;
if (registration.getIdentity() == null) {
newIdentity = userCreator.createUser(infos);
} else {
newIdentity = userCreator.updateUser(infos, registration.getIdentity());
}
if (newIdentity != null) {
registration.setIdentity(newIdentity);
}
}
if (registration.getIdentity() == null) {
if (CoreSpringFactory.getImpl(OAuthLoginModule.class).isAllowUserCreation()) {
register(request, response, registration);
} else {
error(ureq, translate(ureq, "error.account.creation"));
log.error("OAuth Login ok but the user has not an account on OpenOLAT: " + infos);
}
} else {
if (ureq.getUserSession() != null) {
// re-init the activity logger
ThreadLocalUserActivityLoggerInstaller.initUserActivityLogger(request);
}
Identity identity = registration.getIdentity();
int loginStatus = AuthHelper.doLogin(identity, provider.getProviderName(), ureq);
if (loginStatus != AuthHelper.LOGIN_OK) {
if (loginStatus == AuthHelper.LOGIN_NOTAVAILABLE) {
DispatcherModule.redirectToServiceNotAvailable(response);
} else {
// error, redirect to login screen
DispatcherModule.redirectToDefaultDispatcher(response);
}
} else {
// update last login date and register active user
UserDeletionManager.getInstance().setIdentityAsActiv(identity);
MediaResource mr = ureq.getDispatchResult().getResultingMediaResource();
if (mr instanceof RedirectMediaResource) {
RedirectMediaResource rmr = (RedirectMediaResource) mr;
rmr.prepare(response);
} else {
// error, redirect to login screen
DispatcherModule.redirectToDefaultDispatcher(response);
}
}
}
} catch (Exception e) {
log.error("Unexpected error", e);
error(ureq, translate(ureq, "error.generic"));
}
}
Aggregations