function simpleReceiveEnvelopeAndGiveReceipt($envelope, $password) { $message = getMessageFromEnvelope($envelope); $messageName = getMessageNameFromMessage($message); $authorName = getAuthorNameFromMessage($message); $messageHeader = array(); $messageHeader['messageName'] = $messageName; $messageHeader['authorName'] = $authorName; $messageBody = getMessageBodyFromMessage($message); $signature = getSignatureFromMessage($message); $signatureCheckStatus = checkMessageSignature($password, $messageBody['body'], $signature); if (!$signatureCheckStatus) { $exchangeStatus = 'EXCHANGE_FAILED'; $exchangeReceipt = createExchangeReceipt($signatureCheckStatus, $exchangeStatus, null, null); $messageBody['body'] = writeExchangeReceipt($exchangeReceipt); $message = createMessage($messageHeader, $messageBody); return putMessageIntoEnvelope($message, $messageHeader); } $exchangeReceipt = receiveMessageAndGiveReceipt($messageHeader, $messageBody); $messageBody['body'] = writeExchangeReceipt($exchangeReceipt); $message = createMessage($messageHeader, $messageBody); return putMessageIntoEnvelope($message, $messageHeader); }
<?php require_once '../interfaces/PostOffice.php'; require_once 'testData.php'; echo getSignatureFromMessage($message);