Example usage for com.liferay.portal.kernel.theme ThemeDisplay getURLSignIn

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getURLSignIn

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay getURLSignIn.

Prototype

public String getURLSignIn() 

Source Link

Usage

From source file:com.liferay.invitation.invite.members.web.internal.portlet.InviteMembersPortlet.java

License:Open Source License

protected void doSendInvite(ActionRequest actionRequest) throws Exception {
    long groupId = ParamUtil.getLong(actionRequest, "groupId");
    long[] receiverUserIds = getLongArray(actionRequest, "receiverUserIds");
    String[] receiverEmailAddresses = getStringArray(actionRequest, "receiverEmailAddresses");
    long invitedRoleId = ParamUtil.getLong(actionRequest, "invitedRoleId");
    long invitedTeamId = ParamUtil.getLong(actionRequest, "invitedTeamId");

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

    if (!_userLocalService.hasGroupUser(groupId, themeDisplay.getUserId())) {

        return;/*  ww w.  j  ava2s.  c om*/
    }

    ServiceContext serviceContext = ServiceContextFactory.getInstance(actionRequest);

    Group group = _groupLocalService.getGroup(groupId);

    PortletURL portletURL = PortletProviderUtil.getPortletURL(actionRequest, group,
            UserNotificationEvent.class.getName(), PortletProvider.Action.VIEW);

    serviceContext.setAttribute("redirectURL", portletURL.toString());

    HttpServletRequest request = _portal.getHttpServletRequest(actionRequest);

    String createAccountURL = _portal.getCreateAccountURL(request, themeDisplay);

    serviceContext.setAttribute("createAccountURL", createAccountURL);

    serviceContext.setAttribute("loginURL", themeDisplay.getURLSignIn());

    _memberRequestLocalService.addMemberRequests(themeDisplay.getUserId(), groupId, receiverUserIds,
            invitedRoleId, invitedTeamId, serviceContext);

    _memberRequestLocalService.addMemberRequests(themeDisplay.getUserId(), groupId, receiverEmailAddresses,
            invitedRoleId, invitedTeamId, serviceContext);
}

From source file:com.liferay.login.authentication.openid.web.internal.portlet.action.OpenIdLoginMVCActionCommand.java

License:Open Source License

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

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

    if (!_openId.isEnabled(themeDisplay.getCompanyId())) {
        throw new PrincipalException.MustBeEnabled(themeDisplay.getCompanyId(), OpenId.class.getName());
    }//from w  ww . ja v  a 2s  . c o m

    if (actionRequest.getRemoteUser() != null) {
        actionResponse.sendRedirect(themeDisplay.getPathMain());

        return;
    }

    String cmd = ParamUtil.getString(actionRequest, Constants.CMD);

    try {
        if (cmd.equals(Constants.READ)) {
            String redirect = _openIdServiceHandler.readResponse(themeDisplay, actionRequest);

            if (Validator.isNull(redirect)) {
                redirect = themeDisplay.getURLSignIn();
            }

            redirect = _portal.escapeRedirect(redirect);

            actionResponse.sendRedirect(redirect);
        } else {
            _openIdServiceHandler.sendRequest(themeDisplay, actionRequest, actionResponse);
        }
    } catch (Exception e) {
        if (e instanceof OpenIdServiceException) {
            if (_log.isInfoEnabled()) {
                _log.info("Error communicating with OpenID provider: " + e.getMessage());
            }

            SessionErrors.add(actionRequest, e.getClass());
        } else if (e instanceof UserEmailAddressException.MustNotBeDuplicate) {

            SessionErrors.add(actionRequest, e.getClass());
        } else {
            _log.error("Error processing the OpenID login", e);

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

From source file:com.liferay.login.web.internal.servlet.taglib.include.SignInNavigationPrePageInclude.java

License:Open Source License

@Override
public void include(PageContext pageContext) throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    String mvcRenderCommandName = request.getParameter("mvcRenderCommandName");

    if (Validator.isNull(mvcRenderCommandName) || "/login/login".equals(mvcRenderCommandName)) {

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

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

    String signInURL = themeDisplay.getURLSignIn();

    PortletConfig portletConfig = (PortletConfig) request.getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG);

    String portletName = portletConfig.getPortletName();

    if (portletName.equals(PortletKeys.FAST_LOGIN)) {
        PortletURL fastLoginURL = PortletURLFactoryUtil.create(request, PortletKeys.FAST_LOGIN,
                PortletRequest.RENDER_PHASE);

        fastLoginURL.setParameter("saveLastPath", Boolean.FALSE.toString());
        fastLoginURL.setParameter("mvcRenderCommandName", "/login/login");

        try {
            fastLoginURL.setPortletMode(PortletMode.VIEW);
            fastLoginURL.setWindowState(LiferayWindowState.POP_UP);
        } catch (PortletException pe) {
            throw new JspException(pe);
        }

        signInURL = fastLoginURL.toString();
    }

    IconTag iconTag = new IconTag();

    iconTag.setIconCssClass("icon-signin");
    iconTag.setMessage("sign-in");
    iconTag.setUrl(signInURL);

    iconTag.doTag(pageContext);
}