Returns a user object for a given identifier.
@param u a user having a valid identifier set.
@return a user or null if no user is found for this identifier
977462
public static final User readUserForIdentifier(final User u) {
		if (u == null || StringUtils.isBlank(u.getIdentifier())) {
			return null;
		}
		User user = null;
		String password = null;
		String identifier = u.getIdentifier();
		// Try to read the identifier object first, then read the user object linked to it.
		Sysprop s = CoreUtils.getInstance().getDao().read(u.getAppid(), identifier);
		if (s != null && s.getCreatorid() != null) {
			user = CoreUtils.getInstance().getDao().read(u.getAppid(), s.getCreatorid());
			password = (String) s.getProperty(Config._PASSWORD);
		}
		// Try to find the user by email if already created, but with a different identifier.
		// This prevents users with identical emails to have separate accounts by signing in through
		// different identity providers.
		if (user == null && !StringUtils.isBlank(u.getEmail())) {
			HashMap<String, Object> terms = new HashMap<>(2);
			terms.put(Config._EMAIL, u.getEmail());
			terms.put(Config._APPID, u.getAppid());
			List<User> users = CoreUtils.getInstance().getSearch().
					findTerms(u.getAppid(), u.getType(), terms, true, new Pager(1));
			if (!users.isEmpty()) {
				user = users.get(0);
				password = Utils.generateSecurityToken();
				user.createIdentifier(u.getIdentifier(), password);
			}
		}
		if (user != null) {
			if (password != null) {
				user.setPassword(password);
			}
			if (!identifier.equals(user.getIdentifier())) {
				logger.info("Identifier changed for user '{}', from {} to {}.",
						user.getId(), user.getIdentifier(), identifier);
				// the main identifier was changed - update
				user.setIdentifier(identifier);
				CoreUtils.getInstance().getDao().update(user.getAppid(), user);
			}
			return user;
		}
		logger.debug("User not found for identifier {}/{}, {}.", u.getAppid(), identifier, u.getId());
		return null;
	}
210051
@Pure
	public BusHub getBusHub(UUID uuid) {
		if (uuid == null) {
			return null;
		}
		for (final BusHub busHub : this.validBusHubs) {
			if (uuid.equals(busHub.getUUID())) {
				return busHub;
			}
		}
		for (final BusHub busHub : this.invalidBusHubs) {
			if (uuid.equals(busHub.getUUID())) {
				return busHub;
			}
		}
		return null;
	}
381356
@GetMapping("/user")
  public ResponseEntity<User> getUser(
      @VersionApi int version, //<1>
      @RequestParam("id") String id) {
    throw new UnsupportedOperationException();
  }
838885
protected String getDnForUser(String userId) {
    LdapUserEntity user = (LdapUserEntity) createUserQuery(org.camunda.bpm.engine.impl.context.Context.getCommandContext())
      .userId(userId)
      .singleResult();
    if(user == null) {
      return "";
    } else {
      return user.getDn();
    }
  }
242015
public Optional<UUID> getId(final Object object) {
        return Optional.ofNullable(objectToId.get(object));
    }
477833
def get_user_by_id(uid,**kwargs):
    
    user_id = kwargs.get('user_id')
    try:
        user_i = _get_user(uid)
        return user_i
    except NoResultFound:
        return None
1089986
public Entry getEntryByUUID(final UUID UUID) {
        List<Entry> allEntries = getEntries();

        List<Entry> entries = ListFilter.filter(allEntries, new Filter<Entry>() {

            @Override
            public boolean matches(Entry item) {

                if (item.getUuid() != null && item.getUuid().compareTo(UUID) == 0) {
                    return true;
                } else {
                    return false;
                }
            }
        });

        if (entries.size() == 1) {
            return entries.get(0);
        } else {
            return null;
        }
    }
95838
@Override
    public Set<Node> findUsers(final String uid) {
        QueryBuilder qb = new LdapQueryBuilder();
        if ("*".equals(uid)) {
            qb.append(LdapKeys.OBJECT_CLASS, userObjectClass);
        } else {
            qb.append(LdapKeys.OBJECT_CLASS, userObjectClass);
            qb.append(userIdentifyer, uid + "*");
        }
        return findUsers(qb);
    }
527598
protected Integer getUserId() {
        Integer userId = ThreadContext.getContext(UserWebConstant.CTX_USERID);
        if (userId != null) {
            return userId;
        }
        return null;
    }
1297171
public RestletUtilUser findUser(final String userIdentifier)
    {
        if(userIdentifier == null)
        {
            throw new NullPointerException("User identifier was null");
        }
        
        RestletUtilUser result = null;
        
        RepositoryConnection conn = null;
        try
        {
            conn = this.repository.getConnection();
            
            final String query = this.buildSparqlQueryToFindUser(userIdentifier, false);
            
            this.log.debug("findUser: query={}", query);
            
            final TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
            
            final TupleQueryResult queryResult = tupleQuery.evaluate();
            
            try
            {
                if(queryResult.hasNext())
                {
                    final BindingSet bindingSet = queryResult.next();
                    
                    result = this.buildRestletUserFromSparqlResult(userIdentifier, bindingSet);
                }
                else
                {
                    this.log.info("Could not find user with identifier, returning null: {}", userIdentifier);
                }
            }
            finally
            {
                queryResult.close();
            }
            
        }
        catch(final RepositoryException e)
        {
            throw new RuntimeException("Failure finding user in repository", e);
        }
        catch(final MalformedQueryException e)
        {
            throw new RuntimeException("Failure finding user in repository", e);
        }
        catch(final QueryEvaluationException e)
        {
            throw new RuntimeException("Failure finding user in repository", e);
        }
        finally
        {
            try
            {
                conn.close();
            }
            catch(final RepositoryException e)
            {
                this.log.error("Failure to close connection", e);
            }
        }
        
        return result;
    }
553012
@SuppressWarnings("unchecked")
    @Override
	public <T extends ApiUser> T getUserByName(String username) {
	    User sfsUser = getZone().getUserByName(username);
        if(sfsUser != null && sfsUser.containsProperty(APIKey.USER))
            return (T) sfsUser.getProperty(APIKey.USER);
        return null;
	}
937682
@Override
    public Iterable<Long> getUserItemTimestamps(U u, I i) {
        if (userItemTimestamps.containsKey(u) && userItemTimestamps.get(u).containsKey(i)) {
            return userItemTimestamps.get(u).get(i);
        }
        return null;
    }
1241712
public User findUserById(String userId) {
    return createUserQuery(org.camunda.bpm.engine.impl.context.Context.getCommandContext())
      .userId(userId)
      .singleResult();
  }
463663
@Override
    public PrincipalUser getUser(String username, String password) {
        requireNotDisposed();
        requireArgument(_isUsernameValid(username), MessageFormat.format("Invalid username: {0}", username));

        PrincipalUser result = null;
        String userDn = _findDNForUser(username);

        if (userDn != null && password != null) {
            result = _findPrincipalUser(userDn, username, password);
        }
        return result;
    }
863787
public Object find(Class clazz, Object identifier) {
        try {
            return persistenceManager.findById(clazz, identifier);
        } catch (InitializationException ignore){}
        catch (Exception e) {
            e.printStackTrace();
        }

        return null;
    }
811293
@GET
    @Produces(MediaType.APPLICATION_JSON)
    @Path("/username/{username}")
    @Description("Returns the user having the given username.")
    public PrincipalUserDto getUserByUsername(@Context HttpServletRequest req,
        @PathParam("username") final String userName) {

        Enumeration<String> headerNames = req.getHeaderNames();
        while(headerNames.hasMoreElements()) {
            String headerName = headerNames.nextElement();
            String headerValue = req.getHeader(headerName);
            System.out.println(headerName + ": " + headerValue);
        }

        if (userName == null || userName.isEmpty()) {
            throw new WebApplicationException("Username cannot be null or empty.", Status.BAD_REQUEST);
        }

        PrincipalUser remoteUser = validateAndGetOwner(req, null);
        PrincipalUser user = _uService.findUserByUsername(userName);

        if (user != null) {
            super.validateResourceAuthorization(req, user, remoteUser);
            return PrincipalUserDto.transformToDto(user);
        } else if (!remoteUser.isPrivileged()) {
            throw new WebApplicationException(Response.Status.FORBIDDEN.getReasonPhrase(), Response.Status.FORBIDDEN);
        } else {
            throw new WebApplicationException(Response.Status.NOT_FOUND.getReasonPhrase(), Response.Status.NOT_FOUND);
        }
    }
634700
public User getUserById(int id) {
		for (User u : users)
			if (u.getId() == id)
				return u;
		return null;
	}