Get original message body, to be encrypted/signed

@return string Message body
433444
public function getOrigBody()
    {
        $_headers = $this->message->headers();
        $headers  = array();

        if ($_headers['Content-Transfer-Encoding']
            && stripos($_headers['Content-Type'], 'multipart') === false
        ) {
            $headers[] = 'Content-Transfer-Encoding: ' . $_headers['Content-Transfer-Encoding'];
        }
        $headers[] = 'Content-Type: ' . $_headers['Content-Type'];

        return implode("\r\n", $headers) . "\r\n\r\n" . $this->body;
    }
1165113
public function getBody() {
		if ($this->body && isset($this->headers[self::HEADER_KEY_CONTENT_TYPE]) && $this->headers[self::HEADER_KEY_CONTENT_TYPE] == 'application/x-www-form-urlencoded') {
			return http_build_query($this->body);
		} elseif ((is_object($this->body) || is_array($this->body)) &&
			(!isset($this->headers[self::HEADER_KEY_CONTENT_TYPE]) || $this->headers[self::HEADER_KEY_CONTENT_TYPE] != 'multipart/form-data')) {
			return json_encode($this->serializer->sanitizeForSerialization($this->body));
		} else {
	      return $this->body;
	    }
	}
1009801
protected function decodeBody()
    {
        if(is_object($this->message)){
            foreach ($this->message->types as $typeMessage) {
                if(is_object($this->message->$typeMessage)){
                    switch ($this->message->$typeMessage->structure->encoding) {
                        case 3:
                            $this->message->$typeMessage->body = imap_base64($this->message->$typeMessage->body);
                            break;
                        case 4:
                            $this->message->$typeMessage->body = imap_qprint($this->message->$typeMessage->body);
                            break;
                    }
                }

                if(is_object($this->message->$typeMessage)){
                    if ($this->message->$typeMessage->charset) {
                        $this->message->$typeMessage->body = $this->convertToUtf8($this->message->$typeMessage->body, $this->message->$typeMessage->charset);
                    }
                }
            }
        }
    }
879757
public function getBody()
    {
        $body = '';
        if ($this->_method === 'POST' || $this->_method === 'PUT') {
            if ($this->_body === null) {
                $this->_body = $this->getPostBody();
            }
            $this->setHeader('content-length', strlen($this->_body));
            $body = $this->_body . Client::CRLF;
        }
        return $body;
    }
1204824
public function getMessageString()
    {
        $str = $this->pri;
        $str .= implode(' ', $this->header);

        if ($this->message['APP-NAME']) {
            $str .= ' ' . $this->message['APP-NAME'] . ': ' . $this->message['MSG'];
        } else {
            $str .= ' ' . $this->message['MSG'];
        }
        return $str;
    }
1173813
public function getEncodedMessage(): string
    {
        $output = '';
        $boundary = '--------' . Generators::random();

        foreach ($this->headers as $name => $value) {
            $output .= $name . ': ' . $this->getEncodedHeader($name);
            if ($this->parts && $name === 'Content-Type') {
                $output .= ';' . self::EOL . "\tboundary=\"$boundary\"";
            }
            $output .= self::EOL;
        }
        $output .= self::EOL;

        $body = $this->body;
        if ($body !== '') {
            switch ($this->getEncoding()) {
                case self::ENCODING_QUOTED_PRINTABLE:
                    $output .= \quoted_printable_encode($body);
                    break;

                case self::ENCODING_BASE64:
                    $output .= \rtrim(\chunk_split(\base64_encode($body), self::LINE_LENGTH, self::EOL));
                    break;

                case self::ENCODING_7BIT:
                    $body = \preg_replace('#[\x80-\xFF]+#', '', $body);
                // break intentionally omitted

                case self::ENCODING_8BIT:
                    $output .= \str_replace(["\x00", "\r", "\n"], ['', '', self::EOL], $body);
                    break;

                default:
                    throw new RuntimeException('Unknown encoding.');
            }
        }

        if ($this->parts) {
            if (\substr($output, -\strlen(self::EOL)) !== self::EOL) {
                $output .= self::EOL;
            }
            foreach ($this->parts as $part) {
                $output .= '--' . $boundary . self::EOL . $part->getEncodedMessage() . self::EOL;
            }
            $output .= '--' . $boundary . '--';
        }

        return $output;
    }
647432
private function extractAuthKeyFromPemContent()
    {
        $details = openssl_pkey_get_details(openssl_pkey_get_private($this->pem));
        if (!array_key_exists('key', $details)) {
            return null;
        }

        // Remove BEGIN RSA PRIVATE KEY / END RSA PRIVATE KEY lines
        $KeyStr = trim($details['key']);
        // Support line break on *nix systems, OS, older OS, and Microsoft
        $keyArr = preg_split('/\r\n|\r|\n/', $KeyStr);
        if (strpos($KeyStr, 'BEGIN') !== false) {
            array_shift($keyArr);
            array_pop($keyArr);
        }
        $authKey = implode('', $keyArr);

        // Check auth key is not empty
        if (empty($authKey)) {
            throw new RequestException('Could not retrieve Auth key from PEM content.', 401);
        }

        return $authKey;
    }
683876
protected function getPlainBody()
    {
        $charset    = $this->isUtf8($this->body['text/plain']) ? 'utf-8' : 'US-ASCII';
        $plane      = str_replace("\r", '', trim($this->body['text/plain']));
        $count      = ceil(strlen($plane) / 998);

        $body = array();
        $body[] = 'Content-Type: text/plain; charset='.$charset;
        $body[] = 'Content-Transfer-Encoding: 7bit';
        $body[] = null;

        for ($i = 0; $i < $count; $i++) {
            $body[] = substr($plane, ($i * 998), 998);
        }

        $body[] = null;
        $body[] = null;

        return $body;
    }
638803
public function getBody()
	{
		$number		= count( $this->parts );
		if( !$number )
			return '';

		$innerBoundary	= $this->mimeBoundary.'-1';

		$contents	= array( 'This is a multi-part message in MIME format.');
		$contents[]	= '--'.$this->mimeBoundary;
		$contents[]	= 'Content-Type: multipart/alternative;';
		$contents[]	= ' boundary="'.$innerBoundary.'"'.Net_Mail::$delimiter;
		foreach( $this->parts as $part )
			if( $part instanceof Net_Mail_Body )
				$contents[]	= '--'.$innerBoundary.Net_Mail::$delimiter.$part->render();
		$contents[]	= '--'.$innerBoundary.'--'.Net_Mail::$delimiter;

		foreach( $this->parts as $part )
			if( $part instanceof Net_Mail_Attachment )
				$contents[]	= '--'.$this->mimeBoundary.Net_Mail::$delimiter.$part->render();
		$contents[]	= '--'.$this->mimeBoundary.'--'.Net_Mail::$delimiter;
		return join( Net_Mail::$delimiter, $contents );
	}
802193
public function getSignatureBase() {
		$fields = array();

		if ($this->eetStatus !== null) {
			$fields[] = $this->eetStatus;
		}
		if ($this->data) {
			$fields[] = $this->data->getSignatureBase();
		}
		if ($this->verificationMode !== null) {
			$fields[] = $this->verificationMode ? 'true' : 'false';
		}
		if ($this->vatId) {
			$fields[] = $this->vatId;
		}
		if ($this->receiptNumber) {
			$fields[] = $this->receiptNumber;
		}
		if ($this->receiptTime) {
			if (isset($this->rawData['receiptTime']) and $this->rawData['receiptTime']) {
				$fields[] = $this->rawData['receiptTime'];
			} else {
				$fields[] = self::formatTime($this->receiptTime);
			}
		}
		if ($this->evidenceMode !== null) {
			$fields[] = $this->evidenceMode;
		}
		if ($this->uuid !== null) {
			$fields[] = $this->uuid;
		}
		if ($this->sendTime) {
			if (isset($this->rawData['sendTime']) and $this->rawData['sendTime']) {
				$fields[] = $this->rawData['sendTime'];
			} else {
				$fields[] = self::formatTime($this->sendTime);
			}
		}
		if ($this->acceptTime) {
			if (isset($this->rawData['acceptTime']) and $this->rawData['acceptTime']) {
				$fields[] = $this->rawData['acceptTime'];
			} else {
				$fields[] = self::formatTime($this->acceptTime);
			}
		}
		if ($this->bkp) {
			$fields[] = $this->bkp;
		}
		if ($this->pkp) {
			$fields[] = $this->pkp;
		}
		if ($this->fik) {
			$fields[] = $this->fik;
		}
		if ($this->rejectTime) {
			if (isset($this->rawData['rejectTime']) and $this->rawData['rejectTime']) {
				$fields[] = $this->rawData['rejectTime'];
			} else {
				$fields[] = self::formatTime($this->rejectTime);
			}
		}
		if ($this->error) {
			$fields[] = $this->error->getSignatureBase();
		}
		if ($this->warning) {
			foreach ($this->warning as $w) {
				$fields[] = $w->getSignatureBase();
			}
		}

		return implode('|', $fields);
	}
519683
public function getPostBody()
    {
        $body = [
            'message' => $this->getContent(),
        ];

        if ($this->link != null) {
            $body['link'] = $this->link->getUrl();
        }

        if ($this->image != null) {
            $body['media'] = $this->image;
        }

        if ($this->video != null) {
            $body['media'] = $this->video;
        }

        if ($this->params != null) {
            $body = array_merge($body, $this->params);
        }

        return $body;
    }
486260
public function getBody() {
        if (!isset($this->body)) {
            $contentType = $this->getHeader('Content-Type');

            if (stripos($contentType, 'application/json') !== false) {
                $this->body = json_decode($this->rawBody, true);
            } else {
                $this->body = $this->rawBody;
            }
        }
        return $this->body;
    }
889488
public function getMsgBody()
    {
        $body = null;

        if (!empty($this->_parts)) {
            if (count($this->_parts) > 1) {
                foreach ($this->_parts as $part) {
                    if ($part->contentType != Content::CT_TEXT_PLAIN && $this->getHeaders()->getMessageContentType() == Content::CT_MULTIPART_ALTERNATIVE) {
                        $body = $part->getContentDecode();
                        break;
                    }

                    $body .= PHP_EOL.$part->getContentDecode();
                }
            } else {
                $body = $this->_parts[0]->getContentDecode();
            }
        }

        return $body;
    }
58115
public function body() {
		return sprintf(
			'Invalid version detected for %s. Found %s but expected %s.',
			$this->requirement->component(),
			$this->detected,
			$this->requirement->version()
		);
	}
32670
public function getPayload()
    {
        $payload = $this->payload;

        // The "message" property is deprecated and replaced by "error_description"
        // TODO: remove "message" property
        if (isset($payload['error_description']) && !isset($payload['message'])) {
            $payload['message'] = $payload['error_description'];
        }

        return $payload;
    }
104404
public function getBinaryMessage()
    {
        $encodedPayload = $this->jsonEncode($this->payload->getPayload());

        return chr(0).
               chr(0).
               chr(32).
               pack('H*', $this->deviceToken).
               chr(0).chr(strlen($encodedPayload)).
               $encodedPayload;
    }
991453
public function returnBody()
    {
        $body = $this->getBody();
        $text = '';

        if ($body->hasChildNodes()) {
            foreach ($body->childNodes as $child) {
                $text .= $this->dom->saveXML($child);
            }
        }

        return Horde_String::convertCharset($text, 'UTF-8', $this->_origCharset);
    }