List of usage examples for com.liferay.portal.kernel.model CompanyConstants AUTH_TYPE_EA
String AUTH_TYPE_EA
To view the source code for com.liferay.portal.kernel.model CompanyConstants AUTH_TYPE_EA.
Click Source Link
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 w w w . j a v a2 s . com*/ 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; }/* www . j a v a2 s . c o m*/ 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 w w . j a v a 2s .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.document.library.repository.external.ExtRepositoryAdapter.java
License:Open Source License
private String _getLogin() { String login = PrincipalThreadLocal.getName(); if (Validator.isNull(login) || _isDefaultUser(login)) { return PropsUtil.get(PropsKeys.DL_REPOSITORY_GUEST_USERNAME); }/*from www . jav a 2 s.c o m*/ try { String authType = 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 (PortalException | SystemException e) { if (_log.isWarnEnabled()) { _log.warn("Unable to get login to connect to external repository " + _extRepository, e); } login = null; } return login; }
From source file:com.liferay.document.library.repository.external.model.ExtRepositoryModelAdapter.java
License:Open Source License
protected User getUser(String extRepositoryUserName) { User user = null;//from ww w . j a v a 2s . c om if (Validator.isNotNull(extRepositoryUserName)) { String liferayLogin = _extRepositoryAdapter.getLiferayLogin(extRepositoryUserName); try { String authType = _extRepositoryAdapter.getAuthType(); if (authType.equals(CompanyConstants.AUTH_TYPE_ID)) { user = UserLocalServiceUtil.getUser(GetterUtil.getLong(liferayLogin)); } else if (authType.equals(CompanyConstants.AUTH_TYPE_EA)) { user = UserLocalServiceUtil.getUserByEmailAddress(getCompanyId(), liferayLogin); } else if (authType.equals(CompanyConstants.AUTH_TYPE_SN)) { user = UserLocalServiceUtil.getUserByScreenName(getCompanyId(), liferayLogin); } } 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.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()); }/*w ww . j a v a 2 s .c o m*/ } 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 ww . j a va2 s .c om 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 String getLogin(ThemeDisplay themeDisplay, ActionRequest actionRequest, User user) throws SystemException { Company company = themeDisplay.getCompany(); String authType = company.getAuthType(); String login;/*from ww w . j av a 2 s. com*/ 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; }