PrivacyHelper
extends AbstractHelper
in package
Provides routines to set or retrieve the signature part of a signed message.
Tags
Table of Contents
- $mimePartFactory : IMimePartFactory
- $uuEncodedPartFactory : IUUEncodedPartFactory
- $genericHelper : GenericHelper
- $multipartHelper : MultipartHelper
- __construct() : mixed
- ensureHtmlPartFirstForSignedMessage() : mixed
- Ensures a non-text part comes first in a signed multipart/alternative message as some clients seem to prefer the first content part if the client doesn't understand multipart/signed.
- getSignedMessageAsString() : string
- Returns a string containing the entire body (content) of a signed message for verification or calculating a signature.
- getSignedMessageStream() : StreamInterface
- Returns a stream that can be used to read the content part of a signed message, which can be used to sign an email or verify a signature.
- overwrite8bitContentEncoding() : mixed
- Loops over parts of the message and sets the content-transfer-encoding header to quoted-printable for text/* mime parts, and to base64 otherwise for parts that are '8bit' encoded.
- setMessageAsMultipartSigned() : mixed
- The passed message is set as multipart/signed, and a new part is created below it with content headers, content and children copied from the message.
- setSignature() : mixed
- Sets the signature of the message to $body, creating a signature part if one doesn't exist.
Properties
$mimePartFactory
protected
IMimePartFactory
$mimePartFactory
to create parts for attachments/content
$uuEncodedPartFactory
protected
IUUEncodedPartFactory
$uuEncodedPartFactory
to create parts for attachments
$genericHelper
private
GenericHelper
$genericHelper
a GenericHelper instance
$multipartHelper
private
MultipartHelper
$multipartHelper
a MultipartHelper instance
Methods
__construct()
public
__construct(IMimePartFactory $mimePartFactory, IUUEncodedPartFactory $uuEncodedPartFactory, GenericHelper $genericHelper, MultipartHelper $multipartHelper) : mixed
Parameters
- $mimePartFactory : IMimePartFactory
- $uuEncodedPartFactory : IUUEncodedPartFactory
- $genericHelper : GenericHelper
- $multipartHelper : MultipartHelper
Return values
mixed —ensureHtmlPartFirstForSignedMessage()
Ensures a non-text part comes first in a signed multipart/alternative message as some clients seem to prefer the first content part if the client doesn't understand multipart/signed.
public
ensureHtmlPartFirstForSignedMessage(IMessage $message) : mixed
Parameters
- $message : IMessage
Return values
mixed —getSignedMessageAsString()
Returns a string containing the entire body (content) of a signed message for verification or calculating a signature.
public
getSignedMessageAsString(IMessage $message) : string
Non-CRLF new lines are replaced to always be CRLF.
Parameters
- $message : IMessage
Return values
string —or null if the message doesn't have any children
getSignedMessageStream()
Returns a stream that can be used to read the content part of a signed message, which can be used to sign an email or verify a signature.
public
getSignedMessageStream(IMessage $message) : StreamInterface
The method simply returns the stream for the first child. No verification of whether the message is in fact a signed message is performed.
Note that unlike getSignedMessageAsString, getSignedMessageStream doesn't replace new lines.
Parameters
- $message : IMessage
Return values
StreamInterface —or null if the message doesn't have any children
overwrite8bitContentEncoding()
Loops over parts of the message and sets the content-transfer-encoding header to quoted-printable for text/* mime parts, and to base64 otherwise for parts that are '8bit' encoded.
public
overwrite8bitContentEncoding(IMessage $message) : mixed
Used for multipart/signed messages which doesn't support 8bit transfer encodings.
Parameters
- $message : IMessage
Return values
mixed —setMessageAsMultipartSigned()
The passed message is set as multipart/signed, and a new part is created below it with content headers, content and children copied from the message.
public
setMessageAsMultipartSigned(IMessage $message, string $micalg, string $protocol) : mixed
Parameters
- $message : IMessage
- $micalg : string
- $protocol : string
Return values
mixed —setSignature()
Sets the signature of the message to $body, creating a signature part if one doesn't exist.
public
setSignature(IMessage $message, string $body) : mixed
Parameters
- $message : IMessage
- $body : string