Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
34 righe
1.1 KiB
34 righe
1.1 KiB
<?php |
|
|
|
namespace ProcurePlus { |
|
|
|
use gara; |
|
|
|
class Out |
|
{ |
|
/** |
|
* Metodo di test che invia una richiesta firmata a ProcurePlus |
|
* e si aspetta di ricevere in risposta un JWT firmato. |
|
* Questo verifica connettività e correttezza delle chiavi di cifratura |
|
* @param array $data Contenuto del claim in risposta |
|
* @return bool |
|
*/ |
|
public static function ping(array $data) : bool { |
|
$body = HTTP::signedRequest("ping", $data); |
|
|
|
$jws = \JOSE_JWS::decode($body); |
|
$verifyKey = KeyStore::get("sign", getCurrentDomain(), "public"); |
|
$jws->verify($verifyKey, "RS512"); |
|
|
|
foreach($jws->claims as $key => $val) { |
|
if($val !== $data[$key]) { |
|
throw new \Exception("Data mismatch! $key: sent '{$data[$key]}', got '$val'"); |
|
} |
|
} |
|
return true; |
|
} |
|
public static function sendGara(gara $gara) { |
|
return HTTP::signedRequest("sendGara", $gara->serialize()); |
|
} |
|
} |
|
}
|
|
|