@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); } }
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"); }
/** * Return the list of all possible attribute names. This implementation queries the database to * provide a list of all mapped attribute names, plus all attribute keys currently in-use in the * database. * * @return Set */ @Override public Set<String> getPossibleUserAttributeNames() { final Set<String> names = new HashSet<String>(); names.addAll(this.possibleUserAttributes); names.addAll(localAccountDao.getCurrentAttributeNames()); names.add(displayNameAttribute); return names; }
ILocalAccountPerson account = this.localAccountDao.getPerson(username); final String password = userType.getPassword(); final List<Attribute> attributes = userType.getAttributes(); this.localAccountDao.deleteAccount(account); account = this.localAccountDao.createPerson(username); this.localAccountDao.updateAccount(account);
protected boolean isLocalAccount(String username) { ILocalAccountPerson person = accountDao.getPerson(username); if (person != null) { return true; } else { return false; } }
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; }
ILocalAccountPerson account = accountDao.getPerson(username); account.setPassword(passwordService.encryptPassword(password)); account.setLastPasswordChange(new Date()); account.removeAttribute("loginToken"); accountDao.updateAccount(account); if (log.isInfoEnabled()) { log.info("Password created for account: " + account);
@Override public final Set<IPersonAttributes> getPeopleWithMultivaluedAttributes( Map<String, List<Object>> query) { Validate.notNull(query, "query may not be null."); // Generate the query to pass to the subclass final LocalAccountQuery queryBuilder = this.generateQuery(query); if (queryBuilder == null) { this.logger.debug( "No queryBuilder was generated for query " + query + ", null will be returned"); return null; } // Get the username from the query, if specified final IUsernameAttributeProvider usernameAttributeProvider = this.getUsernameAttributeProvider(); // Execute the query in the subclass final List<ILocalAccountPerson> unmappedPeople = localAccountDao.getPeople(queryBuilder); if (unmappedPeople == null) { return null; } // Map the attributes of the found people according to resultAttributeMapping if it is set final Set<IPersonAttributes> mappedPeople = new LinkedHashSet<IPersonAttributes>(); for (final ILocalAccountPerson unmappedPerson : unmappedPeople) { final IPersonAttributes mappedPerson = this.mapPersonAttributes(unmappedPerson); mappedPeople.add(mappedPerson); } return Collections.unmodifiableSet(mappedPeople); }
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; }
@Override public final Set<IPersonAttributes> getPeopleWithMultivaluedAttributes( Map<String, List<Object>> query) { Validate.notNull(query, "query may not be null."); // Generate the query to pass to the subclass final LocalAccountQuery queryBuilder = this.generateQuery(query); if (queryBuilder == null) { this.logger.debug( "No queryBuilder was generated for query " + query + ", null will be returned"); return null; } // Get the username from the query, if specified final IUsernameAttributeProvider usernameAttributeProvider = this.getUsernameAttributeProvider(); // Execute the query in the subclass final List<ILocalAccountPerson> unmappedPeople = localAccountDao.getPeople(queryBuilder); if (unmappedPeople == null) { return null; } // Map the attributes of the found people according to resultAttributeMapping if it is set final Set<IPersonAttributes> mappedPeople = new LinkedHashSet<IPersonAttributes>(); for (final ILocalAccountPerson unmappedPerson : unmappedPeople) { final IPersonAttributes mappedPerson = this.mapPersonAttributes(unmappedPerson); mappedPeople.add(mappedPerson); } return Collections.unmodifiableSet(mappedPeople); }
@Override @Transactional public boolean updatePassword(String user, boolean create) throws IOException { // Make sure user is specified correctly if (StringUtils.isBlank(user)) { System.err.println("You did not specify a valid user name. Please try again."); return false; } // attempt to get the account form the database ILocalAccountPerson account = this.localAccountDao.getPerson(user); if (account == null) { if (!create) { System.err.println("No such user: " + user); return false; } account = this.localAccountDao.createPerson(user); } System.out.print("Enter Password for " + user + ": "); System.out.flush(); // Needed for prompt to appear when running from Ant. final BufferedReader d = new BufferedReader(new InputStreamReader(System.in, UTF_8)); final String spass = d.readLine(); // update the user's password final String encryptedPassword = this.portalPasswordService.encryptPassword(spass); account.setPassword(encryptedPassword); this.localAccountDao.updateAccount(account); System.out.println("Password Updated..."); return true; }
final ILocalAccountPerson person = localAccountDao.getPerson(userName); if (person != null) { localAccountDao.deleteAccount(person);
String first_name, last_name; ILocalAccountDao accountStore = LocalAccountDaoLocator.getLocalAccountDao(); ILocalAccountPerson account = accountStore.getPerson(this.myPrincipal.UID); if (account != null) { first_name = (String) account.getAttributeValue("given");
/** * Return the list of all possible attribute names. This implementation queries the database to * provide a list of all mapped attribute names, plus all attribute keys currently in-use in the * database. * * @return Set */ @Override public Set<String> getPossibleUserAttributeNames() { final Set<String> names = new HashSet<String>(); names.addAll(this.possibleUserAttributes); names.addAll(localAccountDao.getCurrentAttributeNames()); names.add(displayNameAttribute); return names; }
account = accountDao.getPerson(form.getUsername()); if (account == null) { account = accountDao.createPerson(form.getUsername()); account = accountDao.getPerson(form.getId()); accountDao.updateAccount(account); log.info("Account " + account.getName() + " successfully updated");
final ILocalAccountPerson person = localAccountDao.getPerson(userName); if (person != null) { localAccountDao.deleteAccount(person);
ILocalAccountPerson account = accountStore.getPerson(this.myPrincipal.UID);
public PersonForm getNewAccountForm() { PersonForm form = new PersonForm(accountEditAttributes); Set<String> attributeNames = accountDao.getCurrentAttributeNames(); for (String name : attributeNames) { form.getAttributes() .put(name, new StringListAttribute(Collections.<String>emptyList())); } return form; }
userType.setUsername(userName); final ILocalAccountPerson localAccountPerson = this.localAccountDao.getPerson(userName); if (localAccountPerson != null) { userType.setPassword(localAccountPerson.getPassword());
public void validateEditLocalAccount(PersonForm person, MessageContext context) { // ensure that this username isn't already taken if (person.getId() < 0 && accountDao.getPerson(person.getUsername()) != null) { context.addMessage( new MessageBuilder() .error() .source("username") .code("username.in.use") .build()); } if (StringUtils.isNotBlank(person.getPassword()) || StringUtils.isNotBlank(person.getConfirmPassword())) { if (person.getPassword() == null || !person.getPassword().equals(person.getConfirmPassword())) { context.addMessage( new MessageBuilder() .error() .source("password") .code("passwords.must.match") .build()); } } } }