Returns the token object for the given public key

@access public
@param string $publicKey
@return boolean
498107
public function getTokenForPublicKey($publicKey)
    {
        if (!$this->accessControlManager->hasAccessEntityForName(self::ACCESS_ENTITY_TYPE, $publicKey)) {
            return false;
        }
        
        // Get the access entity
        $accessEntity = $this->accessControlManager->getAccessEntityForName(self::ACCESS_ENTITY_TYPE, $publicKey);

        if ($accessEntity === false) {
            return false;
        }
        
        return $accessEntity;
    }
698046
public function activateUser(string $key)
    {

        // Get tokendate from db
        $tokenhandler = new ActivationToken($this->db);
        $tokenhandler->setSelectorTokenString($key);

        // Store the current to extracted from selector:token string ($key)
        $token_from_key = $tokenhandler->getActivationToken();

        // Load the tokendata by using the selector from selector:token string ($key)
        $tokenhandler->loadTokenData();

        // Get user id
        $id_user = $tokenhandler->getUserId();

        // No user id means the activation must fail
        if (empty($id_user)) {
            return false;
        }

        // Get the token loaded from db via selector from selector:token string ($key)
        $token_from_db = $tokenhandler->getActivationToken();

        // Matching hashes?
        if (!hash_equals($token_from_key, $token_from_db)) {
            return false;
        }

        // Activate user
        $this->db->qb([
            'table' => $this->table,
            'method' => 'UPDATE',
            'fields' => 'state',
            'filter' => 'id_user=:id_user',
            'params' => [
                ':state' => 0,
                ':id_user' => $id_user
            ]
        ], true);

        // and delete the token of this user
        $tokenhandler->deleteActivationToken();

        // And finally return user id
        return $id_user;
    }
225228
public function getPublicKey($client_id = null)
    {
        if (isset($this->keys[$client_id])) {
            return $this->keys[$client_id]['public_key'];
        }

        // use a global encryption pair
        if (isset($this->keys['public_key'])) {
            return $this->keys['public_key'];
        }

        return false;
    }
815528
public function encryptByPublicKey_data($data, $publickey = '')
	{
		$RSACrypt = new RSACrypt();

		if ($publickey != "") {
			$RSACrypt->pubkey = $publickey;
		}
		$crypt_res = "";
		for ($i = 0; $i < ((strlen($data) - strlen($data) % 117) / 117 + 1); $i++) {
			$crypt_res = $crypt_res . ($RSACrypt->encryptByPublicKey(mb_strcut($data, $i * 117, 117, 'utf-8')));
		}
		return $crypt_res;
	}
1224005
public static function verify($token, $key)
    {
        // Check values
        if (empty($token) || empty($key)) {
            return false;
        }

        // Split parts
        list($payloadJSON_encoded, $signature) = explode('.', $token);

        // Generate signature to verify
        $signatureGenerated = hash_hmac('SHA256', $payloadJSON_encoded, $key);

        return ($signature === $signatureGenerated);
    }
1255688
public function setPublicKey($public_key)
    {
        // If the public key is a file name then convert it to
        // the contents of the file (which should be an RSA public
        // key in PEM format)
        if (file_exists($public_key)) {
            $this->public_key_text = file_get_contents($public_key);
        } elseif (! empty($public_key)) {
            $this->public_key_text = $public_key;
        }

        return $this;
    }
256883
protected function getPublicKey() {
        if (!$this->_publicKey) {
            $this->_publicKey = new PublicKeyList($this->version);
        }

        return $this->_publicKey;
    }
75039
public function getToken($id)
    {
        $result = $this->request('GET', '/tokens/' . $id);

        return $this->objectConverter->convert($result);
    }
595557
protected function getTokenForRequest()
	{
		$token = $this->request->input( $this->inputKey );

		if ( empty( $token ) )
			$token = $this->request->bearerToken();

		if ( empty( $token ) )
			$token = $this->request->getPassword();

		return $token;
	}
1178971
public static function retrieve($publickey = null, $secretkey = null)
    {
        return parent::g_retrieve(get_class(), self::getUrl(), $publickey, $secretkey);
    }
749945
public function editPublicKey($publicKey, $privateKey) {
        $this->validatePublicKeyName($publicKey);

        return $this->getCommand('EditPublicKey', array(
            'properties' => json_encode(array('privateKey' => $privateKey)),
            'publicKey' => $publicKey,
        ))->execute();
    }
1180164
public function get($key, &$token = null)
    {
        $value = $this->transaction->get($key, $token);

        // only store if we managed to retrieve a value (valid token) and it's
        // not already in cache (or we may mess up tokens)
        if ($value !== false && $this->local->get($key, $localToken) === false && $localToken === null) {
            $this->local->set($key, $value);
        }

        return $value;
    }
658384
public function verifySignature($publicKey) 
    {
        $signature = $this->getSignature();
        $data = $this->getDataForSigning();
        
        if (!isset($signature)) {
            throw new \Exception("Missing signature");
        } elseif (1 != $result = openssl_verify($data, base64_decode ($signature), $publicKey)) {
            throw new \Exception("OpenSSL verification failed.");
        }
    }
1004105
public function getAuthToken($tenantKey = null) 
	{
		$tenantKey = $tenantKey == null ? $this->tenantKey : $tenantKey;
		if ($this->tenantTokens[$tenantKey] == null) {
			$this->tenantTokens[$tenantKey] = array();
		}		
		return isset($this->tenantTokens[$tenantKey]['authToken']) 
			? $this->tenantTokens[$tenantKey]['authToken']
			: null;
	}
777762
public function getPublicKey() {

    if (empty($this->wardenPublicKey)) {
      $result = $this->request('/public-key');
      $this->wardenPublicKey = base64_decode($result->getBody());
    }

    return $this->wardenPublicKey;
  }
109488
public function get($key)
    {
        if (empty($this->predis)) return false;

        $key = $this->processKey($key);

        $data = $this->predis->get($key);

        return unserialize($data);
    }
418860
private function acquireToken($code)
    {
        // Request the token
        $client = new Client(); //GuzzleHttp\Client

        try {
            $response = $client->post($this->token_endpoint, [
                'form_params' => $this->getAccessTokenFields($code),
                'curl' => $this->setOauthCurlopts(),
                'synchronous' => true,
            ]);

            // Get the token and type from the response
            return json_decode($response->getBody(), true);

        } catch (\GuzzleException $e) {

            return false;
        }
    }