Examples of ThemeDisplay


Examples of com.liferay.portal.theme.ThemeDisplay

          // URLs for portlets when add-default-resource=false. It is therefore necessary to check that
          // add-default-resource=true before adding the p_p_auth parameter to the URL.
          FacesContext facesContext = FacesContext.getCurrentInstance();
          PortletRequest portletRequest = (PortletRequest) facesContext.getExternalContext().getRequest();
          String portletId = (String) portletRequest.getAttribute(WebKeys.PORTLET_ID);
          ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

          try {
            Portlet portlet = PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(),
                portletId);
            addPortletAuthToken = portlet.isAddDefaultResource();
          }
          catch (SystemException e) {
            logger.error(e);
View Full Code Here

Examples of com.liferay.portal.theme.ThemeDisplay

  public Locale getLocale() {
    Locale locale = null;

    // Try and get the current user's locale from Liferay, since they can override the locale with the Liferay
    // Language portlet.
    ThemeDisplay themeDisplay = getThemeDisplay();

    if (themeDisplay != null) {
      locale = themeDisplay.getLocale();
    }

    // If Liferay didn't return a locale, then try and get the locale from the JSF ViewRoot.
    if (locale == null) {
View Full Code Here

Examples of com.liferay.portal.theme.ThemeDisplay

  public void authenticate() {

    LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
    ActionRequest actionRequest = (ActionRequest) liferayFacesContext.getPortletRequest();
    ActionResponse actionResponse = (ActionResponse) liferayFacesContext.getPortletResponse();
    ThemeDisplay themeDisplay = liferayFacesContext.getThemeDisplay();
    HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(actionRequest);

    // If the request object is a wrapper that handles special namespacing considerations for portlet session
    // attributes, then get the inner-most wrapped request. This will ensure that the following call to
    // LoginUtil.login(...) will be able to work with a session that has an attribute map shared by the portal.
    if (httpServletRequest.getClass().getName().equals(NAMESPACE_SERVLET_REQUEST_FQCN)) {

      while (httpServletRequest instanceof HttpServletRequestWrapper) {
        HttpServletRequestWrapper httpServletRequestWrapper = (HttpServletRequestWrapper) httpServletRequest;
        httpServletRequest = (HttpServletRequest) httpServletRequestWrapper.getRequest();
      }
    }

    HttpServletResponse httpServletResponse = PortalUtil.getHttpServletResponse(actionResponse);

    String handle = loginModelBean.getHandle();
    String password = loginModelBean.getPassword();
    boolean rememberMe = loginModelBean.isRememberMe();

    boolean authenticated = false;
    String feedbackMessageId = null;

    try {

      LoginUtilCompat.invokeLogin(httpServletRequest, httpServletResponse, handle, password, rememberMe,
        authType);

      authenticated = true;
    }
    catch (AuthException e) {
      feedbackMessageId = "authentication-failed";
    }
    catch (CompanyMaxUsersException e) {
      feedbackMessageId = "unable-to-login-because-the-maximum-number-of-users-has-been-reached";
    }
    catch (CookieNotSupportedException e) {
      feedbackMessageId = "authentication-failed-please-enable-browser-cookies";
    }
    catch (NoSuchUserException e) {
      feedbackMessageId = "authentication-failed";
    }
    catch (PasswordExpiredException e) {
      feedbackMessageId = "your-password-has-expired";
    }
    catch (UserEmailAddressException e) {
      feedbackMessageId = "authentication-failed";
    }
    catch (UserLockoutException e) {
      feedbackMessageId = "this-account-has-been-locked";
    }
    catch (UserPasswordException e) {
      feedbackMessageId = "authentication-failed";
    }
    catch (UserScreenNameException e) {
      feedbackMessageId = "authentication-failed";
    }
    catch (Exception e) {
      logger.error(e);
    }

    if (authenticated) {

      try {
        ExternalContext externalContext = liferayFacesContext.getExternalContext();

        if (PropsValuesCompat.PORTAL_JAAS_ENABLE) {
          externalContext.redirect(themeDisplay.getPathMain() + "/portal/protected");
        }
        else {
          String redirect = ParamUtil.getString(actionRequest, "redirect");

          if (Validator.isNotNull(redirect)) {
            redirect = PortalUtilCompat.escapeRedirect(redirect);

            if (!redirect.startsWith(Http.HTTP)) {
              redirect = getCompleteRedirectURL(httpServletRequest, redirect);
            }

            externalContext.redirect(redirect);
          }
          else {
            boolean doActionAfterLogin = ParamUtil.getBoolean(actionRequest, "doActionAfterLogin");

            if (doActionAfterLogin) {
              return;
            }
            else {

              redirect = getCompleteRedirectURL(httpServletRequest, themeDisplay.getPathMain());
              externalContext.redirect(redirect);
            }
          }
        }
      }
View Full Code Here

Examples of com.liferay.portal.theme.ThemeDisplay

    if (authType == null) {

      LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();

      try {
        ThemeDisplay themeDisplay = liferayFacesContext.getThemeDisplay();
        Company company = themeDisplay.getCompany();

        authType = company.getAuthType();
      }
      catch (SystemException e) {
        logger.error(e);
View Full Code Here

Examples of com.liferay.portal.theme.ThemeDisplay

        throws PortletException, IOException
    {
        _log.info("calling processAction ...");

        // Determine the username
        ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
        User                 user = themeDisplay.getUser();
        String           username = user.getScreenName();
        // Determine the application pathname
        PortletSession portletSession = request.getPortletSession();
        PortletContext portletContext = portletSession.getPortletContext();
        appServerPath                 = portletContext.getRealPath("/");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.