Checks if the user with {@code username} has the specified {@code grant}
@param grant a {@link com.baasbox.android.Grant}
@param username a username
@return
979007
public boolean hasUserGrant(Grant grant,String username){
        if (grant == null) throw new IllegalArgumentException("grant cannot be null");
        if (username==null) throw new IllegalArgumentException("username cannot be null");
        Set<String> users = userGrants.get(grant);
        return users!=null &&users.contains(username);
    }
608524
protected List<GrantedAuthority> getAuthorities(String username) {
        final List<GrantedAuthority> grantedAuths = new ArrayList<>();
        grantedAuths.add(new SimpleGrantedAuthority("DATA_SCIENTIST"));
        return grantedAuths;
    }
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;
	}
381810
public List<CouchDbGoogleAuthenticatorAccount> findByUsername(final String username) {
        try {
            return queryView("by_username", username);
        } catch (final DocumentNotFoundException ignored) {
            return null;
        }
    }
460030
public void addUsername(String username) {
        SystemAssert.requireArgument(username != null && !username.isEmpty(), "Username cannot be null or empty.");
        this.usernames.add(username);
    }
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);
    }
647280
public static SanePasswordProvider forUsernameAndPassword(
      final String username, final String password) {
    return new SanePasswordProvider() {
      @Override
      public String getUsername(String resource) {
        return username;
      }

      @Override
      public String getPassword(String resource) {
        return password;
      }

      @Override
      public boolean canAuthenticate(String resource) {
        return true;
      }
    };
  }
277027
public static boolean isSuperuser(String username)
    {
        UntypedResultSet result = selectUser(username);
        return !result.isEmpty() && result.one().getBoolean("super");
    }
371913
public List<Permission> getUserPermission(String userName) {
        ACL acl = getServiceDirectoryClient().getACL(AuthScheme.DIRECTORY, userName);

        int permissionId = 0;
        if(acl != null){
            permissionId = acl.getPermission();
        }
        return PermissionUtil.id2Permissions(permissionId);
    }
585622
public Response unlockUser(String username) {
		return restClient.delete("lockouts/" + username, new HashMap<String, String>());
	}
1112836
public static String getUser(String userName, UserGroupInformation ugi) {
        if (StringUtils.isNotEmpty(userName)) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Returning userName {}", userName);
            }
            return userName;
        }

        if (ugi != null && StringUtils.isNotEmpty(ugi.getShortUserName())) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Returning ugi.getShortUserName {}", userName);
            }
            return ugi.getShortUserName();
        }

        try {
            return UserGroupInformation.getCurrentUser().getShortUserName();
        } catch (IOException e) {
            LOG.warn("Failed for UserGroupInformation.getCurrentUser() ", e);
            return System.getProperty("user.name");
        }
    }
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;
    }
661040
private PortalUser getPortalUser(final String userName) {
        return jdbcOperations.execute(
                (ConnectionCallback<PortalUser>)
                        con -> {
                            PortalUser portalUser = null;
                            PreparedStatement pstmt = null;

                            try {
                                String query = "SELECT USER_ID FROM UP_USER WHERE USER_NAME=?";

                                pstmt = con.prepareStatement(query);
                                pstmt.setString(1, userName);

                                ResultSet rs = null;
                                try {
                                    if (log.isDebugEnabled())
                                        log.debug(
                                                "RDBMUserIdentityStore::getPortalUID(userName="
                                                        + userName
                                                        + "): "
                                                        + query);
                                    rs = pstmt.executeQuery();
                                    if (rs.next()) {
                                        portalUser = new PortalUser();
                                        portalUser.setUserId(rs.getInt("USER_ID"));
                                        portalUser.setUserName(userName);
                                    }
                                } finally {
                                    try {
                                        if (rs != null) {
                                            rs.close();
                                        }
                                    } catch (Exception e) {
                                    }
                                }
                            } finally {
                                try {
                                    if (pstmt != null) {
                                        pstmt.close();
                                    }
                                } catch (Exception e) {
                                }
                            }

                            return portalUser;
                        });
    }
1261986
public static boolean checkBasicAuth(HttpServletRequest servletRequest, String username, String password) {

		String basicAuth = servletRequest.getHeader("Authorization");
		if (StringUtils.isNullOrEmptyTrimmed(basicAuth) || !basicAuth.startsWith("Basic ")) {
			return false;
		}

		String base64Credentials = basicAuth.substring("Basic".length()).trim();
		String credentials = new String(Base64.getDecoder().decode(base64Credentials), Charset.forName("UTF-8"));

		// credentials = username:password
		final String[] values = credentials.split(":", 2);
		if (values.length != 2) {
			return false;
		}

		return StringUtils.equals(values[0], username) && StringUtils.equals(values[1], password);
	}
22193
static boolean _isUsernameValid(String username) {
        Matcher matcher = Pattern.compile(EMAIL_REGEX).matcher(username);

        return matcher.matches();
    }
769501
public Collection<GrantedAuthority> getGrantedAuthorities(DirContextOperations user, String username) {
        String userDn = user.getNameInNamespace();

        if (logger.isDebugEnabled()) {
            logger.debug("Getting authorities for user " + userDn);
        }

        Set<GrantedAuthority> roles = getGroupMembershipRoles(userDn, username);

        Set<GrantedAuthority> extraRoles = getAdditionalRoles(user, username);

        if (extraRoles != null) {
            roles.addAll(extraRoles);
        }

        if (defaultRole != null) {
            roles.add(defaultRole);
        }

        List<GrantedAuthority> result = new ArrayList<GrantedAuthority>(roles.size());
        result.addAll(roles);

        return result;
    }
554157
public WebhookMessageBuilder setUsername(String username)
    {
        this.username = Helpers.isBlank(username) ? null : username;
        return this;
    }