Acquire the service token from Federated STS

@param string $username
@param string $password
@return string
18792
protected function acquireSecurityTokenFromFederatedSTS($username, $password) {

        $response = Requests::get(str_replace('{username}', $username, self::$RealmUrlTemplate),null);
        $federatedStsUrl = $this->getFederatedAuthenticationInformation($response);

        if ($federatedStsUrl) {
          $message_id = md5(uniqid($username . '-' . time() . '-' . rand() , true));
          $data = $this->prepareSecurityFederatedTokenRequest($username, $password, $message_id, $federatedStsUrl->textContent);

          $headers = array();
          $headers['Content-Type'] = 'application/soap+xml';
          $response = Requests::post($federatedStsUrl->textContent, $headers, $data);

          $samlAssertion = $this->getSamlAssertion($response);

          if ($samlAssertion) {
            $samlAssertion_node = $samlAssertion->item(0);
            $data = $this->prepareRST2Request($samlAssertion_node);
            $response = Requests::post(self::$RST2Url, $headers, $data);
            $this->usingFederatedSTS = TRUE;

            return $response;
          }
        }

        return NULL;
    }
268792
public function setToken($username = null)
    {
        // Only set Token if Username is supplied.
        if (! is_null($username)) {
            $this->token = new Token($username);
        }

        return $this;
    }
434049
public function Login ($username = '', $password = '') {
    if ($this->connected == false) {
      $this->error = 'Not connected to POP3 server';

      if ($this->do_debug >= 1) {
        $this->displayErrors();
      }
    }

    if (empty($username)) {
      $username = $this->username;
    }

    if (empty($password)) {
      $password = $this->password;
    }

    $pop_username = "USER $username" . $this->CRLF;
    $pop_password = "PASS $password" . $this->CRLF;

    //  Send the Username
    $this->sendString($pop_username);
    $pop3_response = $this->getResponse();

    if ($this->checkResponse($pop3_response)) {
      //  Send the Password
      $this->sendString($pop_password);
      $pop3_response = $this->getResponse();

      if ($this->checkResponse($pop3_response)) {
        return true;
      } else {
        return false;
      }
    } else {
      return false;
    }
  }
1190852
public function authentication($username, $password)
    {
        $endpoint = sprintf('authentication?username=%s', urlencode($username));
        $parameters['value'] = $password;
        return $this->apiClient->callEndpoint(
            $endpoint,
            $parameters,
            null,
            HttpMethod::REQUEST_POST
        );
    }
295247
protected function adminLogin($username, $password)
    {
        $hash = $this->getPasswordHash()->hash($password);

        $user = $this->getEntityManager()->getRepository('User')->findOne([
            'whereClause' => [
                'userName' => $username,
                'password' => $hash,
                'type' => ['admin', 'super-admin']
            ]
        ]);

        return $user;
    }
882789
public function Authenticate($username, $password)
    {
        // Start authentication
        fputs($this->smtp_conn, "AUTH LOGIN" . $this->CRLF);

        $rply = $this->get_lines();
        $code = substr($rply, 0, 3);

        if ($code != 334) {
            $this->error =
            array("error" => "AUTH not accepted from server",
                "smtp_code"   => $code,
                "smtp_msg"    => substr($rply, 4));
            if ($this->do_debug >= 1) {
                echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
            }
            return false;
        }

        // Send encoded username
        fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);

        $rply = $this->get_lines();
        $code = substr($rply, 0, 3);

        if ($code != 334) {
            $this->error =
            array("error" => "Username not accepted from server",
                "smtp_code"   => $code,
                "smtp_msg"    => substr($rply, 4));
            if ($this->do_debug >= 1) {
                echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
            }
            return false;
        }

        // Send encoded password
        fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);

        $rply = $this->get_lines();
        $code = substr($rply, 0, 3);

        if ($code != 235) {
            $this->error =
            array("error" => "Password not accepted from server",
                "smtp_code"   => $code,
                "smtp_msg"    => substr($rply, 4));
            if ($this->do_debug >= 1) {
                echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
            }
            return false;
        }

        return true;
    }
736494
private function createUser($username, $password)
    {
        $user = new UserInformation(
            [
                'username' => $username,
                'acl'      => UserInformationInterface::ROLE_ALL
            ]
        );

        $user->set('password', $this->get('security.password_encoder')->encodePassword($user, $password));

        $user = $this->get('tenside.user_provider')->addUser($user)->refreshUser($user);

        return $user;
    }
300253
public function authenticate(string $username, string $password, ?string $scope = '*'): Response
    {
        $body = $this->mergeApiBody(
            \array_filter(\compact('username', 'password', 'scope'))
        );

        return $this->send('POST', 'oauth/token', $this->getApiHeaders(), $body)
                    ->validateWith(function ($statusCode, $response) {
                        if ($statusCode !== 200) {
                            throw new RuntimeException('Unable to generate access token!');
                        }

                        $this->client->setAccessToken($response->toArray()['access_token']);
                    });
    }
1050175
private function passChallenge($username)
    {
        $getdata = [
            'operation' => 'getchallenge',
            'username'  => $username
        ];
        $result = $this->sendHttpRequest($getdata, 'GET');
        
        if (!is_array($result) || !isset($result[ 'token' ])) {
            return false;
        }

        $this->serviceExpireTime = $result[ 'expireTime' ];
        $this->serviceToken = $result[ 'token' ];

        return true;
    }
517910
public function authenticatePassword($clientId, string $clientSecret, string $username, string $password): Token
    {
        $request = new Request('POST', $this->tokenUrl, [
            'Content-Type' => 'application/json',
        ], json_encode([
            'client_id' => $clientId,
            'client_secret' => $clientSecret,
            'username' => $username,
            'password' => $password,
            'grant_type' => 'password',
        ]));

        $response = $this->getClient()->sendRequest($request);
        $responseBody = $response->getBody()->getContents();
        $this->token = $this->denormalizeObject(Token::class, [json_decode($responseBody)], false);

        return $this->token;
    }
1060955
public function getToken($username, $password)
    {
        try {
            return $this->bizImpl->getToken($username, $password);
        } catch (\Throwable $throwable) {
            throw new SystemException($throwable->getMessage(), $throwable->getCode());
        }
    }
665176
public function login( $username, $password )
	{
		$this->checkConnection( TRUE, FALSE );
		if( !@ftp_login( $this->resource, $username, $password ) )
			return FALSE;
		$this->auth	= TRUE;
		return TRUE;
	}
849428
public function basicAuth($username, $password)
    {
        $this->username = $username;
        $this->password = $password;
        return $this;
    }
788754
public function login($username = null, $password = null)
    {
        $this->_username = null !== $username ? $username : $this->_username;
        $this->_password = null !== $password ? $password : $this->_password;

        if (null === $this->_ssh_resource) {
            throw new TransportException(sprintf('None SSH connection available.'));
        }

        if (null === $this->_ssh_key_pub) {
            if (false === ssh2_auth_password($this->_ssh_resource, $this->_username, $this->_password)) {
                throw new TransportException(sprintf('Could not authenticate with username %s.', $this->_username));
            }
        } else {
            if (false === ssh2_auth_pubkey_file($this->_ssh_resource, $this->_username, $this->_ssh_key_pub, $this->_ssh_key_priv, $this->_ssh_key_pass)) {
                throw new TransportException(sprintf('Could not authenticate with keyfile %s.', $this->_keyfile));
            }
        }

        if (false === $this->_sftp_resource = ssh2_sftp($this->_ssh_resource)) {
            throw new TransportException("Could not initialize SFTP subsystem.");
        }

        return $this;
    }
811027
protected function authenticate($username, $password) {
        $authenticator=$this->config()->authenticator_class;
        
        $member=$authenticator::authenticate(array(
                                                $this->config()->authenticator_username_field=>$username,
                                                'Password'=>$password
                                            ));
        
        return (!empty($member) && $member!==false && $member->exists()==true && Permission::check('KAPOST_API_ACCESS', 'any', $member));
    }
1292132
public function getAccessToken($apiKey, $apiSecret, $username, $password)
    {
        $response = $this->guzzle->request('POST', self::ENDPOINT, [
            'auth' => [$apiKey, $apiSecret],
            'form_params' => [
                'grant_type' => 'password',
                'username' => $username,
                'password' => $password,
            ],
        ]);

        $data = json_decode((string) $response->getBody(), true);

        $token = $data['access_token'];
        $expiry = new \DateTime('@' . (time() + $data['expires_in']));

        return new AccessToken($token, $expiry);
    }
550291
public function setAuthorization($username, $password)
    {
        $this->username = $username;
        $this->password = $password;

        return $this;
    }