Builds a RestletUtilUser from the data retrieved in a SPARQL result.

@param userIdentifier
The unique identifier of the User.
@param bindingSet
Results of a single user from SPARQL.
@return A RestletUtilUser account.
493420
protected RestletUtilUser buildRestletUserFromSparqlResult(final String userIdentifier, final BindingSet bindingSet)
    {
        // log.info("result={}", bindingSet);
        
        String userEmail = bindingSet.getValue("userEmail").stringValue();
        // TODO: When hashed, need to unhash here
        char[] userSecret = null;
        if(bindingSet.hasBinding("userSecret"))
        {
            userSecret = bindingSet.getValue("userSecret").stringValue().toCharArray();
        }
        String userFirstName = null;
        if(bindingSet.hasBinding("userFirstName"))
        {
            userFirstName = bindingSet.getValue("userFirstName").stringValue();
        }
        String userLastName = null;
        if(bindingSet.hasBinding("userLastName"))
        {
            userLastName = bindingSet.getValue("userLastName").stringValue();
        }
        
        return new RestletUtilUser(userIdentifier, userSecret, userFirstName, userLastName, userEmail);
    }
1095601
private UserEntity ensureRolesFetched(final UserEntity user)
	{
		if (user != null)
			user.getRoles().stream().map(r -> r.getId()).collect(Collectors.toList());

		return user;
	}
1086984
@GET
  @Path("/db/{authorizerName}/users/{userName}")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  @ResourceFilters(BasicSecurityResourceFilter.class)
  public Response getUser(
      @Context HttpServletRequest req,
      @PathParam("authorizerName") final String authorizerName,
      @PathParam("userName") final String userName,
      @QueryParam("full") String full
  )
  {
    return resourceHandler.getUser(authorizerName, userName, full != null);
  }
703646
protected Identity getIdentityFromResultSet() throws PersistenceBrokerException
    {
        // fill primary key values from Resultset
        FieldDescriptor fld;
        FieldDescriptor[] pkFields = getQueryObject().getClassDescriptor().getPkFields();
        Object[] pkValues = new Object[pkFields.length];

        for (int i = 0; i < pkFields.length; i++)
        {
            fld = pkFields[i];
            pkValues[i] = getRow().get(fld.getColumnName());
        }

        // return identity object build up from primary keys
        return getBroker().serviceIdentity().buildIdentity(
                getQueryObject().getClassDescriptor().getClassOfObject(), getTopLevelClass(), pkValues);
    }
1236062
@Override
    public Set<IPortletEntity> getPortletEntitiesForUser(int userId) {
        final Set<IPortletEntity> portletEntities =
                this.delegatePortletEntityDao.getPortletEntitiesForUser(userId);
        return this.wrapEntities(portletEntities);
    }
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);
	}
201868
public UserEntities getUsers(Map<String, String> queryParams) {
		UserEntities userEntities = restClient.get("users", UserEntities.class, queryParams);
		return userEntities;
	}
1023725
public List<RestletUtilUser> getUsers()
    {
        List<RestletUtilUser> result = new ArrayList<RestletUtilUser>();
        
        RepositoryConnection conn = null;
        try
        {
            conn = this.repository.getConnection();
            
            final String query = this.buildSparqlQueryToFindUser(null, true);
            
            this.log.debug("findUser: query={}", query);
            
            final TupleQuery tupleQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, query);
            
            final TupleQueryResult queryResult = tupleQuery.evaluate();
            
            try
            {
                while(queryResult.hasNext())
                {
                    final BindingSet bindingSet = queryResult.next();
                    Binding binding = bindingSet.getBinding("userIdentifier");
                    
                    result.add(this.buildRestletUserFromSparqlResult(binding.getValue().stringValue(), bindingSet));
                }
            }
            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 Collections.unmodifiableList(result);
    }
266723
@Restricted(NoExternalUse.class)
    public @Nullable ApiTokenStore.HashedToken getLegacyTokenOf(@Nonnull User user) {
        ApiTokenProperty apiTokenProperty = user.getProperty(ApiTokenProperty.class);
        return apiTokenProperty.getTokenStore().getLegacyToken();
    }
770867
public static TwilioRestClient getRestClient() {
        if (Twilio.restClient == null) {
            if (Twilio.username == null || Twilio.password == null) {
                throw new AuthenticationException(
                    "TwilioRestClient was used before AccountSid and AuthToken were set, please call Twilio.init()"
                );
            }

            TwilioRestClient.Builder builder = new TwilioRestClient.Builder(Twilio.username, Twilio.password);
            if (Twilio.accountSid != null) {
                builder.accountSid(Twilio.accountSid);
            }
            Twilio.restClient = builder.build();
        }

        return Twilio.restClient;
    }
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;
	}
381356
@GetMapping("/user")
  public ResponseEntity<User> getUser(
      @VersionApi int version, //<1>
      @RequestParam("id") String id) {
    throw new UnsupportedOperationException();
  }
531770
private User userFromResultSet(final ResultSet rs) throws SQLException {
      String niceName = Strings.nullToEmpty(rs.getString(3)).trim();
      String displayName = Strings.nullToEmpty(rs.getString(4)).trim();
      String useDisplayName = displayName.isEmpty() ? niceName : displayName;
      return new User(rs.getLong(1), rs.getString(2), useDisplayName, niceName, rs.getString(5), rs.getTimestamp(6).getTime(), rs.getString(7), ImmutableList.of());
   }
1207975
@Trivial
    private IdentifierType createIdentiferFromLdapEntry(LdapEntry ldapEntry) throws WIMException {
        IdentifierType outId = new IdentifierType();
        outId.setUniqueName(ldapEntry.getUniqueName());
        outId.setExternalId(ldapEntry.getExtId());
        outId.setExternalName(ldapEntry.getDN());
        outId.setRepositoryId(reposId);
        return outId;
    }
1104345
public final void setItsUser(final UserJetty pUser) {
    this.itsUser = pUser;
    if (this.itsId == null) {
      this.itsId = new IdUserRoleJetty();
    }
    this.itsId.setItsUser(this.itsUser);
  }
1108689
public function checkUserFollowsChannel($userIdentifier, $channelIdentifier)
    {
        if ($this->apiVersionIsGreaterThanV3()) {
            if (!is_numeric($userIdentifier)) {
                throw new InvalidIdentifierException('user');
            }

            if (!is_numeric($channelIdentifier)) {
                throw new InvalidIdentifierException('channel');
            }
        }

        return $this->get(sprintf('users/%s/follows/channels/%s', $userIdentifier, $channelIdentifier));
    }
739870
@Override
    protected List<IPersonAttributes> getPeopleForQuery(final PartialWhereClause queryBuilder, final String queryUserName) {
        //Execute the query
        final RowMapper<R> rowMapper = this.getRowMapper();

        final List<R> results;
        if (queryBuilder != null) {
            //Merge the generated SQL with the base query template
            final StringBuilder partialSqlWhere = queryBuilder.sql;
            final Matcher queryMatcher = WHERE_PLACEHOLDER.matcher(this.queryTemplate);
            final String querySQL = queryMatcher.replaceAll(partialSqlWhere.toString());

            results = this.simpleJdbcTemplate.query(querySQL, rowMapper, queryBuilder.arguments.toArray());

            if (this.logger.isDebugEnabled()) {
                this.logger.debug("Executed '" + this.queryTemplate + "' with arguments " + queryBuilder.arguments + " and got results " + results);
            }
        } else {
            results = this.simpleJdbcTemplate.query(this.queryTemplate, rowMapper);

            if (this.logger.isDebugEnabled()) {
                this.logger.debug("Executed '" + this.queryTemplate + "' and got results " + results);
            }
        }

        return this.parseAttributeMapFromResults(results, queryUserName);
    }