List of usage examples for com.liferay.portal.kernel.security.auth Authenticator FAILURE
int FAILURE
To view the source code for com.liferay.portal.kernel.security.auth Authenticator FAILURE.
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()); }// ww w.j a v a 2 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.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 ww w . j ava2s . 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()); } }