Resolves a user by username, possibly with the internal cache.
@param username The username.
@return The user or {@code null}, if not found.
@throws SQLException on database error.
519555
public User resolveUser(final String username) throws SQLException {
      metrics.usernameCacheTries.mark();
      User user = usernameCache.getIfPresent(username);
      if(user != null) {
         metrics.usernameCacheHits.mark();
         return user;
      } else {
         user = selectUser(username);
         if(user != null) {
            usernameCache.put(username, user);
         }
         return user;
      }
   }
569573
@NotNull
    public T queryNN() throws SQLException {
        T res = null;
        try (ResultSet r = statement.executeQuery()) {
            if (r.next()) {
                res = resultMapper.map(r);
            }
            Objects.requireNonNull(res);
            return res;
        }
    }
729180
public boolean userHasLock(String username) {
        Objects.requireNonNull(username, Required.USERNAME.toString());
        boolean lock = false;
        
        Config config = Application.getInstance(Config.class);
        Cache cache = Application.getInstance(CacheProvider.class).getCache(CacheName.AUTH);
        AtomicInteger counter = cache.getCounter(username);
        if (counter != null && counter.get() > config.getAuthenticationLock()) {
            lock = true;
        }
        
        return lock;
    }
29132
public static void setUsername(final String username) {
        if (username == null) {
            throw new AuthenticationException("Username can not be null");
        }

        if (!username.equals(Twilio.username)) {
            Twilio.invalidate();
        }

        Twilio.username = username;
    }
530873
public Connection getConnection(String username, String password)
	throws SQLException {
		try {
			return this.multiDataSource.get(new UsernamePassword(username, password)).getConnection();
		} catch (ExecutionException e) {
			throw PoolUtil.generateSQLException("Unable to obtain connection", e);

		}
	}
776185
public static dbuser get(nitro_service service, String username) throws Exception{
		dbuser obj = new dbuser();
		obj.set_username(username);
		dbuser response = (dbuser) obj.get_resource(service);
		return response;
	}
709348
public UserStateResult getUserState(String username)
            throws APIConnectionException, APIRequestException {
        StringUtils.checkUsername(username);
        ResponseWrapper response = _httpClient.sendGet(_baseUrl + userPath + "/" + username + "/userstat");
        return UserStateResult.fromResponse(response, UserStateResult.class);
    }
1241712
public User findUserById(String userId) {
    return createUserQuery(org.camunda.bpm.engine.impl.context.Context.getCommandContext())
      .userId(userId)
      .singleResult();
  }
162652
@Override
  public final String getUserName() {
    if (httpReq.getUserPrincipal() != null) {
      return httpReq.getUserPrincipal().getName();
    }
    return null;
  }
238816
public Session resolveSession(String sessionToken, String userId) {
		this.sessionToken = sessionToken;
		this.userId = userId;
		if (accessManager != null) {
			this.session = accessManager.getSessionByToken(sessionToken);
		}
		return session;
	}
644481
private User getFromCache(String userName)
   {
      return (User)cache.get(userName, CacheType.USER);
   }
928827
public static void sqluser(StringBuilder buf, List<? extends CharSequence> parsedArgs) throws SQLException {
    zeroArgumentFunctionCall(buf, "user", "user", parsedArgs);
  }
1213273
public void update(Connection conn, User user) throws SQLException {
        String sql = "UPDATE userbase \n";
        Integer id = user.getId();
        user.setId(null);
        try {
            String s = SQLBuilder.beanToSQLClause(user,",");
            sql = sql + SQLBuilder.getSetClause(s) +"\n"+
                "WHERE id=? ";
        } catch (JibuException e) {
            throw new SQLException(e.getMessage());
        }
        user.setId(id);
        run.update(conn, sql, id);
    }
1029318
public User getUser(String id) {
        return db.query("SELECT * FROM Users WHERE id = ?",
                new ResultSetExtractor<User>() {
                    public User extractData(ResultSet rs)
                            throws SQLException {
                        if (rs.next()) {
                            return getUser(rs);
                        } else {
                            return null;
                        }
                    }
                },
                Integer.parseInt(id));
    }
502871
public Post.Builder resolve(final Post.Builder post) throws SQLException {
      Timer.Context ctx = metrics.resolvePostTimer.time();
      try {
         User author = resolveUser(post.getAuthorId());
         if(author != null) {
            List<Meta> meta = userMetadata(post.getAuthorId());
            if(meta.size() > 0) {
               author = author.withMetadata(meta);
            }
            post.setAuthor(author);
         }

         List<Meta> meta = selectPostMeta(post.getId());
         if(meta.size() > 0) {
            post.setMetadata(meta);
         }

         List<TaxonomyTerm> terms = selectPostTerms(post.getId());
         if(terms.size() > 0) {
            post.setTaxonomyTerms(terms);
         }

         List<Post> children = selectChildren(post.getId(), false);
         if(children.size() > 0) {
            post.setChildren(children);
         }
         return post;
      } finally {
         ctx.stop();
      }
   }
381810
public List<CouchDbGoogleAuthenticatorAccount> findByUsername(final String username) {
        try {
            return queryView("by_username", username);
        } catch (final DocumentNotFoundException ignored) {
            return null;
        }
    }
692728
public static function getUser($username = null)
	{
		if ( is_null( $username ) ) $username = self::getCurrentUsername();

		if ( self::userExists( $username ) ) {
			return self::$auth['users'][ $username ];
		}

		return null;
	}