Search in sources :

Example 46 with ChiefController

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

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 47 with ChiefController

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

the class AuthHelper method createGuestHome.

/**
 * Create a base chief controller for the current anonymous user request
 * and initialize the first screen after login. Note, the user request
 * must be authenticated, but as an anonymous user and not a known user.
 *
 * @param ureq The authenticated user request.
 * @return The chief controller
 */
private static ChiefController createGuestHome(UserRequest ureq) {
    if (!ureq.getUserSession().isAuthenticated())
        throw new AssertException("not authenticated!");
    BaseFullWebappControllerParts guestSitesAndNav = new GuestBFWCParts();
    ChiefController cc = new BaseFullWebappController(ureq, guestSitesAndNav);
    Windows.getWindows(ureq.getUserSession()).setChiefController(cc);
    return cc;
}
Also used : BaseFullWebappController(org.olat.core.commons.fullWebApp.BaseFullWebappController) AssertException(org.olat.core.logging.AssertException) BaseFullWebappControllerParts(org.olat.core.commons.fullWebApp.BaseFullWebappControllerParts) GuestBFWCParts(org.olat.login.GuestBFWCParts) ChiefController(org.olat.core.gui.control.ChiefController)

Example 48 with ChiefController

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

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 49 with ChiefController

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

the class AuthHelper method createAuthHome.

/**
 * Create a base chief controller for the current authenticated user request
 * and initialize the first screen after login.
 *
 * @param ureq The authenticated user request.
 * @return The chief controller
 */
public static ChiefController createAuthHome(UserRequest ureq) {
    if (!ureq.getUserSession().isAuthenticated())
        throw new AssertException("not authenticated!");
    BaseFullWebappControllerParts authSitesAndNav = new AuthBFWCParts();
    ChiefController cc = new BaseFullWebappController(ureq, authSitesAndNav);
    Windows.getWindows(ureq.getUserSession()).setChiefController(cc);
    return cc;
}
Also used : BaseFullWebappController(org.olat.core.commons.fullWebApp.BaseFullWebappController) AssertException(org.olat.core.logging.AssertException) AuthBFWCParts(org.olat.login.AuthBFWCParts) BaseFullWebappControllerParts(org.olat.core.commons.fullWebApp.BaseFullWebappControllerParts) ChiefController(org.olat.core.gui.control.ChiefController)

Example 50 with ChiefController

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

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)

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