/** * 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 void deleteAccount(IPerson currentUser, String target) { if (!canDeleteUser(currentUser, target)) { throw new RuntimeException( "Current user " + currentUser.getName() + " does not have permissions to update person " + target); } ILocalAccountPerson person = accountDao.getPerson(target); accountDao.deleteAccount(person); log.info("Account " + person.getName() + " successfully deleted"); }
public PersonForm getForm(String username) { ILocalAccountPerson person = accountDao.getPerson(username); PersonForm form = new PersonForm(accountEditAttributes); form.setUsername(person.getName()); form.setId(person.getId()); Set<String> attributeNames = accountDao.getCurrentAttributeNames(); for (String name : attributeNames) { List<String> values = new ArrayList<String>(); List<Object> attrValues = person.getAttributeValues(name); if (attrValues != null) { for (Object value : person.getAttributeValues(name)) { values.add((String) value); } } form.getAttributes().put(name, new StringListAttribute(values)); } return form; }
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); } }