Example usage for com.liferay.portal.util PropsValues AUTH_LOGIN_DISABLED

List of usage examples for com.liferay.portal.util PropsValues AUTH_LOGIN_DISABLED

Introduction

In this page you can find the example usage for com.liferay.portal.util PropsValues AUTH_LOGIN_DISABLED.

Prototype

boolean AUTH_LOGIN_DISABLED

To view the source code for com.liferay.portal.util PropsValues AUTH_LOGIN_DISABLED.

Click Source Link

Usage

From source file:com.liferay.login.web.internal.portlet.action.LoginMVCActionCommand.java

License:Open Source License

@Override
protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (PropsValues.AUTH_LOGIN_DISABLED) {
        actionResponse.sendRedirect(themeDisplay.getPathMain() + PropsValues.AUTH_LOGIN_DISABLED_PATH);

        return;//from   w ww . ja  v a  2  s. co  m
    }

    /*if (actionRequest.getRemoteUser() != null) {
       actionResponse.sendRedirect(themeDisplay.getPathMain());
            
       return;
    }*/

    try {
        login(themeDisplay, actionRequest, actionResponse);

        boolean doActionAfterLogin = ParamUtil.getBoolean(actionRequest, "doActionAfterLogin");

        if (doActionAfterLogin) {
            LiferayPortletResponse liferayPortletResponse = _portal.getLiferayPortletResponse(actionResponse);

            PortletURL renderURL = liferayPortletResponse.createRenderURL();

            renderURL.setParameter("mvcRenderCommandName", "/login/login_redirect");

            actionRequest.setAttribute(WebKeys.REDIRECT, renderURL.toString());
        }
    } catch (Exception e) {
        if (e instanceof AuthException) {
            Throwable cause = e.getCause();

            if (cause instanceof PasswordExpiredException || cause instanceof UserLockoutException) {

                SessionErrors.add(actionRequest, cause.getClass(), cause);
            } else {
                if (_log.isInfoEnabled()) {
                    _log.info("Authentication failed");
                }

                SessionErrors.add(actionRequest, e.getClass());
            }
        } else if (e instanceof CompanyMaxUsersException || e instanceof CookieNotSupportedException
                || e instanceof NoSuchUserException || e instanceof PasswordExpiredException
                || e instanceof UserEmailAddressException || e instanceof UserIdException
                || e instanceof UserLockoutException || e instanceof UserPasswordException
                || e instanceof UserScreenNameException) {

            SessionErrors.add(actionRequest, e.getClass(), e);
        } else {
            _log.error(e, e);

            _portal.sendError(e, actionRequest, actionResponse);

            return;
        }

        postProcessAuthFailure(actionRequest, actionResponse);
    }
}

From source file:com.liferay.portlet.login.action.LoginAction.java

License:Open Source License

@Override
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (PropsValues.AUTH_LOGIN_DISABLED) {
        actionResponse.sendRedirect(themeDisplay.getPathMain() + PropsValues.AUTH_LOGIN_DISABLED_PATH);

        return;/*from   w  ww . ja  v a2  s. c  om*/
    }

    /*if (actionRequest.getRemoteUser() != null) {
       actionResponse.sendRedirect(themeDisplay.getPathMain());
            
       return;
    }*/

    try {
        PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest);

        login(themeDisplay, actionRequest, actionResponse, preferences);

        boolean doActionAfterLogin = ParamUtil.getBoolean(actionRequest, "doActionAfterLogin");

        if (doActionAfterLogin) {
            setForward(actionRequest, "portlet.login.login_redirect");
        }
    } catch (Exception e) {
        if (e instanceof AuthException) {
            Throwable cause = e.getCause();

            if (cause instanceof PasswordExpiredException || cause instanceof UserLockoutException) {

                SessionErrors.add(actionRequest, cause.getClass().getName());
            } else {
                if (_log.isInfoEnabled()) {
                    _log.info("Authentication failed");
                }

                SessionErrors.add(actionRequest, e.getClass().getName());
            }
        } else if (e instanceof CompanyMaxUsersException || e instanceof CookieNotSupportedException
                || e instanceof NoSuchUserException || e instanceof PasswordExpiredException
                || e instanceof UserEmailAddressException || e instanceof UserIdException
                || e instanceof UserLockoutException || e instanceof UserPasswordException
                || e instanceof UserScreenNameException) {

            SessionErrors.add(actionRequest, e.getClass().getName());
        } else {
            _log.error(e, e);

            PortalUtil.sendError(e, actionRequest, actionResponse);
        }
    }
}

From source file:com.liferay.portlet.login.action.SampleLoginAction.java

License:Open Source License

@Override
public void processAction(ActionMapping actionMapping, ActionForm actionForm, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (PropsValues.AUTH_LOGIN_DISABLED) {
        actionResponse.sendRedirect(themeDisplay.getPathMain() + PropsValues.AUTH_LOGIN_DISABLED_PATH);

        return;//from w  w  w.  j  av  a 2 s.  c  o m
    }

    /*if (actionRequest.getRemoteUser() != null) {
       actionResponse.sendRedirect(themeDisplay.getPathMain());
            
       return;
    }*/

    try {
        login(themeDisplay, actionRequest, actionResponse);

        boolean doActionAfterLogin = ParamUtil.getBoolean(actionRequest, "doActionAfterLogin");

        if (doActionAfterLogin) {
            setForward(actionRequest, "portlet.login.login_redirect");
        }
    } catch (Exception e) {
        if (e instanceof AuthException) {
            Throwable cause = e.getCause();

            if (cause instanceof PasswordExpiredException || cause instanceof UserLockoutException) {

                SessionErrors.add(actionRequest, cause.getClass());
            } else {
                if (_log.isInfoEnabled()) {
                    _log.info("Authentication failed");
                }

                SessionErrors.add(actionRequest, e.getClass());
            }
        } else if (e instanceof CompanyMaxUsersException || e instanceof CookieNotSupportedException
                || e instanceof NoSuchUserException || e instanceof PasswordExpiredException
                || e instanceof UserEmailAddressException || e instanceof UserIdException
                || e instanceof UserLockoutException || e instanceof UserPasswordException
                || e instanceof UserScreenNameException) {

            SessionErrors.add(actionRequest, e.getClass());
        } else {
            _log.error(e, e);

            PortalUtil.sendError(e, actionRequest, actionResponse);

            return;
        }

        postProcessAuthFailure(actionRequest, actionResponse);
    }
}

From source file:com.test.CharterLogin.java

License:Open Source License

@Override
public void processAction(ActionMapping mapping, ActionForm form, PortletConfig portletConfig,
        ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    if (PropsValues.AUTH_LOGIN_DISABLED) {
        actionResponse.sendRedirect(themeDisplay.getPathMain() + PropsValues.AUTH_LOGIN_DISABLED_PATH);

        return;//from w  w w  . j  av  a 2 s  .com
    }

    /*if (actionRequest.getRemoteUser() != null) {
       actionResponse.sendRedirect(themeDisplay.getPathMain());
            
       return;
    }*/

    try {
        PortletPreferences preferences = PortletPreferencesFactoryUtil.getPortletSetup(actionRequest);

        login(themeDisplay, actionRequest, actionResponse, preferences);

        boolean doActionAfterLogin = ParamUtil.getBoolean(actionRequest, "doActionAfterLogin");

        if (doActionAfterLogin) {
            setForward(actionRequest, "portlet.login.login_redirect");
        }
    } catch (Exception e) {
        if (e instanceof AuthException) {
            Throwable cause = e.getCause();

            if (cause instanceof PasswordExpiredException || cause instanceof UserLockoutException) {

                SessionErrors.add(actionRequest, cause.getClass());
            } else {
                if (_log.isInfoEnabled()) {
                    _log.info("Authentication failed");
                }

                SessionErrors.add(actionRequest, e.getClass());
            }
        } else if (e instanceof CompanyMaxUsersException || e instanceof CookieNotSupportedException
                || e instanceof NoSuchUserException || e instanceof PasswordExpiredException
                || e instanceof UserEmailAddressException || e instanceof UserIdException
                || e instanceof UserLockoutException || e instanceof UserPasswordException
                || e instanceof UserScreenNameException) {

            SessionErrors.add(actionRequest, e.getClass());
        } else {
            _log.error(e, e);

            PortalUtil.sendError(e, actionRequest, actionResponse);
        }
    }
}