Helper method to set username for the first HTTP basic authentication.

@param username Username
333984
public void setUsername(String username) {
        for (Authentication auth : authentications.values()) {
            if (auth instanceof HttpBasicAuth) {
                ((HttpBasicAuth) auth).setUsername(username);
                return;
            }
        }
        throw new RuntimeException("No HTTP basic authentication configured!");
    }
950280
public void setPassword(String password) {
        for (Authentication auth : authentications.values()) {
            if (auth instanceof HttpBasicAuth) {
                ((HttpBasicAuth) auth).setPassword(password);
                return;
            }
        }
        throw new RuntimeException("No HTTP basic authentication configured!");
    }
367236
protected boolean configureUsernamePassword(final GitHubClient client,
			final String userName, final String password) {
		if (StringUtils.isEmpty(userName, password))
			return false;

		if (isDebug())
			debug("Using basic authentication with username: " + userName);
		client.setCredentials(userName, password);
		return true;
	}
513396
public static void putPasswordResetUsername(final RequestContext requestContext, final String username) {
        val flowScope = requestContext.getFlowScope();
        flowScope.put("username", username);
    }
1036384
def username(self, username):
        
        validate_username(username)
        self._username = username.lower()
        self._displayname = username
121936
public Principal authenticate(String username, char password[]) 
    throws NamingException
	{
		DirContext ctx = null;
		try
		{
			String userDN = toDN(username);
			ctx = initContext(userDN, password);

			return new X500Principal(userDN);
		}
		finally
		{
			if(ctx != null)
				try{ ctx.close(); } catch(Exception e){e.printStackTrace();}
		}
	}
647846
public void authenticate(AuthenticationProtocol authentication,
			String servicename) throws SshException, AuthenticationResult {

		try {
			if (getUsername() == null || getPassword() == null) {
				throw new SshException("Username or password not set!",
						SshException.BAD_API_USAGE);
			}

			if (passwordChangeRequired && newpassword == null) {
				throw new SshException("You must set a new password!",
						SshException.BAD_API_USAGE);
			}

			ByteArrayWriter msg = new ByteArrayWriter();

			try {
				msg.writeBoolean(passwordChangeRequired);
				msg.writeString(getPassword());
				if (passwordChangeRequired) {
					msg.writeString(newpassword);

				}
				authentication.sendRequest(getUsername(), servicename,
						"password", msg.toByteArray());
			} finally {
				try {
					msg.close();
				} catch (IOException e) {
				}
			}
			// We need to read the response since we may have password change.
			byte[] response = authentication.readMessage();

			if (response[0] != SSH_MSG_USERAUTH_PASSWD_CHANGEREQ) {
				authentication.transport.disconnect(
						TransportProtocol.PROTOCOL_ERROR,
						"Unexpected message received");
				throw new SshException(
						"Unexpected response from Authentication Protocol",
						SshException.PROTOCOL_VIOLATION);
			}

			passwordChangeRequired = true;
			throw new AuthenticationResult(SshAuthentication.FAILED);
		} catch (IOException ex) {
			throw new SshException(ex, SshException.INTERNAL_ERROR);
		}
	}
655899
private void addBasicCredentials(BasicAuthInfo authInfo,
                                     Map<AuthScope, Credentials> credentialsMap) {
        logger.info("BASIC authentication for: {}", authInfo.getLoginTarget());
        Credentials credentials = new UsernamePasswordCredentials(authInfo.getUsername(),
                authInfo.getPassword());
        credentialsMap.put(new AuthScope(authInfo.getHost(), authInfo.getPort()), credentials);
    }
914432
public function setUserName($userName)
    {
        $user = posix_getpwnam($userName);
        if (! isset($user['uid'])) {
            throw new InvalidArgumentException(sprintf('"%s" is not a valid user name', $userName));
        }

        $this->setUserId($user['uid']);
    }
1112438
public ControllerRoute withBasicAuthentication(String username, String password) {
        Objects.requireNonNull(username, Required.USERNAME.toString());
        Objects.requireNonNull(password, Required.PASSWORD.toString());
        
        this.username = username;
        this.password = password;
        
        return this;
    }
1007912
public Http auth(String username, String password) {
        return username(username).password(password);
    }
1316055
public void authenticate(String username, String password) {
        ldapTemplate.authenticate(query().where("objectClass").is("simpleSecurityObject").and("cn").is(username), password);
        LOGGER.info("Successfully authenticated " + username);
    }
816232
public void setCredential(String username, String password) {
	if (username != null) {
	    env.put("java.naming.security.principal", username);
	    env.put("java.naming.security.credentials", password);
	}
	else {
	    env.remove("java.naming.security.principal");
	    env.remove("java.naming.security.credentials");
	}
    }
606506
public boolean login(final String username, final byte[] authResponse) {
        Optional<ProxyUser> user = getUser(username);
        return user.isPresent() && (Strings.isNullOrEmpty(user.get().getPassword()) || Arrays.equals(getAuthCipherBytes(user.get().getPassword()), authResponse));
    }
578454
@SuppressWarnings("unused")
    public void setSmtpAuth(String userName, String password) {
        setSmtpUsername(userName);
        setSmtpPassword(password);
    }
1355315
public void setUserName(final String userName) {

        if (TraceComponent.isAnyTracingEnabled() && TRACE.isDebugEnabled()) {
            SibTr.debug(this, TRACE, "UserName", userName);
        }
        _userName = userName;

    }
1207144
public HttpRequest basicAuth(String username, String password) {
		final String data = username.concat(":").concat(password);
		final String base64 = Base64.encode(data, charset);

		header("Authorization", "Basic " + base64, true);

		return this;
	}