/** * Get user with the given name. This method throws an exception if the user * does not exist. * * @param name the user name * @return the user * @throws DbException if the user does not exist */ public User getUser(String name) { User user = findUser(name); if (user == null) { throw DbException.get(ErrorCode.USER_NOT_FOUND_1, name); } return user; }
@Override public Session createSession(Properties ci) { String userName = ci.getProperty("user"); String password = ci.getProperty("password"); if (userName == null) { userName = Database.SYSTEM_USER_NAME; } User user = database.findUser(userName); if (user == null) { // users is the last thing we add, so if no user is around, // the database is new (or not initialized correctly) user = new User(database, userName); user.setAdmin(true); user.setPassword(password); database.addDatabaseObject(user); } User userObject = database.getUser(userName); Session session = database.createSession(userObject); return session; }