Shortcut for {@link UserDetailsService#loadUserByUsername(String)}.

@throws UserMayOrMayNotExistException
If the security realm cannot even tell if the user exists or not.
@return
never null.
187570
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
        return getSecurityComponents().userDetails.loadUserByUsername(username);
    }
54733
@Restricted(NoExternalUse.class)
    public @Nonnull
    Authentication impersonate(@Nonnull UserDetails userDetails) {
        return new UsernamePasswordAuthenticationToken(userDetails.getUsername(), "", userDetails.getAuthorities());
    }
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;
      }
   }
726914
public boolean requiresUserDataCheck(CmsObject cms, CmsUser user) {

        if (user.isManaged()
            || user.isWebuser()
            || OpenCms.getDefaultUsers().isDefaultUser(user.getName())
            || OpenCms.getRoleManager().hasRole(cms, user.getName(), CmsRole.ROOT_ADMIN)) {
            return false;
        }
        String lastCheckStr = (String)user.getAdditionalInfo().get(
            CmsUserSettings.ADDITIONAL_INFO_LAST_USER_DATA_CHECK);
        if (lastCheckStr == null) {
            return !CmsStringUtil.isEmptyOrWhitespaceOnly(getUserDataCheckIntervalStr());
        }
        long lastCheck = Long.parseLong(lastCheckStr);
        if ((System.currentTimeMillis() - lastCheck) > getUserDataCheckInterval()) {
            return true;
        }
        return false;
    }
885585
@SuppressWarnings("unchecked")
    public UserInfo getUserInfo(String username) throws Exception {

        String pwdCredential = getUserCredentials(username);

        if (pwdCredential == null) {
            return null;
        }

        pwdCredential = convertCredentialLdapToJetty(pwdCredential);
        pwdCredential = decodeBase64EncodedPwd(pwdCredential);
        Credential credential = Credential.getCredential(pwdCredential);
        List roles = getUserRoles(_rootContext, username);

        return new UserInfo(username, credential, roles);
    }
391585
public UserDetails loadUserByUsername(String ident) {
		User user = new User();
		// check if the cookie has an appid prefix
		// and load user from the corresponding app
		if (StringUtils.contains(ident, "/")) {
			String[] parts = ident.split("/");
			user.setAppid(parts[0]);
			ident = parts[1];
		}
		user.setIdentifier(ident);
		user = loadUser(user);

		if (user == null) {
			throw new UsernameNotFoundException(ident);
		}

		return new AuthenticatedUserDetails(user);
	}
1346371
public User getUser(String userName) {
        User result = null;
        for (User item : getUsersList()) {
            if (item.getName().equals(userName)) {
                result = item;
            }
        }
        return result;
    }
892524
@Override
    public IPerson getPerson(HttpServletRequest request) throws PortalSecurityException {

        /*
         * This method overrides the implementation of getPerson() in BasePersonManager, but we only
         * want the RemoteUser behavior here if we're using RemoteUser AuthN.
         */
        if (!remoteUserSecurityContextFactory.isEnabled()) {
            return super.getPerson(request);
        }

        // Return the person object if it exists in the user's session
        final HttpSession session = request.getSession(false);
        IPerson person = null;
        if (session != null) {
            person = (IPerson) session.getAttribute(PERSON_SESSION_KEY);
            if (person != null) {
                return person;
            }
        }

        try {
            // Create a new instance of a person
            person = createPersonForRequest(request);

            // If the user has authenticated with the server which has implemented web
            // authentication,
            // the REMOTE_USER environment variable will be set.
            String remoteUser = request.getRemoteUser();

            // We don't want to ignore the security contexts which are already configured in
            // security.properties, so we
            // retrieve the existing security contexts.  If one of the existing security contexts is
            // a RemoteUserSecurityContext,
            // we set the REMOTE_USER field of the existing RemoteUserSecurityContext context.
            //
            // If a RemoteUserSecurityContext does not already exist, we create one and populate the
            // REMOTE_USER field.

            ISecurityContext context;
            Enumeration subContexts = null;
            boolean remoteUserSecurityContextExists = false;

            // Retrieve existing security contexts.
            context = person.getSecurityContext();
            if (context != null) subContexts = context.getSubContexts();

            if (subContexts != null) {
                while (subContexts.hasMoreElements()) {
                    ISecurityContext ctx = (ISecurityContext) subContexts.nextElement();
                    // Check to see if a RemoteUserSecurityContext already exists, and set the
                    // REMOTE_USER
                    if (ctx instanceof RemoteUserSecurityContext) {
                        RemoteUserSecurityContext remoteuserctx = (RemoteUserSecurityContext) ctx;
                        remoteuserctx.setRemoteUser(remoteUser);
                        remoteUserSecurityContextExists = true;
                    }
                }
            }

            // If a RemoteUserSecurityContext doesn't already exist, create one.
            // This preserves the default behavior of this class.
            if (!remoteUserSecurityContextExists) {
                RemoteUserSecurityContext remoteuserctx = new RemoteUserSecurityContext(remoteUser);
                person.setSecurityContext(remoteuserctx);
            }
        } catch (Exception e) {
            // Log the exception
            logger.error("Exception creating person for request: {}", request, e);
        }
        if (session != null) {
            // Add this person object to the user's session
            session.setAttribute(PERSON_SESSION_KEY, person);
        }
        // Return the new person object
        return (person);
    }
880302
@Override
	public void check() throws JMSException
    {
        Iterator<User> users = userMap.values().iterator();
        while (users.hasNext())
        {
            User user = users.next();
            user.check();
        }
    }
477322
@RequestMapping(value = "/findByUsername", method = RequestMethod.GET)
	public @ResponseBody
	ResponseAccount findByUsername(
			@RequestParam(value = "username", required = true) String username) {
		logger.debug("Received request to get account by username");

		ResponseAccount acconut = accountService.getAccountByUsername(username);

		return acconut;

	}
664129
@Override
  @Transactional(readOnly = true)
  @RunAsSystem
  public UserDetails findUserByToken(String token) {
    Token molgenisToken = getMolgenisToken(token);
    return userDetailsService.loadUserByUsername(molgenisToken.getUser().getUsername());
  }
1307438
@Transactional
    @Override
    public PrincipalUser findUserByUsername(String userName) {
    	requireNotDisposed();
        requireArgument(userName != null && !userName.trim().isEmpty(), "User name cannot be null or empty.");

        PrincipalUser result = PrincipalUser.findByUserName(emf.get(), userName);

        _logger.debug("Retrieving user having username {} from db.", userName);
        return result;
    }
52213
private void loadUser(String username)
    {
        try
        {
            if (null==_con)
                connectDatabase();
            
            if (null==_con)
                throw new SQLException("Can't connect to database");
            
            PreparedStatement stat = _con.prepareStatement(_userSql);
            stat.setObject(1, username);
            ResultSet rs = stat.executeQuery();
    
            if (rs.next())
            {
                Object key = rs.getObject(_userTableKey);
                put(username, rs.getString(_userTablePasswordField));
                stat.close();
                
                stat = _con.prepareStatement(_roleSql);
                stat.setObject(1, key);
                rs = stat.executeQuery();

                while (rs.next())
                    addUserToRole(username, rs.getString(_roleTableRoleField));
                
                stat.close();
            }
        }
        catch (SQLException e)
        {
            log.warn("UserRealm " + getName()
                      + " could not load user information from database", e);
            connectDatabase();
        }
    }
428673
protected User getUser(String username) {
    Integer id = userIds().get(username.toLowerCase());
    if (id == null) {
      throw new IllegalStateException(format("Could not find ID corresponding to username [%s]", username));
    }

    return getUser(id);
  }
469898
public static Function<RequestEnvelope, String> userId() {
        return r -> Optional.ofNullable(r).map(RequestEnvelope::getContext)
                .map(Context::getSystem)
                .map(SystemState::getUser)
                .map(User::getUserId)
                .orElseThrow(() -> new PersistenceException("Could not retrieve user ID from request envelope to generate persistence ID"));
    }
541580
@Get("/users/me")
    public HttpResponse usersMe() throws Exception {
        final User user = AuthUtil.currentUser();
        return HttpResponse.of(HttpStatus.OK, MediaType.JSON_UTF_8,
                               HttpData.of(Jackson.writeValueAsBytes(user)));
    }
1161383
public Object setUserData(String key, Object data, UserDataHandler handler) {
	// dynamic load to support jre 1.4 and 1.5
	try {
	    Method m = node.getClass().getMethod("setUserData", new Class[] { key.getClass(), data.getClass(), handler.getClass() });
	    return m.invoke(node, new Object[] { key, data, handler });
	}
	catch (Exception e) {
	    throw new PageRuntimeException(Caster.toPageException(e));
	}
    }