List of usage examples for com.liferay.portal.kernel.model Company getAuthType
public String getAuthType();
From source file:com.liferay.docs.mvcportlet.action.EditUserMVCActionCommand.java
License:Open Source License
@Override protected Object[] updateUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String currentPassword = actionRequest.getParameter("password0"); String newPassword = actionRequest.getParameter("password1"); User user = PortalUtil.getSelectedUser(actionRequest); if (Validator.isNotNull(currentPassword)) { if (Validator.isNull(newPassword)) { throw new UserPasswordException.MustNotBeNull(user.getUserId()); }//from www .ja v a 2s .c o m Company company = PortalUtil.getCompany(actionRequest); String authType = company.getAuthType(); Map<String, String[]> headerMap = new HashMap<>(); Map<String, String[]> parameterMap = new HashMap<>(); Map<String, Object> resultsMap = new HashMap<>(); int authResult = Authenticator.FAILURE; if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) { authResult = userLocalService.authenticateByEmailAddress(company.getCompanyId(), user.getEmailAddress(), currentPassword, headerMap, parameterMap, resultsMap); } else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) { authResult = userLocalService.authenticateByUserId(company.getCompanyId(), user.getUserId(), currentPassword, headerMap, parameterMap, resultsMap); } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) { authResult = userLocalService.authenticateByScreenName(company.getCompanyId(), user.getScreenName(), currentPassword, headerMap, parameterMap, resultsMap); } if (authResult == Authenticator.FAILURE) { throw new UserPasswordException.MustMatchCurrentPassword(user.getUserId()); } } else if (Validator.isNotNull(newPassword)) { throw new UserPasswordException.MustNotBeNull(user.getUserId()); } return super.updateUser(actionRequest, actionResponse); }
From source file:com.liferay.document.library.repository.cmis.CMISRepositoryHandler.java
License:Open Source License
public String getLogin() { String login = PrincipalThreadLocal.getName(); if (Validator.isNull(login)) { return login; }//ww w . j a v a 2 s.c om try { Company company = companyLocalService.getCompany(getCompanyId()); String authType = company.getAuthType(); if (!authType.equals(CompanyConstants.AUTH_TYPE_ID)) { User user = userLocalService.getUser(GetterUtil.getLong(login)); if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) { login = user.getEmailAddress(); } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) { login = user.getScreenName(); } } } catch (Exception e) { throw new RepositoryException(e); } return login; }
From source file:com.liferay.document.library.repository.cmis.internal.model.CMISModel.java
License:Open Source License
protected User getUser(String createdBy) { User user = null;/* w ww . j a va 2 s. c o m*/ try { Company company = CompanyLocalServiceUtil.getCompany(getCompanyId()); String authType = company.getAuthType(); if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) { user = UserLocalServiceUtil.getUser(GetterUtil.getLong(createdBy)); } else if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) { user = UserLocalServiceUtil.getUserByEmailAddress(getCompanyId(), createdBy); } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) { user = UserLocalServiceUtil.getUserByScreenName(getCompanyId(), createdBy); } } catch (Exception e) { } if (user == null) { try { user = UserLocalServiceUtil.getDefaultUser(getCompanyId()); } catch (Exception e) { } } return user; }
From source file:com.liferay.login.web.internal.portlet.action.CreateAccountMVCActionCommand.java
License:Open Source License
protected void sendRedirect(ActionRequest actionRequest, ActionResponse actionResponse, ThemeDisplay themeDisplay, User user, String password) throws Exception { String login = null;/*from w ww . jav a 2 s . co m*/ Company company = themeDisplay.getCompany(); String authType = company.getAuthType(); if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) { login = String.valueOf(user.getUserId()); } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) { login = user.getScreenName(); } else { login = user.getEmailAddress(); } HttpServletRequest request = _portal.getHttpServletRequest(actionRequest); String redirect = _portal.escapeRedirect(ParamUtil.getString(actionRequest, "redirect")); if (Validator.isNotNull(redirect)) { HttpServletResponse response = _portal.getHttpServletResponse(actionResponse); _authenticatedSessionManager.login(request, response, login, password, false, null); } else { PortletURL loginURL = LoginUtil.getLoginURL(request, themeDisplay.getPlid()); loginURL.setParameter("login", login); redirect = loginURL.toString(); } actionResponse.sendRedirect(redirect); }
From source file:com.liferay.login.web.internal.portlet.util.LoginUtil.java
License:Open Source License
public static String getLogin(HttpServletRequest request, String paramName, Company company) { String login = request.getParameter(paramName); if ((login == null) || login.equals(StringPool.NULL)) { login = CookieKeys.getCookie(request, CookieKeys.LOGIN, false); String authType = company.getAuthType(); if (PropsValues.COMPANY_LOGIN_PREPOPULATE_DOMAIN && Validator.isNull(login) && authType.equals(CompanyConstants.AUTH_TYPE_EA)) { login = "@".concat(company.getMx()); }/* ww w . ja v a 2 s. c om*/ } return login; }
From source file:com.liferay.my.account.web.internal.portlet.action.UpdatePasswordMVCActionCommand.java
License:Open Source License
protected void authenticateUser(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String currentPassword = actionRequest.getParameter("password0"); String newPassword = actionRequest.getParameter("password1"); User user = _portal.getSelectedUser(actionRequest); if (Validator.isNotNull(currentPassword)) { if (Validator.isNull(newPassword)) { throw new UserPasswordException.MustNotBeNull(user.getUserId()); }/*from w w w .j a v a2s.c o m*/ Company company = _portal.getCompany(actionRequest); String authType = company.getAuthType(); Map<String, String[]> headerMap = new HashMap<>(); Map<String, String[]> parameterMap = new HashMap<>(); Map<String, Object> resultsMap = new HashMap<>(); int authResult = Authenticator.FAILURE; if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) { authResult = _userLocalService.authenticateByEmailAddress(company.getCompanyId(), user.getEmailAddress(), currentPassword, headerMap, parameterMap, resultsMap); } else if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) { authResult = _userLocalService.authenticateByUserId(company.getCompanyId(), user.getUserId(), currentPassword, headerMap, parameterMap, resultsMap); } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) { authResult = _userLocalService.authenticateByScreenName(company.getCompanyId(), user.getScreenName(), currentPassword, headerMap, parameterMap, resultsMap); } if (authResult == Authenticator.FAILURE) { throw new UserPasswordException.MustMatchCurrentPassword(user.getUserId()); } } else if (Validator.isNotNull(newPassword)) { throw new UserPasswordException.MustNotBeNull(user.getUserId()); } }
From source file:com.slemarchand.quick.sign.up.web.portlet.QuickSignUpPortlet.java
License:Open Source License
protected User addUser(ActionRequest actionRequest, ActionResponse actionResponse, String password) throws SystemException, PortalException { ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY); Company company = themeDisplay.getCompany(); String authType = company.getAuthType(); boolean autoPassword = false; String password1 = null;/* ww w. j a v a 2 s . c o m*/ String password2 = null; boolean autoScreenName = !authType.equals(CompanyConstants.AUTH_TYPE_SN); String screenName = ParamUtil.getString(actionRequest, "screenName"); String emailAddress = ParamUtil.getString(actionRequest, "emailAddress"); long facebookId = 0; String openId = StringPool.BLANK; String firstName = ParamUtil.getString(actionRequest, "firstName"); String middleName = StringPool.BLANK; String lastName = ParamUtil.getString(actionRequest, "lastName"); int prefixId = 0; int suffixId = 0; boolean male = ParamUtil.getBoolean(actionRequest, "male", true); int birthdayMonth = 1; int birthdayDay = 1; int birthdayYear = 1970; String jobTitle = StringPool.BLANK; long[] groupIds = null; long[] organizationIds = null; long[] roleIds = null; long[] userGroupIds = null; boolean sendEmail = true; ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(), actionRequest); password1 = password; password2 = password; User user = UserServiceUtil.addUser(company.getCompanyId(), autoPassword, password1, password2, autoScreenName, screenName, emailAddress, facebookId, openId, themeDisplay.getLocale(), firstName, middleName, lastName, prefixId, suffixId, male, birthdayMonth, birthdayDay, birthdayYear, jobTitle, groupIds, organizationIds, roleIds, userGroupIds, sendEmail, serviceContext); long userId = user.getUserId(); user = UserLocalServiceUtil.updatePasswordReset(userId, false); PasswordPolicy passwordPolicy = PasswordPolicyLocalServiceUtil.getPasswordPolicyByUserId(userId); passwordPolicy.setChangeRequired(false); PasswordPolicyLocalServiceUtil.updatePasswordPolicy(passwordPolicy); if (_USERS_REMINDER_QUERIES_ENABLED) { user = UserLocalServiceUtil.updateReminderQuery(userId, StringPool.DASH, UUID.randomUUID().toString()); } user = UserLocalServiceUtil.updateAgreedToTermsOfUse(userId, true); return user; }
From source file:com.slemarchand.quick.sign.up.web.portlet.QuickSignUpPortlet.java
License:Open Source License
protected String getLogin(ThemeDisplay themeDisplay, ActionRequest actionRequest, User user) throws SystemException { Company company = themeDisplay.getCompany(); String authType = company.getAuthType(); String login;//from w w w . j ava 2 s.c o m if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) { login = user.getEmailAddress(); } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) { login = user.getScreenName(); } else { login = Long.toString(user.getUserId()); } return login; }