Create auth string from username and password.

@return basic authentication string
553756
public String getAuthString() {
        String credentials = this.username + ":" + this.password;
        try {

            String encoded = new Base64().encodeAsString(credentials.getBytes("ascii"));
            return "Basic " + encoded;

        } catch (final UnsupportedEncodingException e) {

            throw new InvalidRequestException("It must be possible to encode credentials as ascii", credentials, e);

        }
    }
1303394
public function getBasicAuth()
    {
        if (empty($this->basicAuth))
            return "";

        if (empty($this->basicAuth["username"]))
            // Username cannot be empty in Basic Authentication
            return "";

        $username = $this->basicAuth["username"];
        $password = isset($this->basicAuth["password"]) ? $this->basicAuth["password"] : "";
        return sprintf("%s:%s@", $username, $password);
    }
374827
static public String[] getUserNameAndPassword(String auth) throws Exception {

		auth = auth.trim();
		String[] components = auth.split("\\s+");
		if( components.length > 0 ) {
			if( "basic".equalsIgnoreCase(components[0].trim()) ) {
				// Basic authentication was used, second word is uuencoded
				if( components.length > 1 ) {
					String encoded = components[1];

					byte[] decoded = Base64.decodeBase64( encoded.getBytes() );
					StringWriter sw = new StringWriter();
					for(int loop=0; loop<decoded.length; ++loop) {
						sw.write((int)decoded[loop]);
					}

					String userAndPass = sw.toString();
					String[] tokens = userAndPass.trim().split(":");
					
					if( tokens.length < 2 ) {
						throw new Exception("Unable to decode name from basic authorization");
					}
					
					return tokens;
				} else {
					throw new Exception("Invalid authorization using Basic encoding");
				}
			}
		}
		
		throw new Exception("Unknown authorization type: "+auth);
	}
350409
public String getAuthority() {
        String userInfo = getUserInfo();
        StringBuilder auth = new StringBuilder();
        if(!"*".equals(userInfo)) {
            auth.append(userInfo).append("@");
        }
        auth.append('@').append(host).append(':').append(port);
        return auth.toString();
    }
552473
public HttpClientBuilder basicAuth(String username, String password) {
		basicAuthUsername = username;
		basicAuthPassword = password;
		return this;
	}
225885
public T authentication(String username, String password) {
        return authentication(username, password, false);
    }
1316698
public function withBasicAuth(?string $username = null, string $password = null): self
    {
        if ($username === null) {
            return $this->withoutHeader('Authorization');
        } else {
            $auth = base64_encode($username . ':' . $password);

            return $this->withHeader('Authorization', "Basic {$auth}");
        }
    }
734697
public function basicAuthentication(string $username, string $password = ""): HttpRequest
    {
        $this->username = $username;
        $this->password = $password;
        return $this;
    }
1042216
protected Account authenticate(String username, String password) {
        StandardCredentials authenticationToken = new StandardCredentials(username, password);
        Account account = securityManager.authenticate(authenticationToken);
        return account;
    }
181372
@Override
	public SecuritySetter<HttpURLConnection> basicAuth(String user, String password) throws CadiException {
		if(password.startsWith("enc:???")) {
			try {
				password = access.decrypt(password, true);
			} catch (IOException e) {
				throw new CadiException("Error decrypting password",e);
			}
		}
		try {
			return new HBasicAuthSS(user,password,si);
		} catch (IOException e) {
			throw new CadiException("Error creating HBasicAuthSS",e);
		}
	}
187365
protected IPromise<BasicAuthenticationResult> getCredentials(String user, String pw, String jwt) {
        Promise p = new Promise();
        if ( SESSIONID_SPECIAL_STRING.equals(pw) ) {
            sessionStorage.getUserFromSessionId(user).then( (r,e) -> {
                if ( r != null ) {
                    sessionStorage.getUser(r).then( (rec,err) -> {
                        if ( rec != null )
                            getCredentials(rec.getKey(),rec.getString("pwd"), null ).then(p);
                        else
                            p.reject("unknown user");
                    });
                } else {
                    p.reject("authentication failed");
                }
            });
        } else {
            sessionStorage.getUser(user).then((rec, err) -> {
                if (rec == null) {
                    p.reject("wrong user or password");
                } else {
                    if (pw.equals(rec.getString("pwd"))) {
                        if (!rec.getBool("verified")) {
                            // e.g. email verification etc.
                            p.reject("account not verified");
                        } else
                            p.resolve(new BasicAuthenticationResult().userName(rec.getKey()));
                    }
                }
            });
        }
        return p;
    }
373221
def get_auth_basic(self):
        """"""
        username = ''
        password = ''
        auth_header = self.get_header('authorization')
        if auth_header:
            m = re.search(r"^Basic\s+(\S+)$", auth_header, re.I)
            if m:
                auth_str = Base64.decode(m.group(1))
                username, password = auth_str.split(':', 1)

        return username, password
600497
public RestTemplateBuilder basicAuthentication(String username, String password) {
		return new RestTemplateBuilder(this.detectRequestFactory, this.rootUri,
				this.messageConverters, this.requestFactorySupplier,
				this.uriTemplateHandler, this.errorHandler,
				new BasicAuthenticationInterceptor(username, password),
				this.restTemplateCustomizers, this.requestFactoryCustomizer,
				this.interceptors);
	}
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;
    }
954112
def http_basic(r, username, password):
    
    username = str(username)
    password = str(password)

    auth_s = b64encode('%s:%s' % (username, password))
    r.headers['Authorization'] = ('Basic %s' % auth_s)

    return r
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();}
		}
	}
1187067
public CLIConnectionFactory basicAuth(String userInfo) {
        return authorization("Basic " + new String(Base64.encodeBase64((userInfo).getBytes())));
    }