Search in sources :

Example 11 with ILocalAccountPerson

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;
}
Also used : ArrayList(java.util.ArrayList) StringListAttribute(org.apereo.portal.portlets.StringListAttribute) ILocalAccountPerson(org.apereo.portal.persondir.ILocalAccountPerson)

Example 12 with ILocalAccountPerson

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");
}
Also used : ILocalAccountPerson(org.apereo.portal.persondir.ILocalAccountPerson)

Example 13 with ILocalAccountPerson

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);
}
Also used : ILocalAccountPerson(org.apereo.portal.persondir.ILocalAccountPerson) Transactional(org.springframework.transaction.annotation.Transactional)

Example 14 with ILocalAccountPerson

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);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ILocalAccountPerson(org.apereo.portal.persondir.ILocalAccountPerson)

Aggregations

ILocalAccountPerson (org.apereo.portal.persondir.ILocalAccountPerson)14 Date (java.util.Date)3 Calendar (java.util.Calendar)2 List (java.util.List)2 Map (java.util.Map)2 ILocalAccountDao (org.apereo.portal.persondir.ILocalAccountDao)2 PortalSecurityException (org.apereo.portal.security.PortalSecurityException)2 Test (org.junit.Test)2 Transactional (org.springframework.transaction.annotation.Transactional)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Multipart (javax.mail.Multipart)1 InternetAddress (javax.mail.internet.InternetAddress)1 MimeMessage (javax.mail.internet.MimeMessage)1 EntityManager (javax.persistence.EntityManager)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 EntityIdentifier (org.apereo.portal.EntityIdentifier)1 LocalAccountQuery (org.apereo.portal.persondir.LocalAccountQuery)1 Preference (org.apereo.portal.portletpublishing.xml.Preference)1 StringListAttribute (org.apereo.portal.portlets.StringListAttribute)1