public function toFlattenedJSON($id)
{
$recipient = $this->getRecipient($id);
$json = $this->getJSONBase();
if (!empty($recipient->getHeaders())) {
$json['header'] = $recipient->getHeaders();
}
if (!empty($recipient->getEncryptedKey())) {
$json['encrypted_key'] = Base64Url::encode($recipient->getEncryptedKey());
}
return json_encode($json);
}