public String displayDialog() throws IOException, CmsException {

        if ((OpenCms.getSiteManager().getSites().size() > 1)
            && !OpenCms.getSiteManager().isWorkplaceRequest(getRequest())) {

            // this is a multi site-configuration, but not a request to the configured Workplace site
            // do not send any redirects to the workplace site for security reasons
            getResponse().sendError(HttpServletResponse.SC_NOT_FOUND);
            return null;
        }

        CmsObject cms = getCmsObject();
        if (shouldUseNewLogin() && (cms.getRequestContext().getCurrentUser().isGuestUser())) {
            if (getRequest().getParameter(PARAM_ACTION_LOGOUT) != null) {
                getResponse().sendRedirect(OpenCms.getLinkManager().substituteLink(cms, "/system/login"));
                return "";
            } else {
                return CmsLoginUI.displayVaadinLoginDialog(getRequest(), getResponse());
            }
        }

        m_message = null;
        if (cms.getRequestContext().getCurrentUser().isGuestUser()) {
            // user is not currently logged in
            m_action = ACTION_DISPLAY;
            m_username = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_USERNAME);
            if (m_username != null) {
                // remove white spaces, can only lead to confusion on user name
                m_username = m_username.trim();
            }
            m_password = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_PASSWORD);
            m_actionLogin = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_ACTION_LOGIN);
            m_oufqn = getRequest().getParameter(PARAM_OUFQN);
            if (m_oufqn == null) {
                m_oufqn = getPreDefOuFqn();
            }
            if (OpenCms.getLoginManager().isEnableSecurity()) {
                // security option is enabled, try to get PC type from request parameter
                m_pcType = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_PCTYPE);
            } else {
                // if security option is disabled, just set PC type to "private" to get common login dialog
                m_pcType = PCTYPE_PRIVATE;
            }

            // try to get some info from a cookie
            getCookieData();

            // set PC type to "public" as default if not already set by cookie, request or if security option is disabled
            if (m_pcType == null) {
                m_pcType = PCTYPE_PUBLIC;
            }
        } else {
            // user is already logged in
            m_oufqn = cms.getRequestContext().getOuFqn();
            m_action = ACTION_LOGIN;
            m_actionLogout = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_ACTION_LOGOUT);
        }

        if (m_oufqn == null) {
            m_oufqn = CmsOrganizationalUnit.SEPARATOR;
        }

        String actionGetOus = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_ACTION_GETOULIST);
        if (Boolean.TRUE.toString().equals(actionGetOus)) {
            return getJsonOrgUnitList();
        }

        // initialize the right ou
        m_ou = null;
        try {
            m_ou = OpenCms.getOrgUnitManager().readOrganizationalUnit(getCmsObject(), m_oufqn);
        } catch (CmsException e) {
            m_oufqn = CmsOrganizationalUnit.SEPARATOR;
            try {
                m_ou = OpenCms.getOrgUnitManager().readOrganizationalUnit(getCmsObject(), m_oufqn);
            } catch (CmsException exc) {
                LOG.error(exc.getLocalizedMessage(), exc);
            }
        }

        // initialize the requested resource
        m_requestedResource = CmsRequestUtil.getNotEmptyParameter(
            getRequest(),
            CmsWorkplaceManager.PARAM_LOGIN_REQUESTED_RESOURCE);
        if (m_requestedResource == null) {
            // no resource was requested, use default workplace URI
            m_requestedResource = CmsVaadinUtils.getWorkplaceLink();
        }

        if (Boolean.valueOf(m_actionLogin).booleanValue()) {
            CmsMessageContainer emptyValidation = validateUserAndPasswordNotEmpty(m_username, m_password);
            if (emptyValidation != null) {
                m_message = emptyValidation;
            } else {

                // try to login with the given user information
                login((m_oufqn == null ? CmsOrganizationalUnit.SEPARATOR : m_oufqn) + m_username, m_password);

                if (getLoginException() == null) {
                    // the login was successful
                    m_action = ACTION_LOGIN;

                    CmsWorkplaceSettings settings = initSiteAndProject(cms);
                    getRequest().getSession().setAttribute(CmsWorkplaceManager.SESSION_WORKPLACE_SETTINGS, settings);
                    m_directEditPath = getDirectEditPath(cms, settings.getUserSettings());
                } else {
                    // there was an error during login
                    CmsException loginException = getLoginException();

                    if (org.opencms.security.Messages.ERR_LOGIN_FAILED_DISABLED_2 == loginException.getMessageContainer().getKey()) {
                        // the user account is disabled
                        m_message = Messages.get().container(Messages.GUI_LOGIN_FAILED_DISABLED_0);
                    } else if (org.opencms.security.Messages.ERR_LOGIN_FAILED_TEMP_DISABLED_4 == loginException.getMessageContainer().getKey()) {
                        // the user account is temporarily disabled because of too many login failures
                        m_message = Messages.get().container(Messages.GUI_LOGIN_FAILED_TEMP_DISABLED_0);
                    } else if (org.opencms.security.Messages.ERR_LOGIN_FAILED_WITH_MESSAGE_1 == loginException.getMessageContainer().getKey()) {
                        // all logins have been disabled be the Administration
                        CmsLoginMessage loginMessage = OpenCms.getLoginManager().getLoginMessage();
                        if (loginMessage != null) {
                            m_message = Messages.get().container(
                                Messages.GUI_LOGIN_FAILED_WITH_MESSAGE_1,
                                loginMessage.getMessage());
                        }
                    }
                    if (m_message == null) {
                        if (loginException instanceof CmsCustomLoginException) {
                            m_message = loginException.getMessageContainer();
                        } else {
                            // any other error - display default message
                            m_message = Messages.get().container(Messages.GUI_LOGIN_FAILED_0);
                        }
                    }
                }
            }
        } else if (Boolean.valueOf(m_actionLogout).booleanValue()) {
            m_action = ACTION_LOGOUT;
            // store the workplace window data
            Cookie wpDataCookie = getCookie(getRequest(), COOKIE_WP_DATA);
            String wpData = CmsRequestUtil.getNotEmptyParameter(getRequest(), PARAM_WPDATA);
            if (wpData != null) {
                wpData = CmsEncoder.escapeXml(wpData);
                wpDataCookie.setValue(wpData);
                setCookie(wpDataCookie, false, getRequest(), getResponse());
            }
            // after logout this will automatically redirect to the login form again
            logout();
            return null;
        }

        if (m_action == ACTION_LOGIN) {
            // clear message
            m_message = null;
            // login is successful, check if the requested resource can be read
            CmsUriSplitter splitter = new CmsUriSplitter(m_requestedResource, true);
            String resource = splitter.getPrefix();
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(resource)) {
                // bad resource name, use workplace as default
                resource = CmsWorkplace.JSP_WORKPLACE_URI;
            }
            if (CmsStringUtil.isEmptyOrWhitespaceOnly(m_directEditPath)
                && !getCmsObject().existsResource(resource, CmsResourceFilter.ONLY_VISIBLE_NO_DELETED)) {
                // requested resource does either not exist or is not readable by user
                if (CmsWorkplace.JSP_WORKPLACE_URI.equals(resource)) {
                    // we know the Workplace exists, so the user does not have access to the Workplace
                    // probably this is a "Guest" user in a default setup where "Guest" has no access to the Workplace
                    m_message = Messages.get().container(Messages.GUI_LOGIN_FAILED_NO_WORKPLACE_PERMISSIONS_0);
                    m_action = ACTION_DISPLAY;
                } else if (getCmsObject().existsResource(CmsWorkplace.JSP_WORKPLACE_URI)) {
                    // resource does either not exist or is not readable, but general workplace permissions are granted
                    m_message = Messages.get().container(Messages.GUI_LOGIN_UNKNOWN_RESOURCE_1, m_requestedResource);
                    m_requestedResource = CmsWorkplace.JSP_WORKPLACE_URI;
                } else {
                    // resource does not exist and no general workplace permissions granted
                    m_message = Messages.get().container(
                        Messages.GUI_LOGIN_FAILED_NO_TARGET_PERMISSIONS_1,
                        m_requestedResource);
                    m_action = ACTION_DISPLAY;
                }
            }
            if (m_action == ACTION_DISPLAY) {
                //the login was invalid
                m_requestedResource = null;
                // destroy the generated session
                HttpSession session = getRequest().getSession(false);
                if (session != null) {
                    session.invalidate();
                }
                setCookieData(getRequest(), getResponse());
            } else {
                // successfully logged in, so set the cookie
                setCookieData(getRequest(), getResponse());
            }
        }

        return displayLoginForm();
    }
public String displayDialog ( ) throws IOException , CmsException { if ( ( OpenCms . getSiteManager ( ) . getSites ( ) . size ( ) > 1 ) && ! OpenCms . getSiteManager ( ) . isWorkplaceRequest ( getRequest ( ) ) ) { getResponse ( ) . sendError ( HttpServletResponse . SC_NOT_FOUND ) ; return null ; } CmsObject cms = getCmsObject ( ) ; if ( shouldUseNewLogin ( ) && ( cms . getRequestContext ( ) . getCurrentUser ( ) . isGuestUser ( ) ) ) { if ( getRequest ( ) . getParameter ( PARAM_ACTION_LOGOUT ) != null ) { getResponse ( ) . sendRedirect ( OpenCms . getLinkManager ( ) . substituteLink ( cms , "/system/login" ) ) ; return "" ; } else { return CmsLoginUI . displayVaadinLoginDialog ( getRequest ( ) , getResponse ( ) ) ; } } m_message = null ; if ( cms . getRequestContext ( ) . getCurrentUser ( ) . isGuestUser ( ) ) { m_action = ACTION_DISPLAY ; m_username = CmsRequestUtil . getNotEmptyParameter ( getRequest ( ) , PARAM_USERNAME ) ; if ( m_username != null ) { m_username = m_username . trim ( ) ; } m_password = CmsRequestUtil . getNotEmptyParameter ( getRequest ( ) , PARAM_PASSWORD ) ; m_actionLogin = CmsRequestUtil . getNotEmptyParameter ( getRequest ( ) , PARAM_ACTION_LOGIN ) ; m_oufqn = getRequest ( ) . getParameter ( PARAM_OUFQN ) ; if ( m_oufqn == null ) { m_oufqn = getPreDefOuFqn ( ) ; } if ( OpenCms . getLoginManager ( ) . isEnableSecurity ( ) ) { m_pcType = CmsRequestUtil . getNotEmptyParameter ( getRequest ( ) , PARAM_PCTYPE ) ; } else { m_pcType = PCTYPE_PRIVATE ; } getCookieData ( ) ; if ( m_pcType == null ) { m_pcType = PCTYPE_PUBLIC ; } } else { m_oufqn = cms . getRequestContext ( ) . getOuFqn ( ) ; m_action = ACTION_LOGIN ; m_actionLogout = CmsRequestUtil . getNotEmptyParameter ( getRequest ( ) , PARAM_ACTION_LOGOUT ) ; } if ( m_oufqn == null ) { m_oufqn = CmsOrganizationalUnit . SEPARATOR ; } String actionGetOus = CmsRequestUtil . getNotEmptyParameter ( getRequest ( ) , PARAM_ACTION_GETOULIST ) ; if ( Boolean . TRUE . toString ( ) . equals ( actionGetOus ) ) { return getJsonOrgUnitList ( ) ; } m_ou = null ; try { m_ou = OpenCms . getOrgUnitManager ( ) . readOrganizationalUnit ( getCmsObject ( ) , m_oufqn ) ; } catch ( CmsException e ) { m_oufqn = CmsOrganizationalUnit . SEPARATOR ; try { m_ou = OpenCms . getOrgUnitManager ( ) . readOrganizationalUnit ( getCmsObject ( ) , m_oufqn ) ; } catch ( CmsException exc ) { LOG . error ( exc . getLocalizedMessage ( ) , exc ) ; } } m_requestedResource = CmsRequestUtil . getNotEmptyParameter ( getRequest ( ) , CmsWorkplaceManager . PARAM_LOGIN_REQUESTED_RESOURCE ) ; if ( m_requestedResource == null ) { m_requestedResource = CmsVaadinUtils . getWorkplaceLink ( ) ; } if ( Boolean . valueOf ( m_actionLogin ) . booleanValue ( ) ) { CmsMessageContainer emptyValidation = validateUserAndPasswordNotEmpty ( m_username , m_password ) ; if ( emptyValidation != null ) { m_message = emptyValidation ; } else { login ( ( m_oufqn == null ? CmsOrganizationalUnit . SEPARATOR : m_oufqn ) + m_username , m_password ) ; if ( getLoginException ( ) == null ) { m_action = ACTION_LOGIN ; CmsWorkplaceSettings settings = initSiteAndProject ( cms ) ; getRequest ( ) . getSession ( ) . setAttribute ( CmsWorkplaceManager . SESSION_WORKPLACE_SETTINGS , settings ) ; m_directEditPath = getDirectEditPath ( cms , settings . getUserSettings ( ) ) ; } else { CmsException loginException = getLoginException ( ) ; if ( org . opencms . security . Messages . ERR_LOGIN_FAILED_DISABLED_2 == loginException . getMessageContainer ( ) . getKey ( ) ) { m_message = Messages . get ( ) . container ( Messages . GUI_LOGIN_FAILED_DISABLED_0 ) ; } else if ( org . opencms . security . Messages . ERR_LOGIN_FAILED_TEMP_DISABLED_4 == loginException . getMessageContainer ( ) . getKey ( ) ) { m_message = Messages . get ( ) . container ( Messages . GUI_LOGIN_FAILED_TEMP_DISABLED_0 ) ; } else if ( org . opencms . security . Messages . ERR_LOGIN_FAILED_WITH_MESSAGE_1 == loginException . getMessageContainer ( ) . getKey ( ) ) { CmsLoginMessage loginMessage = OpenCms . getLoginManager ( ) . getLoginMessage ( ) ; if ( loginMessage != null ) { m_message = Messages . get ( ) . container ( Messages . GUI_LOGIN_FAILED_WITH_MESSAGE_1 , loginMessage . getMessage ( ) ) ; } } if ( m_message == null ) { if ( loginException instanceof CmsCustomLoginException ) { m_message = loginException . getMessageContainer ( ) ; } else { m_message = Messages . get ( ) . container ( Messages . GUI_LOGIN_FAILED_0 ) ; } } } } } else if ( Boolean . valueOf ( m_actionLogout ) . booleanValue ( ) ) { m_action = ACTION_LOGOUT ; Cookie wpDataCookie = getCookie ( getRequest ( ) , COOKIE_WP_DATA ) ; String wpData = CmsRequestUtil . getNotEmptyParameter ( getRequest ( ) , PARAM_WPDATA ) ; if ( wpData != null ) { wpData = CmsEncoder . escapeXml ( wpData ) ; wpDataCookie . setValue ( wpData ) ; setCookie ( wpDataCookie , false , getRequest ( ) , getResponse ( ) ) ; } logout ( ) ; return null ; } if ( m_action == ACTION_LOGIN ) { m_message = null ; CmsUriSplitter splitter = new CmsUriSplitter ( m_requestedResource , true ) ; String resource = splitter . getPrefix ( ) ; if ( CmsStringUtil . isEmptyOrWhitespaceOnly ( resource ) ) { resource = CmsWorkplace . JSP_WORKPLACE_URI ; } if ( CmsStringUtil . isEmptyOrWhitespaceOnly ( m_directEditPath ) && ! getCmsObject ( ) . existsResource ( resource , CmsResourceFilter . ONLY_VISIBLE_NO_DELETED ) ) { if ( CmsWorkplace . JSP_WORKPLACE_URI . equals ( resource ) ) { m_message = Messages . get ( ) . container ( Messages . GUI_LOGIN_FAILED_NO_WORKPLACE_PERMISSIONS_0 ) ; m_action = ACTION_DISPLAY ; } else if ( getCmsObject ( ) . existsResource ( CmsWorkplace . JSP_WORKPLACE_URI ) ) { m_message = Messages . get ( ) . container ( Messages . GUI_LOGIN_UNKNOWN_RESOURCE_1 , m_requestedResource ) ; m_requestedResource = CmsWorkplace . JSP_WORKPLACE_URI ; } else { m_message = Messages . get ( ) . container ( Messages . GUI_LOGIN_FAILED_NO_TARGET_PERMISSIONS_1 , m_requestedResource ) ; m_action = ACTION_DISPLAY ; } } if ( m_action == ACTION_DISPLAY ) { m_requestedResource = null ; HttpSession session = getRequest ( ) . getSession ( false ) ; if ( session != null ) { session . invalidate ( ) ; } setCookieData ( getRequest ( ) , getResponse ( ) ) ; } else { setCookieData ( getRequest ( ) , getResponse ( ) ) ; } } return displayLoginForm ( ) ; }
Returns the HTML for the login dialog in it's current state.<p>

@return the HTML for the login dialog

@throws IOException in case a redirect fails
@throws CmsException in case displaying the login dialog fails