Search in sources :

Example 6 with ChiefController

use of org.olat.core.gui.control.ChiefController in project OpenOLAT by OpenOLAT.

the class AuthHelper method doLogin.

/**
 * Used by DMZDispatcher to do regular logins and by ShibbolethDispatcher
 * which is somewhat special because logins are handled asynchronuous ->
 * therefore a dedicated dispatcher is needed which also has to have access to
 * the doLogin() method.
 *
 * @param identity
 * @param authProvider
 * @param ureq
 * @return True if success, false otherwise.
 */
public static int doLogin(Identity identity, String authProvider, UserRequest ureq) {
    int initializeStatus = initializeLogin(identity, authProvider, ureq, false);
    if (initializeStatus != LOGIN_OK) {
        // login not successfull
        return initializeStatus;
    }
    // do logging
    ThreadLocalUserActivityLogger.log(OlatLoggingAction.OLAT_LOGIN, AuthHelper.class, LoggingResourceable.wrap(identity));
    // brasato:: fix it
    // successfull login, reregister window
    ChiefController occ;
    if (ureq.getUserSession().getRoles().isGuestOnly()) {
        occ = createGuestHome(ureq);
    } else {
        occ = createAuthHome(ureq);
    }
    Window currentWindow = occ.getWindow();
    currentWindow.setUriPrefix(WebappHelper.getServletContextPath() + DispatcherModule.PATH_AUTHENTICATED);
    Windows.getWindows(ureq).registerWindow(currentWindow);
    RedirectMediaResource redirect;
    String redirectTo = (String) ureq.getUserSession().getEntry("redirect-bc");
    if (StringHelper.containsNonWhitespace(redirectTo)) {
        String url = WebappHelper.getServletContextPath() + DispatcherModule.PATH_AUTHENTICATED + redirectTo;
        redirect = new RedirectMediaResource(url);
    } else {
        // redirect to AuthenticatedDispatcher
        // IMPORTANT: windowID has changed due to re-registering current window -> do not use ureq.getWindowID() to build new URLBuilder.
        URLBuilder ubu = new URLBuilder(WebappHelper.getServletContextPath() + DispatcherModule.PATH_AUTHENTICATED, currentWindow.getInstanceId(), "1");
        StringOutput sout = new StringOutput(30);
        ubu.buildURI(sout, null, null);
        redirect = new RedirectMediaResource(sout.toString());
    }
    ureq.getDispatchResult().setResultingMediaResource(redirect);
    return LOGIN_OK;
}
Also used : Window(org.olat.core.gui.components.Window) RedirectMediaResource(org.olat.core.gui.media.RedirectMediaResource) StringOutput(org.olat.core.gui.render.StringOutput) ChiefController(org.olat.core.gui.control.ChiefController) URLBuilder(org.olat.core.gui.render.URLBuilder)

Example 7 with ChiefController

use of org.olat.core.gui.control.ChiefController in project OpenOLAT by OpenOLAT.

the class LayoutMain3ColsBackController method setAsFullscreen.

public void setAsFullscreen() {
    ChiefController cc = getWindowControl().getWindowBackOffice().getChiefController();
    if (cc != null) {
        thebaseChief = cc;
        thebaseChief.getScreenMode().setMode(Mode.full);
    }
    fullScreen = true;
}
Also used : ChiefController(org.olat.core.gui.control.ChiefController)

Example 8 with ChiefController

use of org.olat.core.gui.control.ChiefController in project OpenOLAT by OpenOLAT.

the class LayoutMain3ColsPreviewController method setAsFullscreen.

public void setAsFullscreen() {
    ChiefController cc = getWindowControl().getWindowBackOffice().getChiefController();
    if (cc != null) {
        thebaseChief = cc;
        thebaseChief.getScreenMode().setMode(Mode.full);
    }
    fullScreen = true;
}
Also used : ChiefController(org.olat.core.gui.control.ChiefController)

Example 9 with ChiefController

use of org.olat.core.gui.control.ChiefController in project OpenOLAT by OpenOLAT.

the class ShibbolethDispatcher method handleException.

/**
 * It first tries to catch the frequent SAMLExceptions and to ask the user to login again.
 * It basically lets the user to login again without getting a RedScreen if one of the most
 * frequent shibboleth error occurs. Else a RedScreen is the last option.
 * @param e
 * @param req
 * @param resp
 */
private void handleException(Throwable e, HttpServletRequest req, HttpServletResponse resp, Translator transl) {
    UserRequest ureq = new UserRequestImpl(ShibbolethDispatcher.PATH_SHIBBOLETH, req, resp);
    if (e instanceof ShibbolethException) {
        String userMsg = "";
        int errorCode = ((ShibbolethException) e).getErrorCode();
        switch(errorCode) {
            case ShibbolethException.GENERAL_SAML_ERROR:
                userMsg = transl.translate("error.shibboleth.generic");
                break;
            case ShibbolethException.UNIQUE_ID_NOT_FOUND:
                userMsg = transl.translate("error.unqueid.notfound");
                break;
            default:
                userMsg = transl.translate("error.shibboleth.generic");
                break;
        }
        showMessage(ureq, "org.opensaml.SAMLException: " + e.getMessage(), e, userMsg, ((ShibbolethException) e).getContactPersonEmail());
        return;
    } else {
        try {
            ChiefController msgcc = MsgFactory.createMessageChiefController(ureq, new OLATRuntimeException("Error processing Shibboleth request: " + e.getMessage(), e), false);
            msgcc.getWindow().dispatchRequest(ureq, true);
        } catch (Throwable t) {
            log.error("We're fucked up....", t);
        }
    }
}
Also used : OLATRuntimeException(org.olat.core.logging.OLATRuntimeException) ChiefController(org.olat.core.gui.control.ChiefController) UserRequest(org.olat.core.gui.UserRequest) UserRequestImpl(org.olat.core.gui.UserRequestImpl)

Example 10 with ChiefController

use of org.olat.core.gui.control.ChiefController in project OpenOLAT by OpenOLAT.

the class ShibbolethDispatcher method authorization.

private boolean authorization(HttpServletRequest req, HttpServletResponse resp, ShibbolethAttributes shibbolethAttibutes) {
    boolean authorized = false;
    if (shibbolethModule.isAccessControlByAttributes()) {
        if (StringHelper.containsNonWhitespace(shibbolethModule.getAttribute1()) && StringHelper.containsNonWhitespace(shibbolethModule.getAttribute1Values())) {
            authorized |= authorization(shibbolethModule.getAttribute1(), shibbolethModule.getAttribute1Values(), shibbolethAttibutes);
        }
        if (StringHelper.containsNonWhitespace(shibbolethModule.getAttribute2()) && StringHelper.containsNonWhitespace(shibbolethModule.getAttribute2Values())) {
            authorized |= authorization(shibbolethModule.getAttribute2(), shibbolethModule.getAttribute2Values(), shibbolethAttibutes);
        }
    } else {
        authorized = true;
    }
    if (!authorized) {
        UserRequest ureq = new UserRequestImpl(ShibbolethDispatcher.PATH_SHIBBOLETH, req, resp);
        String userMsg = translator.translate("error.shibboleth.not.authorized");
        ChiefController msgcc = MessageWindowController.createMessageChiefController(ureq, null, userMsg, null);
        msgcc.getWindow().dispatchRequest(ureq, true);
    }
    return authorized;
}
Also used : ChiefController(org.olat.core.gui.control.ChiefController) UserRequest(org.olat.core.gui.UserRequest) UserRequestImpl(org.olat.core.gui.UserRequestImpl)

Aggregations

ChiefController (org.olat.core.gui.control.ChiefController)58 UserRequest (org.olat.core.gui.UserRequest)10 UserRequestImpl (org.olat.core.gui.UserRequestImpl)10 IOException (java.io.IOException)8 Window (org.olat.core.gui.components.Window)8 InvalidRequestParameterException (org.olat.core.gui.components.form.flexible.impl.InvalidRequestParameterException)8 WindowControl (org.olat.core.gui.control.WindowControl)8 OLATRuntimeException (org.olat.core.logging.OLATRuntimeException)8 ArrayList (java.util.ArrayList)6 BaseFullWebappController (org.olat.core.commons.fullWebApp.BaseFullWebappController)6 StringOutput (org.olat.core.gui.render.StringOutput)6 URLBuilder (org.olat.core.gui.render.URLBuilder)6 AssertException (org.olat.core.logging.AssertException)6 UserSession (org.olat.core.util.UserSession)6 HttpSession (javax.servlet.http.HttpSession)4 BaseFullWebappControllerParts (org.olat.core.commons.fullWebApp.BaseFullWebappControllerParts)4 Windows (org.olat.core.gui.Windows)4 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)4 RedirectMediaResource (org.olat.core.gui.media.RedirectMediaResource)4 ContextEntry (org.olat.core.id.context.ContextEntry)4