Exemplo n.º 1
0
 /**
  * @param \Jose\Object\JWSInterface       $jws
  * @param \Jose\Object\SignatureInterface $signature
  *
  * @return string
  */
 private function getInputToSign(Object\JWSInterface $jws, Object\SignatureInterface $signature)
 {
     $this->checkB64HeaderAndCrit($signature);
     $encoded_protected_headers = $signature->getEncodedProtectedHeaders();
     $payload = $jws->getPayload();
     if (!$signature->hasProtectedHeader('b64') || true === $signature->getProtectedHeader('b64')) {
         $encoded_payload = Base64Url::encode(is_string($payload) ? $payload : json_encode($payload));
         return sprintf('%s.%s', $encoded_protected_headers, $encoded_payload);
     }
     return sprintf('%s.%s', $encoded_protected_headers, $payload);
 }
Exemplo n.º 2
0
 /**
  * @param \Jose\Object\JWSInterface $jws
  * @param null|string               $detached_payload
  */
 private function checkPayload(Object\JWSInterface $jws, $detached_payload = null)
 {
     Assertion::false(null !== $detached_payload && !empty($jws->getPayload()), 'A detached payload is set, but the JWS already has a payload.');
     Assertion::true(!empty($jws->getPayload()) || null !== $detached_payload, 'No payload.');
 }