Determines which API provider should be used.

@param array $credentials

@throws \Exception
193223
private function setApiProvider($credentials)
    {
        if ($this instanceof \Srmklive\PayPal\Services\AdaptivePayments) {
            $this->setAdaptivePaymentsOptions();
        } elseif ($this instanceof \Srmklive\PayPal\Services\ExpressCheckout) {
            $this->setExpressCheckoutOptions($credentials);
        } else {
            throw new \Exception('Invalid api credentials provided for PayPal!. Please provide the right api credentials.');
        }
    }
960103
protected function validatePasswordWithDefaults(array $credentials)
    {
        [$password, $confirm] = [
            $credentials['password'],
            $credentials['password_confirmation'],
        ];

        return $password === $confirm && mb_strlen($password) >= 8;
    }
481632
protected function getPasswordCredential($credentials = array())
	{
		$passField = $this->app['config']['auth.credentials.password'];

		if (isset($credentials[$passField]))
		{
			return $credentials[$passField];
		}
		else if (Input::has($passField))
		{
			return Input::get($passField);
		}
		else if (isset($credentials['user_password']))
		{
			return $credentials['user_password'];
		}
		else if (isset($credentials['pwd']))
		{
			return $credentials['pwd'];
		}

		throw new InvalidArgumentException("Password field not found");

	}
962614
public function getByCredentials(array $credentials) : ?Authenticatable
    {
        if (empty($credentials)) {
            return null;
        }

        // First we will add each credential element to the query as a where clause.
        // Then we can execute the query and, if we found a user, return it in a
        // Eloquent User "model" that will be utilized by the Guard instances.
        $query = $this->getModel()->newQuery();

        foreach ($credentials as $key => $value) {
            if (! Str::contains($key, 'password')) {
                $query->where($key, $value);
            }
        }

        return $query->first();
    }
1142641
public function retrieveByCredentials(array $credentials)
    {
        if (empty($credentials) ||
           (count($credentials) === 1 &&
            array_key_exists('password', $credentials))) {
            return;
        }

        // First we will add each credential element to the query as a where clause.
        // Then we can execute the query and, if we found a user, return it in a
        // Eloquent User "model" that will be utilized by the Guard instances.
        $query = $this->newModelQuery();

        foreach ($credentials as $key => $value) {
            if (Str::contains($key, 'password')) {
                continue;
            }

            if (is_array($value) || $value instanceof Arrayable) {
                $query->whereIn($key, $value);
            } else {
                $query->where($key, $value);
            }
        }

        return $query->first();
    }
352037
public function login($credentials) {
    if (!isset($credentials['login']) || !isset($credentials['password'])) {
      throw new IllegalArgumentException("The parameters 'login' and 'password' are required");
    }
    $config = ObjectFactory::getInstance('configuration');

    $login = $credentials['login'];
    $password = $credentials['password'];

    // try to receive the user with given credentials
    $user = $this->principalFactory->getUser($login, true);

    // check if user exists
    $loginOk = false;
    if ($user != null && $user->isActive()) {
      // check password
      $loginOk = $user->verifyPassword($password);
      if ($loginOk) {
        // load user config initially
        $userConfig = $user->getConfig();
        if (strlen($userConfig) > 0) {
          $config->addConfiguration($userConfig);
        }
        return $user;
      }
    }
    return null;
  }
900276
public function authenticate(array $credentials)
    {
        list($username, $password) = $credentials;
        $user = $this->users->findOneBy(array('username' => $username));

        if (!$user) {
            throw new NS\AuthenticationException("User not found.", self::IDENTITY_NOT_FOUND);
        }

        if ($user->password !== $this->calculateHash($password)) {
            throw new NS\AuthenticationException("Invalid password.", self::INVALID_CREDENTIAL);
        }

        $permissions = array();
        foreach ($user->getRole()->getPermissions() as $key => $per) {
            $permissions[$per->getResource()] = $per->getRead();
        }

        return new NS\Identity($user->id, $user->getRole()->getName(), array(
            'username' => $user->username,
            'email' => $user->email,
            'permissions' => $permissions,
        ));
    }
1338376
protected function handleLogin(array $credentials = [], $remember = false)
    {
        $loginAttribute = strtolower(config('df.login_attribute', 'email'));
        if ($loginAttribute === 'username') {
            $username = array_get($credentials, 'username');
            if (empty($username)) {
                throw new BadRequestException('Login request is missing required username.');
            }
            unset($credentials['email']);
        } else {
            $email = array_get($credentials, 'email');
            if (empty($email)) {
                throw new BadRequestException('Login request is missing required email.');
            }
            unset($credentials['username']);
        }

        $password = array_get($credentials, 'password');
        if (empty($password)) {
            throw new BadRequestException('Login request is missing required password.');
        }

        $credentials['is_active'] = 1;

        // if user management not available then only system admins can login.
        if (!class_exists('\DreamFactory\Core\User\Resources\System\User')) {
            $credentials['is_sys_admin'] = 1;
        }

        if (Session::authenticate($credentials, $remember, true, $this->getAppId())) {
            return Session::getPublicInfo();
        } else {
            throw new UnauthorizedException('Invalid credentials supplied.');
        }
    }
786423
protected function authenticateWith($providers, array $options = [])
    {
        $providers = $this->getPropertyValue($providers);

        $this->authenticationProviders[] = \compact('providers', 'options');
    }
771479
protected function loadProviders($providers)
	{
		foreach ((array) $providers as $provider) {
			$provider = $this->container->get($provider);

			if (!$provider instanceof ServiceProviderInterface) {
				$providerName = get_class($provider);
				throw new \Exception(
					"$providerName does not implement required \\TitaPHP\\Foundation\\ServiceProviderInterface Interface"
				);
			}

			$provider->register($this);
		}
	}
181056
public function setCredentials(array $credentials) : AuthenticatorInterface
    {
        if (array_key_exists('source', $credentials) && preg_match('/^api*/', $credentials['source'])) {
            $this->api = true;
            $this->source = $credentials['source'];
        }

        return $this;
    }
177203
public static function configureOAuth($settings)
    {
        if (!isset($settings['auth_token'])) {
            throw new Exception("'auth_token' must be provided");
        }

        if (!isset($settings['store_hash'])) {
            throw new Exception("'store_hash' must be provided");
        }

        self::$client_id = $settings['client_id'];
        self::$auth_token = $settings['auth_token'];
        self::$store_hash = $settings['store_hash'];

        self::$client_secret = isset($settings['client_secret']) ? $settings['client_secret'] : null;

        self::$api_path = self::$api_url . sprintf(self::$stores_prefix, self::$store_hash);
        self::$connection = false;
    }
508404
protected function validateEmailVerification(array $credentials)
    {
        if (is_null($user = $this->getUser($credentials))) {
            return static::INVALID_USER;
        }

        if (! $this->validateToken($user, $credentials)) {
            return static::INVALID_TOKEN;
        }

        if (! $this->validateTimestamp($credentials['expiration'])) {
            return static::EXPIRED_TOKEN;
        }

        return $user;
    }
1114165
public static function setApiVersion($version)
    {
        if (! in_array($version, [1,2])) {
            throw new \Exception(sprintf("The %d version is not supported", $version));
        }
        self::$apiVersion = $version;
        
        // Refresh services if version is changed and base url is defined
        if (self::$url) {
            self::initServices();
        }
    }
1018067
private function setApiProviderConfiguration($credentials)
    {
        // Setting PayPal API Credentials
        collect($credentials[$this->mode])->map(function ($value, $key) {
            $this->config[$key] = $value;
        });

        // Setup PayPal API Signature value to use.
        $this->config['signature'] = empty($this->config['certificate']) ?
        $this->config['secret'] : $this->config['certificate'];

        $this->paymentAction = $credentials['payment_action'];

        $this->locale = $credentials['locale'];

        $this->certificate = $this->config['certificate'];

        $this->validateSSL = $credentials['validate_ssl'];

        $this->setApiProvider($credentials);
    }
1149367
public function retrieveByCredentials(array $credentials)
    {
        $user = parent::retrieveByCredentials($credentials);

        return $user && $user->hasGroup('sharp') ? $user : null;
    }
26126
public static function configure($settings)
    {
        if (isset($settings['client_id'])) {
            self::configureOAuth($settings);
        } else {
            self::configureBasicAuth($settings);
        }
    }