use of org.apereo.portal.persondir.ILocalAccountPerson in project uPortal by Jasig.
the class UserAccountHelper method getForm.
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;
}
use of org.apereo.portal.persondir.ILocalAccountPerson in project uPortal by Jasig.
the class UserAccountHelper method deleteAccount.
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");
}
use of org.apereo.portal.persondir.ILocalAccountPerson in project uPortal by Jasig.
the class CliPasswordUpdateTool method updatePassword.
@Override
@Transactional
public void updatePassword(String user, String spass, boolean create) throws IOException {
// Make sure user is specified correctly
if (StringUtils.isBlank(user)) {
throw new IllegalArgumentException("You did not specify a valid user name. Please try again.");
}
// attempt to get the account form the database
ILocalAccountPerson account = this.localAccountDao.getPerson(user);
if (account == null) {
if (!create) {
throw new IllegalArgumentException("No such user: " + user);
}
account = this.localAccountDao.createPerson(user);
}
// update the user's password
final String encryptedPassword = this.portalPasswordService.encryptPassword(spass);
account.setPassword(encryptedPassword);
this.localAccountDao.updateAccount(account);
logger.info("Password Updated for: {}", user);
}
use of org.apereo.portal.persondir.ILocalAccountPerson in project uPortal by Jasig.
the class ResetPasswordTenantOperationsListener method sendResetPasswordEmail.
private void sendResetPasswordEmail(final ITenant tenant) {
ILocalAccountPerson admin = localAccountDao.getPerson(tenant.getAttribute(ADMIN_CONTACT_USERNAME));
admin.setAttribute("loginToken", userAccountHelper.getRandomToken());
final HttpServletRequest http = portalRequestUtils.getCurrentPortalRequest();
this.userAccountHelper.sendLoginToken(http, admin, passwordResetNotification);
localAccountDao.updateAccount(admin);
}
Aggregations