/** * Determine the name to use in the password reset email that identifies the users whose * password has been reset. * * @param person the account that has had its password reset * @return the account holders name */ protected String findDisplayNameFromLocalAccountPerson(ILocalAccountPerson person) { Object name = person.getAttributeValue(ILocalAccountPerson.ATTR_DISPLAY_NAME); if ((name instanceof String) && !StringUtils.isEmpty((String) name)) { return (String) name; } // if display name is not set, just return username. return person.getName(); } }
public boolean validateLoginToken(String username, String token) { ILocalAccountPerson person = accountDao.getPerson(username); if (person != null) { Object recordedToken = person.getAttributeValue("loginToken"); if (recordedToken != null && recordedToken.equals(token)) { if (log.isInfoEnabled()) { log.info("Successfully validated security token for user: " + username); } return true; } else { if (log.isInfoEnabled()) { log.info( "Unable to validate security token; recordedToken=" + recordedToken + ", submitted token=" + token); } } } else { if (log.isInfoEnabled()) { log.info("Unable to validate security token; person not found: " + username); } } return false; }
ILocalAccountPerson account = accountStore.getPerson(this.myPrincipal.UID); if (account != null) { first_name = (String) account.getAttributeValue("given"); last_name = (String) account.getAttributeValue("sn"); this.myPrincipal.FullName = first_name + " " + last_name; if (log.isInfoEnabled())
String fullName = (String) account.getAttributeValue("displayName"); this.myPrincipal.FullName = fullName; if (log.isInfoEnabled())
@Override public void sendNotification(URL resetUrl, ILocalAccountPerson account, Locale locale) { log.debug("Sending password reset instructions to user with url {}", resetUrl.toString()); try { MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message, true); String email = (String) account.getAttributeValue(ILocalAccountPerson.ATTR_MAIL); String subject = messageSource.getMessage(subjectMessageKey, new Object[] {}, locale); String body = formatBody(resetUrl, account, locale); helper.addTo(email); helper.setText(body, true); helper.setSubject(subject); helper.setFrom( portalEmailAddress, messageSource.getMessage("portal.name", new Object[] {}, locale)); log.debug( "Sending message to {} from {} subject {}", email, Arrays.toString(message.getFrom()), message.getSubject()); this.mailSender.send(helper.getMimeMessage()); } catch (Exception e) { log.error("Unable to send password reset email", e); } }
public void sendLoginToken( HttpServletRequest request, ILocalAccountPerson account, IPasswordResetNotification notification) { Locale locale = getCurrentUserLocale(request); IPortalUrlBuilder builder = urlProvider.getPortalUrlBuilderByPortletFName( request, PORTLET_FNAME_LOGIN, UrlType.RENDER); IPortletUrlBuilder portletUrlBuilder = builder.getTargetedPortletUrlBuilder(); portletUrlBuilder.addParameter("username", account.getName()); portletUrlBuilder.addParameter( "loginToken", (String) account.getAttributeValue("loginToken")); portletUrlBuilder.setPortletMode(PortletMode.VIEW); portletUrlBuilder.setWindowState(WindowState.MAXIMIZED); try { String path = fixPortletPath(request, builder); URL url = new URL( request.getScheme(), request.getServerName(), request.getServerPort(), path); notification.sendNotification(url, account, locale); } catch (MalformedURLException e) { log.error(e); } }