@author Vova Feldman (@svovaf)
@since  2.0.0

@param number $id
@param string $public_key
@param string $secret_key

@return \FS_User
489527
private function setup_user( $id, $public_key, $secret_key ) {
            $user = self::_get_user_by_id( $id );

            if ( is_object( $user ) ) {
                $this->_user = $user;
            } else {
                $user             = new FS_User();
                $user->id         = $id;
                $user->public_key = $public_key;
                $user->secret_key = $secret_key;

                $this->_user = $user;
                $user_result = $this->get_api_user_scope()->get();
                $user        = new FS_User( $user_result );

                $this->_user = $user;
                $this->_store_user();
            }

            return $user;
        }
949541
public static function getCachedInfo($id, $key = null, $default = null)
    {
        $cacheKey = 'user:' . $id;
        $result = \Cache::remember($cacheKey, \Config::get('df.default_cache_ttl'), function () use ($id){
            $user = static::whereId($id)->first();
            if (empty($user)) {
                throw new NotFoundException("User not found.");
            }

            if (!$user->is_active) {
                throw new ForbiddenException("User is not active.");
            }

            $userInfo = $user->toArray();
            $userInfo['is_sys_admin'] = $user->is_sys_admin;

            return $userInfo;
        });

        if (is_null($result)) {
            return $default;
        }

        if (is_null($key)) {
            return $result;
        }

        return (isset($result[$key]) ? $result[$key] : $default);
    }
1063165
static public function publicIdDecode($public_id)
    {
        $hashids = new Hashids(self::getSalt(), self::getMinLength(), self::getAlphabet());

        $id = $hashids->decode($public_id);

        if (is_array($id) && isset($id[0]))
            return $id[0];

        return null;
    }
138957
protected static function g_retrieve($clazz, $url, $publickey = null, $secretkey = null)
    {
        $resource = call_user_func(array($clazz, 'getInstance'), $clazz, $publickey, $secretkey);
        $result   = $resource->execute($url, self::REQUEST_GET, $resource->getResourceKey());
        $resource->refresh($result);

        return $resource;
    }
971791
public static function init($key = null, $secret = null) {
        $patrol = new Patrol;

        if ($key && $secret) {
            $patrol->setApiKey($key);
            $patrol->setApiSecret($secret);
        }

        return $patrol;
    }
1304122
function SecretGenerator(manifest, instance_id, secrets) {
  ApiModule.call(this);

  var self = this;

  self._manifest = manifest;
  self._secrets = secrets;
  self._instance_id = instance_id;
}
952431
public function get($user_id, $params = [])
    {
        return User::make($this->client, $user_id)
            ->setParams($params);
    }
993444
def get_by_id(self, id):
        """"""
        return self.user_cls(id=id, password='secret' + str(id))
577812
public function getUserData($key, $id = 0)
    {
        // Current User id
        if (!$id) {
            if (defined('USER_ID')) {
                $id = USER_ID;
            } else {
                return NULL;
            }
        } else {
            $id = abs((int)$id);
        }

        // Check or init cache
        if (!isset(self::$cached_user_data[$id])) {
            $user = AdminUserRepository::findOneEntityById($id);
            if (!$user) {
                return NULL;
            }
            self::$cached_user_data[$id] = $user->getAsArray();

            // Unset critical data
            unset(self::$cached_user_data[$id]['password']);
        }

        return isset(self::$cached_user_data[$id][$key]) ? self::$cached_user_data[$id][$key] : NULL;
    }
612069
public function checkClientCredentials($client_id, $client_secret = null)
    {
        return isset($this->clientCredentials[$client_id]['secret']) && $this->clientCredentials[$client_id]['secret'] === $client_secret;
    }
672935
function(publicKey, callback) {
        request.head(
            this.getResourceUrl({ path: '/keys/' + publicKey, user: null }),
            get404Handler(callback)
        );
        return this;
    }
125216
public function checkHOTP($secret, $counter, $code, $hash_type = 'sha512')
	{
		return $this->stringCompare($code, $this->generateCode($secret, $counter, $hash_type));
	}
407217
def get_common_secret(self, server_public, client_public):
        
        return self.hash(self.pad(client_public), self.pad(server_public))
1041040
public function getOAuthClient($client_id, $client_secret, $redirect_uri)
    {
        $options = [
            'clientId' => $client_id,
            'clientSecret' => $client_secret,
            'redirectUri' => $redirect_uri
        ];
        $OAuthClient = new OAuth($options);

        return $OAuthClient;
    }
1364028
public function getClientKey($client_id, $subject)
    {
        $stmt = $this->db->prepare($sql = sprintf('SELECT public_key from %s where client_id=:client_id AND subject=:subject', $this->config['jwt_table']));

        $stmt->execute(array('client_id' => $client_id, 'subject' => $subject));
        return $stmt->fetch();
    }
967183
public function checkClientCredentials($client_id, $client_secret = null)
    {
        $result = $this->collection('client_table')->findOne(array('client_id' => $client_id));

        return $result['client_secret'] == $client_secret;
    }
649559
static function _get_user_by_id( $user_id ) {
            self::$_static_logger->entrance( "user_id = {$user_id}" );

            $users = self::get_all_users();

            if ( is_array( $users ) ) {
                if ( isset( $users[ $user_id ] ) &&
                     $users[ $user_id ] instanceof FS_User &&
                     $user_id == $users[ $user_id ]->id
                ) {
                    return $users[ $user_id ];
                }

                // If user wasn't found by the key, iterate over all the users collection.
                foreach ( $users as $user ) {
                    /**
                     * @var FS_User $user
                     */
                    if ( $user_id == $user->id ) {
                        return $user;
                    }
                }
            }

            return null;
        }