private boolean hasUser(final String userName) { if (userName != null) { try { return m_userDao.hasUser(userName); } catch (IOException e) { Log.error("could not load user", e); //ignore } } return false; }
/** * Get a user's microblog username by User * * @param user * the user object of the user whose microblog username should be returned * @return the microblog username of the specified user * @throws java.io.IOException if any. * @throws java.io.FileNotFoundException if any. */ public String getMicroblogName(final User user) throws FileNotFoundException, IOException { return getContactInfo(user, ContactType.microblog.toString()); }
private User getBackingUser(String name) { try { return m_userManager.getUser(name); } catch (IOException e) { throw new WebRolesException("Error reading users.xml config file", e); } }
public void setContactInfo(final String userId, final ContactType contactType, final String contactValue) throws Exception { update(); m_writeLock.lock(); try { final User user = _getUser(userId); if (user != null) { _setContact(user, contactType, contactValue); } _saveCurrent(); } finally { m_writeLock.unlock(); } }
public OnmsUser getOnmsUser(final String username) throws IOException { update(); m_readLock.lock(); try { return _getOnmsUser(username); } finally { m_readLock.unlock(); } }
/** * <p>getUserNames</p> * * @return a {@link java.util.List} object. * @throws java.io.IOException if any. */ public List<String> getUserNames() throws IOException { update(); m_readLock.lock(); try { return _getUserNames(); } finally { m_readLock.unlock(); } }
for (final String userName : userManager.getUserNames()) { log("Loading configured user: %s...\n", userName); users.add(userManager.getOnmsUser(userName)); newUser.setFullName(user); newUser.setComments("This is a system user, do not delete"); newUser.setPassword(userManager.encryptedPassword(password, true)); newUser.setPasswordSalted(true); users.add(0, newUser); userManager.save(user);
protected void checkUserPassword(final String authUsername, final String authPassword, final SpringSecurityUser user) throws AuthenticationException { final String existingPassword = user.getPassword(); boolean hasUser = false; try { hasUser = m_userManager.hasUser(user.getUsername()); } catch (final Throwable e) { throw new AuthenticationServiceException("An error occurred while checking for " + authUsername + " in the UserManager", e); } if (hasUser) { if (!m_userManager.comparePasswords(authUsername, authPassword)) { LOG.warn("Password auth failed for user: " + authUsername); throw new BadCredentialsException("Bad credentials"); } } else { if (!m_userManager.checkSaltedPassword(authPassword, existingPassword)) { LOG.warn("Salted password auth failed for user: " + authUsername); throw new BadCredentialsException("Bad credentials"); } } }
/** * Sets the password for this user, first encrypting it * * @param userID * the user ID to change the password for * @param aPassword * the password * @throws java.lang.Exception if any. */ public void setUnencryptedPassword(final String userID, final String aPassword) throws Exception { update(); m_writeLock.lock(); try { final User user = m_users.get(userID); if (user != null) { final Password pass = new Password(); pass.setEncryptedPassword(encryptedPassword(aPassword, true)); pass.setSalt(true); user.setPassword(pass); } _saveCurrent(); } finally { m_writeLock.unlock(); } }
/** * */ private int getUsersInTarget(Target target) throws IOException { int count = 0; String targetName = target.getName(); if (getGroupManager().hasGroup(targetName)) { count = getGroupManager().getGroup(targetName).getUsers().size(); } else if (getUserManager().hasOnCallRole(targetName)) { count = getUserManager().countUsersWithRole(targetName); } else if (getUserManager().hasUser(targetName)) { count = 1; } else if (targetName.indexOf('@') > -1) { count = 1; } return count; }
/** * Return a <code>Map</code> of usernames to user instances. * * @return a {@link java.util.Map} object. * @throws java.io.IOException if any. */ public Map<String, User> getUsers() throws IOException { update(); m_readLock.lock(); try { return Collections.unmodifiableMap(m_users); } finally { m_readLock.unlock(); } }
public void save(final OnmsUser onmsUser) throws Exception { update(); User xmlUser = _getUser(onmsUser.getUsername()); if (xmlUser == null) { xmlUser = new User(); _setContact(xmlUser, ContactType.email, onmsUser.getEmail()); _writeUser(onmsUser.getUsername(), xmlUser); } finally { m_writeLock.unlock();
public OnmsUserList getOnmsUserList() throws IOException { update(); final OnmsUserList list = new OnmsUserList(); m_readLock.lock(); try { for (final String username : _getUserNames()) { list.add(_getOnmsUser(username)); } list.setTotalCount(list.getCount()); return list; } finally { m_readLock.unlock(); } }
/** * This method compares two encrypted strings for equality. * * @param userID * the user ID to check against. * @param aPassword * the password to check for equality * @return true if the two passwords are equal (after encryption), false * otherwise */ public boolean comparePasswords(final String userID, final String aPassword) { m_readLock.lock(); try { final User user = m_users.get(userID); if (user == null) return false; final String password = user.getPassword().getEncryptedPassword().trim(); final boolean isSalted = Boolean.valueOf(user.getPassword().getSalt()); if (isSalted) { return checkSaltedPassword(aPassword, password); } else { return password.equals(encryptedPassword(aPassword, false)); } } finally { m_readLock.unlock(); } }
} else if (getUserManager().hasOnCallRole(targetName)) { tasks = makeRoleTasks(startTime, params, noticeId, targetName, targets[i].getCommands().toArray(new String[0]), targetSiblings, autoNotify, TimeConverter.convertToMillis(interval)); } else if (getUserManager().hasUser(targetName)) { NotificationTask[] userTasks = { makeUserTask(startTime, params, noticeId, targetName, targets[i].getCommands().toArray(new String[0]), targetSiblings, autoNotify) }; tasks = userTasks;
/** * Get an XMPP address by name * * @param user a {@link org.opennms.netmgt.config.users.User} object. * @return String the XMPP address * @throws java.io.IOException if any. */ public String getXMPPAddress(final User user) throws IOException { update(); m_readLock.lock(); try { return _getXMPPAddress(user); } finally { m_readLock.unlock(); } }
/** * <p>getUsersWithRole</p> * * @param roleid a {@link java.lang.String} object. * @return an array of {@link java.lang.String} objects. * @throws java.io.IOException if any. */ public String[] getUsersWithRole(final String roleid) throws IOException { update(); m_readLock.lock(); try { return _getUsersWithRole(roleid); } finally { m_readLock.unlock(); } }
/** * <p>getContactServiceProvider</p> * * @param user a {@link org.opennms.netmgt.config.users.User} object. * @param command a {@link java.lang.String} object. * @return a {@link java.lang.String} object. * @throws java.io.IOException if any. */ public String getContactServiceProvider(final User user, final String command) throws IOException { update(); m_readLock.lock(); try { return _getContactServiceProvider(user, command); } finally { m_readLock.unlock(); } }
/** * <p>getContactInfo</p> * * @param user a {@link org.opennms.netmgt.config.users.User} object. * @param command a {@link java.lang.String} object. * @return a {@link java.lang.String} object. * @throws java.io.IOException if any. */ public String getContactInfo(final User user, final String command) throws IOException { update(); m_readLock.lock(); try { return _getContactInfo(user, command); } finally { m_readLock.unlock(); } }
/** * <p>isUserScheduledForRole</p> * * @param user a {@link org.opennms.netmgt.config.users.User} object. * @param roleid a {@link java.lang.String} object. * @param time a {@link java.util.Date} object. * @return a boolean. * @throws java.io.FileNotFoundException if any. * @throws java.io.IOException if any. */ public boolean isUserScheduledForRole(final User user, final String roleid, final Date time) throws FileNotFoundException, IOException { update(); m_readLock.lock(); try { return _isUserScheduledForRole(user, roleid, time); } finally { m_readLock.unlock(); } }