Sets up authentication.

@param username The HTTP basic authentication username.
@param password The HTTP basic authentication password.
@param realm    Optional. Defaults to "restolino".
192468
private void configureAuthentication(String username, String password, String realm) {

        // If the username is set, set up authentication:
        if (StringUtils.isNotBlank(username)) {

            this.username = username;
            this.password = password;
            this.realm = StringUtils.defaultIfBlank(realm, "restolino");

            authenticationEnabled = true;
        }
    }
595996
def basicauthfail(self, realm = b'all'):
        
        if not isinstance(realm, bytes):
            realm = realm.encode('ascii')
        self.start_response(401, [(b'WWW-Authenticate', b'Basic realm="' + realm + b'"')])
        self.exit(b'<h1>' + _createstatus(401) + b'</h1>')
430508
protected String callRestApi(final String username, final String password) {

        final String basicAuth = Base64.getEncoder().encodeToString((username + ":" + password).getBytes(StandardCharsets.UTF_8));
        final Map<String, String> headers = new HashMap<>();
        headers.put(HttpConstants.AUTHORIZATION_HEADER, HttpConstants.BASIC_HEADER_PREFIX + basicAuth);

        HttpURLConnection connection = null;
        try {
            connection = HttpUtils.openPostConnection(new URL(url), headers);
            int code = connection.getResponseCode();
            if (code == 200) {
                logger.debug("Authentication success for username: {}", username);
                return HttpUtils.readBody(connection);
            } else if (code == 401 || code == 403) {
                logger.info("Authentication failure for username: {} -> {}", username, HttpUtils.buildHttpErrorMessage(connection));
                return null;
            } else {
                logger.warn("Unexpected error for username: {} -> {}", username, HttpUtils.buildHttpErrorMessage(connection));
                return null;
            }
        } catch (final IOException e) {
            throw new TechnicalException(e);
        } finally {
            HttpUtils.closeConnection(connection);
        }
    }
570803
function setAuthorization($username,$password){
		settype($username,"string");
		settype($password,"string");

		$this->_Username = $username;
		$this->_Password = $password;
		$this->_AuthType = "basic";
	}
552473
public HttpClientBuilder basicAuth(String username, String password) {
		basicAuthUsername = username;
		basicAuthPassword = password;
		return this;
	}
1167973
public void login(String username, String password) throws IOException {
        String requestUrl = RESOURCE + "/login";
        Credentials creds = new Credentials();

        creds.setPassword(password);
        creds.setUsername(username);

        ArgusResponse response = getClient().executeHttpRequest(ArgusHttpClient.RequestType.POST, requestUrl, creds);

        try {
		assertValidResponse(response, requestUrl);
	} catch (TokenExpiredException e) {
		//This should never happen
		throw new RuntimeException("This should never happen. login() method should never throw a TokenExpiredException", e);
	}
        
        Map<String, String> tokens = fromJson(response.getResult(), new TypeReference<Map<String, String>>() {});
        getClient().accessToken = tokens.get("accessToken");
        getClient().refreshToken = tokens.get("refreshToken");
    }
825964
public function iSetBasicAuthenticationWithAnd($username, $password)
    {
        $authorization = base64_encode($username.':'.$password);
        $this->restApiBrowser->setRequestHeader('Authorization', 'Basic '.$authorization);
    }
45283
public B setBasicAuth(final String username, final String password) {
        String auth = Base64.encodeToString((username + ":" + password).getBytes(), Base64.NO_WRAP);
        httpParams.addHeader("Authorization", "Basic " + auth);
        return self();
    }
1282012
public CRestBuilder basicAuth(String username, String password) {
        this.auth = "basic";
        this.username = username;
        this.password = password;
        return this;
    }
1208499
public void sendChallenge(UserRealm realm, HttpResponse response) throws IOException
    {
        response.setField(HttpFields.__WwwAuthenticate,"basic realm=\""+realm.getName()+'"');

        ServletHttpResponse sresponse = (ServletHttpResponse) response.getWrapper();
        if (sresponse!=null)
            sresponse.sendError(HttpResponse.__401_Unauthorized);
        else
            response.sendError(HttpResponse.__401_Unauthorized);
    }
535878
static public void sendAuthRequiredError(HttpServletResponse response, String realm) throws IOException {
		response.setHeader("WWW-Authenticate", "Basic realm=\""+realm+"\"");
		response.setHeader("Cache-Control", "no-cache,must-revalidate");
		response.setDateHeader("Expires", (new Date()).getTime());
		response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization Required");
	}
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");
	}
    }
963397
public void setCredentials(String username, String password) {
                if (GitTaskUtils.isNullOrBlankString(username) || GitTaskUtils.isNullOrBlankString(password)) {
                        throw new IllegalArgumentException("Credentials must not be empty.");
                }

                credentials = new UsernamePasswordCredentialsProvider(username, password);
        }
368528
public function setBasicAuth( $username, $password )
	{
		$this->curl->setOption( CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
		$this->curl->setOption( CURLOPT_USERPWD, $username.":".$password );
	}
12394
public synchronized void refreshWithPassword(String username, String password, CharacterSelector characterSelector) throws AuthenticationException {
		refreshWithPassword(createPasswordProvider(username, password, characterSelector));
	}
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);
	}
150066
public void set(final String value) {
        // username:password:groups:realm:true|false
        if (value != null) {
            final List<String> parts = splitAndTrim(value, ':');
            // User name and password should be required so we need a minimum of 2
            switch (parts.size()) {
                case 5: {
                    applicationUser = Boolean.parseBoolean(parts.get(4));
                }
                case 4: {
                    realm = parts.get(3);
                }
                case 3: {
                    final String g = parts.get(2);
                    if (!g.isEmpty()) {
                        groups = splitAndTrim(g, ',');
                    }
                }
                case 2: {
                    username = parts.get(0);
                    password = parts.get(1);
                    break;
                }
                default:
                    throw new IllegalArgumentException("Username and password are required parameters");
            }
        }
    }