Search in sources :

Example 21 with RedirectMediaResource

use of org.olat.core.gui.media.RedirectMediaResource in project openolat by klemens.

the class RecordingsTableModel method openWimbaUrl.

private void openWimbaUrl(UserRequest ureq, String target) {
    boolean success = false;
    if (target.equals(COMMAND_OPEN_WIZARD)) {
        String url = wimba.createServiceUrl(target, null);
        RedirectMediaResource rmr = new RedirectMediaResource(url);
        ureq.getDispatchResult().setResultingMediaResource(rmr);
    } else {
        success = wimba.createModerator(ureq.getIdentity(), roomId);
        if (success) {
            wimba.login(ureq.getIdentity(), null);
            String url = wimba.createServiceUrl(target, roomId);
            RedirectMediaResource rmr = new RedirectMediaResource(url);
            ureq.getDispatchResult().setResultingMediaResource(rmr);
        } else {
            // could not create moderator or update the rights
            getWindowControl().setError(translate("error.update.rights"));
            return;
        }
    }
}
Also used : RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource)

Example 22 with RedirectMediaResource

use of org.olat.core.gui.media.RedirectMediaResource in project openolat by klemens.

the class AdobeDisplayController method event.

@Override
protected void event(UserRequest ureq, Component source, Event event) {
    if (source == startModerator) {
        /*
			 * create new meeting room and prepare to join it
			 */
        boolean success = adobe.createClassroom(roomId, null, null, allBegin, allEnd, config);
        if (success) {
            runVC.contextPut("exists", true);
            runVC.setDirty(true);
        } else {
            getWindowControl().setError(translate("error.create.room"));
        }
    } else if (source == startJoinLearner) {
        /*
			 * create new meeting room and join immediately as guest
			 */
        boolean success = adobe.createClassroom(roomId, null, null, allBegin, allEnd, config);
        if (success) {
            runVC.contextPut("exists", true);
            runVC.setDirty(true);
            // join meeting as guest
            URL url = adobe.createClassroomGuestUrl(roomId, ureq.getIdentity(), config);
            RedirectMediaResource rmr = new RedirectMediaResource(url.toString());
            ureq.getDispatchResult().setResultingMediaResource(rmr);
            return;
        } else {
            getWindowControl().setError(translate("error.create.room"));
        }
    } else if (source == joinLearner) {
        /*
			 * easiest case: simply generate link to join meeting as guest
			 */
        URL url = adobe.createClassroomGuestUrl(roomId, ureq.getIdentity(), config);
        RedirectMediaResource rmr = new RedirectMediaResource(url.toString());
        ureq.getDispatchResult().setResultingMediaResource(rmr);
        return;
    } else if (source == joinModerator) {
        /*
			 * join meeting as moderator, first prepare user to have appropriate rights
			 */
        boolean success = adobe.existsClassroom(roomId, config);
        // update rights for user to moderate meeting
        if (success) {
            success = adobe.createModerator(ureq.getIdentity(), roomId);
        } else {
            // room not found, should not appear
            getWindowControl().setError(translate("error.no.room"));
            return;
        }
        // login the user as moderator
        if (success) {
            success = adobe.login(ureq.getIdentity(), null);
        } else {
            // could not create moderator or update the rights
            getWindowControl().setError(translate("error.update.rights"));
            return;
        }
        // redirect to the meeting
        if (success) {
            URL url = adobe.createClassroomUrl(roomId, ureq.getIdentity(), config);
            RedirectMediaResource rmr = new RedirectMediaResource(url.toString());
            ureq.getDispatchResult().setResultingMediaResource(rmr);
        } else {
            // login failed
            getWindowControl().setError(translate("error.no.login"));
            return;
        }
        return;
    } else if (source == removeMeeting) {
        boolean success = adobe.removeClassroom(roomId, config);
        if (success) {
            runVC.contextPut("exists", false);
            runVC.setDirty(true);
        } else {
            // removing failed
            getWindowControl().setError(translate("error.remove.room"));
        }
    } else if (source == updateMeeting) {
        boolean success = adobe.updateClassroom(roomId, null, null, allBegin, allEnd, config);
        if (success) {
            getWindowControl().setInfo(translate("success.update.room"));
        } else {
            // update failed
            getWindowControl().setError(translate("error.update.room"));
        }
    }
}
Also used : RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource) URL(java.net.URL)

Example 23 with RedirectMediaResource

use of org.olat.core.gui.media.RedirectMediaResource in project OpenOLAT by OpenOLAT.

the class ViteroBookingsController method openVitero.

protected void openVitero(UserRequest ureq, ViteroBooking booking) {
    try {
        String url = viteroManager.getURLToBooking(ureq.getIdentity(), booking);
        RedirectMediaResource redirect = new RedirectMediaResource(url);
        ureq.getDispatchResult().setResultingMediaResource(redirect);
    } catch (VmsNotAvailableException e) {
        showError(VmsNotAvailableException.I18N_KEY);
    }
}
Also used : VmsNotAvailableException(org.olat.modules.vitero.manager.VmsNotAvailableException) RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource)

Example 24 with RedirectMediaResource

use of org.olat.core.gui.media.RedirectMediaResource in project OpenOLAT by OpenOLAT.

the class RegistrationController method event.

/**
 * @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 == emailSendForm) {
        if (event == Event.DONE_EVENT) {
            // form
            // validation
            // was ok
            wizInfoController.setCurStep(2);
            // Email requested for tempkey
            // save the fields somewhere
            String email = emailSendForm.getEmailAddress();
            myContent.contextPut("email", email);
            myContent.contextPut("text", translate("step2.reg.text", email));
            // ef.setVisible(false);
            regarea.setVisible(false);
            // get remote address
            String ip = ureq.getHttpReq().getRemoteAddr();
            String serverpath = Settings.getServerContextPathURI();
            String today = DateFormat.getDateInstance(DateFormat.LONG, ureq.getLocale()).format(new Date());
            String[] whereFromAttrs = new String[] { serverpath, today, ip };
            boolean isMailSent = false;
            if (registrationManager.isRegistrationPending(email) || UserManager.getInstance().isEmailAllowed(email)) {
                TemporaryKey tk = null;
                if (userModule.isEmailUnique()) {
                    tk = registrationManager.loadTemporaryKeyByEmail(email);
                }
                if (tk == null)
                    tk = registrationManager.loadOrCreateTemporaryKeyByEmail(email, ip, RegistrationManager.REGISTRATION);
                myContent.contextPut("regKey", tk.getRegistrationKey());
                String link = serverpath + "/dmz/registration/index.html?key=" + tk.getRegistrationKey() + "&language=" + i18nModule.getLocaleKey(ureq.getLocale());
                String[] bodyAttrs = new String[] { // 0
                serverpath, // 1
                tk.getRegistrationKey(), // 2
                i18nModule.getLocaleKey(ureq.getLocale()), // 3
                "<a href=\"" + link + "\">" + link + "</a>" };
                String body = translate("reg.body", bodyAttrs);
                boolean htmlBody = StringHelper.isHtml(body);
                if (!htmlBody) {
                    body += SEPARATOR + translate("reg.wherefrom", whereFromAttrs);
                }
                try {
                    MailBundle bundle = new MailBundle();
                    bundle.setTo(email);
                    bundle.setContent(translate("reg.subject"), body);
                    MailerResult result = mailManager.sendExternMessage(bundle, null, htmlBody);
                    if (result.isSuccessful()) {
                        isMailSent = true;
                    }
                } catch (Exception e) {
                // nothing to do, emailSent flag is false, errors will be reported to user
                }
            } else {
                // if users with this email address exists, they are informed.
                List<Identity> identities = UserManager.getInstance().findIdentitiesByEmail(Collections.singletonList(email));
                for (Identity identity : identities) {
                    String body = translate("login.body", identity.getName()) + SEPARATOR + translate("reg.wherefrom", whereFromAttrs);
                    try {
                        MailBundle bundle = new MailBundle();
                        bundle.setTo(email);
                        bundle.setContent(translate("login.subject"), body);
                        MailerResult result = mailManager.sendExternMessage(bundle, null, true);
                        if (result.isSuccessful()) {
                            isMailSent = true;
                        }
                    } catch (Exception e) {
                    // nothing to do, emailSent flag is false, errors will be reported to user
                    }
                }
            }
            if (isMailSent) {
                showInfo("email.sent");
            } else {
                showError("email.notsent");
            }
        } else if (event == Event.CANCELLED_EVENT) {
            fireEvent(ureq, Event.CANCELLED_EVENT);
        }
    } else if (source == langChooserController) {
        if (event == Event.DONE_EVENT) {
            wizInfoController.setCurStep(2);
            createEmailForm(ureq);
            ureq.getUserSession().removeEntry(LocaleNegotiator.NEGOTIATED_LOCALE);
        } else if (event == Event.CANCELLED_EVENT) {
            ureq.getDispatchResult().setResultingMediaResource(new RedirectMediaResource(Settings.getServerContextPathURI()));
        } else if (event instanceof LanguageChangedEvent) {
            LanguageChangedEvent lcev = (LanguageChangedEvent) event;
            setLocale(lcev.getNewLocale(), true);
            myContent.contextPut("text", translate("select.language.description"));
        }
    } else if (source == registrationForm) {
        // Userdata entered
        if (event == Event.DONE_EVENT) {
            String lang = registrationForm.getLangKey();
            // change language if different then current language
            if (!lang.equals(i18nModule.getLocaleKey(ureq.getLocale()))) {
                Locale loc = i18nManager.getLocaleOrDefault(lang);
                ureq.getUserSession().setLocale(loc);
                getTranslator().setLocale(loc);
            }
            wizInfoController.setCurStep(4);
            myContent.contextPut("pwdhelp", "");
            myContent.contextPut("loginhelp", "");
            myContent.contextPut("text", translate("step4.reg.text"));
            removeAsListenerAndDispose(disclaimerController);
            disclaimerController = new DisclaimerController(ureq, getWindowControl());
            listenTo(disclaimerController);
            regarea.setContent(disclaimerController.getInitialComponent());
        } else if (event == Event.CANCELLED_EVENT) {
            ureq.getDispatchResult().setResultingMediaResource(new RedirectMediaResource(Settings.getServerContextPathURI()));
        }
    } else if (source == disclaimerController) {
        if (event == Event.DONE_EVENT) {
            // finalize the registration by creating the user
            Identity persitedIdentity = createNewUserAfterRegistration();
            // display step5
            displayFinalStep(persitedIdentity);
        } else if (event == Event.CANCELLED_EVENT) {
            ureq.getDispatchResult().setResultingMediaResource(new RedirectMediaResource(Settings.getServerContextPathURI()));
        }
    }
}
Also used : Locale(java.util.Locale) MailerResult(org.olat.core.util.mail.MailerResult) LanguageChangedEvent(org.olat.core.commons.chiefcontrollers.LanguageChangedEvent) Date(java.util.Date) RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource) MailBundle(org.olat.core.util.mail.MailBundle) Identity(org.olat.core.id.Identity)

Example 25 with RedirectMediaResource

use of org.olat.core.gui.media.RedirectMediaResource in project OpenOLAT by OpenOLAT.

the class ShibbolethDispatcher method execute.

/**
 * Main method called by OpenOLATServlet.
 * This processess all shibboleth requests.
 *
 * @param req
 * @param resp
 * @param uriPrefix
 */
@Override
public void execute(HttpServletRequest req, HttpServletResponse resp) {
    if (translator == null) {
        translator = Util.createPackageTranslator(ShibbolethDispatcher.class, I18nModule.getDefaultLocale());
    }
    if (!shibbolethModule.isEnableShibbolethLogins()) {
        throw new OLATSecurityException("Got shibboleth request but shibboleth is not enabled");
    }
    String uriPrefix = DispatcherModule.getLegacyUriPrefix(req);
    Map<String, String> attributesMap = getShibbolethAttributesFromRequest(req);
    ShibbolethAttributes shibbolethAttriutes = CoreSpringFactory.getImpl(ShibbolethAttributes.class);
    shibbolethAttriutes.init(attributesMap);
    String uid = shibbolethAttriutes.getUID();
    if (uid == null) {
        handleException(new ShibbolethException(ShibbolethException.UNIQUE_ID_NOT_FOUND, "Unable to get unique identifier for subject. Make sure you are listed in the metadata.xml file and your resources your are trying to access are available and your are allowed to see them. (Resourceregistry). "), req, resp, translator);
        return;
    }
    if (!authorization(req, resp, shibbolethAttriutes)) {
        return;
    }
    UserRequest ureq = null;
    try {
        // upon creation URL is checked for
        ureq = new UserRequestImpl(uriPrefix, req, resp);
    } catch (NumberFormatException nfe) {
        // a 404 message must be shown -> e.g. robots correct their links.
        if (log.isDebug()) {
            log.debug("Bad Request " + req.getPathInfo());
        }
        DispatcherModule.sendBadRequest(req.getPathInfo(), resp);
        return;
    }
    Authentication auth = securityManager.findAuthenticationByAuthusername(uid, PROVIDER_SHIB);
    if (auth == null) {
        // no matching authentication...
        ShibbolethRegistrationController.putShibAttributes(req, shibbolethAttriutes);
        ShibbolethRegistrationController.putShibUniqueID(req, uid);
        redirectToShibbolethRegistration(resp);
        return;
    }
    if (ureq.getUserSession() != null) {
        // re-init the activity logger
        ThreadLocalUserActivityLoggerInstaller.initUserActivityLogger(req);
    }
    int loginStatus = AuthHelper.doLogin(auth.getIdentity(), ShibbolethDispatcher.PROVIDER_SHIB, ureq);
    if (loginStatus != AuthHelper.LOGIN_OK) {
        if (loginStatus == AuthHelper.LOGIN_NOTAVAILABLE) {
            DispatcherModule.redirectToServiceNotAvailable(resp);
        } else {
            // error, redirect to login screen
            DispatcherModule.redirectToDefaultDispatcher(resp);
        }
        return;
    }
    // Successful login
    Identity authenticationedIdentity = ureq.getIdentity();
    userDeletionManager.setIdentityAsActiv(authenticationedIdentity);
    shibbolethManager.syncUser(authenticationedIdentity, shibbolethAttriutes);
    ureq.getUserSession().getIdentityEnvironment().addAttributes(shibbolethModule.getAttributeTranslator().translateAttributesMap(shibbolethAttriutes.toMap()));
    MediaResource mr = ureq.getDispatchResult().getResultingMediaResource();
    if (mr instanceof RedirectMediaResource) {
        RedirectMediaResource rmr = (RedirectMediaResource) mr;
        rmr.prepare(resp);
    } else {
        // error, redirect to login screen
        DispatcherModule.redirectToDefaultDispatcher(resp);
    }
}
Also used : ShibbolethAttributes(org.olat.shibboleth.manager.ShibbolethAttributes) Authentication(org.olat.basesecurity.Authentication) OLATSecurityException(org.olat.core.logging.OLATSecurityException) RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource) MediaResource(org.olat.core.gui.media.MediaResource) RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource) Identity(org.olat.core.id.Identity) UserRequest(org.olat.core.gui.UserRequest) UserRequestImpl(org.olat.core.gui.UserRequestImpl)

Aggregations

RedirectMediaResource (org.olat.core.gui.media.RedirectMediaResource)48 MediaResource (org.olat.core.gui.media.MediaResource)16 Identity (org.olat.core.id.Identity)8 URL (java.net.URL)6 UserRequest (org.olat.core.gui.UserRequest)6 Window (org.olat.core.gui.components.Window)6 UserSession (org.olat.core.util.UserSession)6 IOException (java.io.IOException)4 HttpSession (javax.servlet.http.HttpSession)4 ChiefController (org.olat.core.gui.control.ChiefController)4 WindowBackOffice (org.olat.core.gui.control.WindowBackOffice)4 StringOutput (org.olat.core.gui.render.StringOutput)4 URLBuilder (org.olat.core.gui.render.URLBuilder)4 AssertException (org.olat.core.logging.AssertException)4 UserRequestImpl (org.olat.core.gui.UserRequestImpl)3 GoToError (org.olat.modules.gotomeeting.model.GoToError)3 OpenMeetingsException (org.olat.modules.openmeetings.manager.OpenMeetingsException)3 ArrayList (java.util.ArrayList)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2