List of usage examples for com.liferay.portal.kernel.util PropsKeys COMPANY_SECURITY_STRANGERS
String COMPANY_SECURITY_STRANGERS
To view the source code for com.liferay.portal.kernel.util PropsKeys COMPANY_SECURITY_STRANGERS.
Click Source Link
From source file:com.liferay.login.web.internal.portlet.action.CreateAccountMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); if (!company.isStrangers()) { throw new PrincipalException.MustBeEnabled(company.getCompanyId(), PropsKeys.COMPANY_SECURITY_STRANGERS); }// w w w.j av a2s . c o m actionRequest = _wrapActionRequest(actionRequest); String cmd = ParamUtil.getString(actionRequest, Constants.CMD); try { if (cmd.equals(Constants.ADD)) { CaptchaConfiguration captchaConfiguration = getCaptchaConfiguration(); if (captchaConfiguration.createAccountCaptchaEnabled()) { CaptchaUtil.check(actionRequest); } addUser(actionRequest, actionResponse); } else if (cmd.equals(Constants.RESET)) { resetUser(actionRequest, actionResponse); } else if (cmd.equals(Constants.UPDATE)) { updateIncompleteUser(actionRequest, actionResponse); } } catch (Exception e) { if (e instanceof UserEmailAddressException.MustNotBeDuplicate || e instanceof UserScreenNameException.MustNotBeDuplicate) { String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); User user = _userLocalService.fetchUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if ((user == null) || (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE)) { SessionErrors.add(actionRequest, e.getClass(), e); } else { actionResponse.setRenderParameter("mvcPath", "/update_account.jsp"); } } else if (e instanceof AddressCityException || e instanceof AddressStreetException || e instanceof AddressZipException || e instanceof CaptchaConfigurationException || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException || e instanceof ContactBirthdayException || e instanceof ContactNameException || e instanceof DuplicateOpenIdException || e instanceof EmailAddressException || e instanceof GroupFriendlyURLException || e instanceof NoSuchCountryException || e instanceof NoSuchListTypeException || e instanceof NoSuchOrganizationException || e instanceof NoSuchRegionException || e instanceof OrganizationParentException || e instanceof PhoneNumberException || e instanceof RequiredFieldException || e instanceof RequiredUserException || e instanceof TermsOfUseException || e instanceof UserEmailAddressException || e instanceof UserIdException || e instanceof UserPasswordException || e instanceof UserScreenNameException || e instanceof UserSmsException || e instanceof WebsiteURLException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { throw e; } } if (Validator.isNull(PropsValues.COMPANY_SECURITY_STRANGERS_URL)) { return; } try { Layout layout = _layoutLocalService.getFriendlyURLLayout(themeDisplay.getScopeGroupId(), false, PropsValues.COMPANY_SECURITY_STRANGERS_URL); String redirect = _portal.getLayoutURL(layout, themeDisplay); sendRedirect(actionRequest, actionResponse, redirect); } catch (NoSuchLayoutException nsle) { // LPS-52675 if (_log.isDebugEnabled()) { _log.debug(nsle, nsle); } } }
From source file:com.liferay.login.web.internal.portlet.action.CreateAnonymousAccountMVCActionCommand.java
License:Open Source License
@Override protected void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); PortletConfig portletConfig = (PortletConfig) actionRequest .getAttribute(JavaConstants.JAVAX_PORTLET_CONFIG); String portletName = portletConfig.getPortletName(); if (!portletName.equals(LoginPortletKeys.FAST_LOGIN)) { throw new PrincipalException("Unable to create anonymous account"); }//from w w w .j ava2 s . c o m if (actionRequest.getRemoteUser() != null) { actionResponse.sendRedirect(themeDisplay.getPathMain()); return; } String cmd = ParamUtil.getString(actionRequest, Constants.CMD); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); PortletURL portletURL = PortletURLFactoryUtil.create(actionRequest, LoginPortletKeys.FAST_LOGIN, PortletRequest.RENDER_PHASE); portletURL.setParameter("mvcRenderCommandName", "/login/login_redirect"); portletURL.setParameter("emailAddress", emailAddress); portletURL.setParameter("anonymousUser", Boolean.TRUE.toString()); portletURL.setWindowState(LiferayWindowState.POP_UP); JSONObject jsonObject = JSONFactoryUtil.createJSONObject(); try { if (cmd.equals(Constants.ADD)) { addAnonymousUser(actionRequest, actionResponse); sendRedirect(actionRequest, actionResponse, portletURL.toString()); } else if (cmd.equals(Constants.UPDATE)) { Company company = themeDisplay.getCompany(); if (!company.isStrangers()) { throw new PrincipalException.MustBeEnabled(company.getCompanyId(), PropsKeys.COMPANY_SECURITY_STRANGERS); } jsonObject = updateIncompleteUser(actionRequest, actionResponse); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } } catch (Exception e) { if (cmd.equals(Constants.UPDATE)) { jsonObject.putException(e); JSONPortletResponseUtil.writeJSON(actionRequest, actionResponse, jsonObject); } else if (e instanceof UserEmailAddressException.MustNotBeDuplicate) { User user = _userLocalService.getUserByEmailAddress(themeDisplay.getCompanyId(), emailAddress); if (user.getStatus() != WorkflowConstants.STATUS_INCOMPLETE) { SessionErrors.add(actionRequest, e.getClass()); } else { sendRedirect(actionRequest, actionResponse, portletURL.toString()); } } else if (e instanceof CaptchaConfigurationException || e instanceof CaptchaTextException || e instanceof CompanyMaxUsersException || e instanceof ContactNameException || e instanceof EmailAddressException || e instanceof GroupFriendlyURLException || e instanceof UserEmailAddressException) { SessionErrors.add(actionRequest, e.getClass(), e); } else { _log.error("Unable to create anonymous account", e); _portal.sendError(e, actionRequest, actionResponse); } } }