namespace MiniOrange\IDPSaml\Controller\Actions;
use MiniOrange\IDPSaml\Helper\IDPConstants;
class ShowTestResultsAction extends BaseAction
{
private $attrs;
private $emailAttribute;
private $samlException;
private $hasExceptionOccurred;
private $nameId;
private $template = "<div style="font-family:Calibri;padding:0 3%%;">{{header}}{{commonbody}}{{footer}}</div>";
private $successHeader = " <div style="color: c3d;background-color: #dff0d8; padding:2%%;margin-bottom0px;text-align:center;
\xa border:1px solid #AEDB9A; font-size8pt;">TEST SUCCESSFUL\xd\xa </div>\xd
<div style="display:block;text-align:center;margin-bottom:4%%;"><img style="width5%%;" src="{{right}}"></div>";
private $errorHeader = " <div style="color: #a942;background-color: #f2dede;padding: 15px;margin-bottom: 20px;text-align:center;\xd\xa borderpx solid #E6B3B2;font-size:18pt;">TEST FAILED\xd\xa </div><div style="display:block;text-align:center;margin-bottom:4%%;"><img style="width:15%%;"src="{{wrong}}"></div>";
private $commonBody = "<span style="font-size:14pt;"><b>Hello</b>, {{email}}</span><br/>\xd
<p style="font-weight:bold;font-size:14pt;margin-left%%;">ATTRIBUTES RECEIVED:</p>\xd
<table style="border-collapse:collapse;border-spacing; display:table;width:0%%;
\xa font-size:14pt;background-color:#EDEDED;">\xd
<tr style="text-align:center;">\xd\xa <td style="font-weight:bold;border:2px solid #949090;padding%%;">ATTRIBUTE NAME</td>
<td style="font-weight:bold;padding%%;border:2px solid #949090; word-wrap:break-word;">ATTRIBUTE VALUE</td>\xd\xa </tr>{{tablecontent}}\xd\xa </table>";
private $exceptionBody = "<div style="margin: 10px 0;padding:2px;color: #D00C;background-color: #FFBABA;font-size: px;
line-height: 1.618;">{{exceptionmessage}}</div>{{certErrorDiv}}{{samlResponseDiv}}";
private $certError = "<p style="font-weight:bold;font-size4pt;margin-left:1%%;">CERT CONFIGURED IN PLUGIN:</p><div style="color: #3B41;\xd\xa font-family: Menlo,Monaco,Consolas,monospace;direction: ltr;text-align: left;white-space: pre;\xd
word-spacing: normal;word-break: normal;font-size: 13px;font-style: normal;font-weight: 400;\xd
height: auto;line-height: 19.5px;border:px solid #ddd;background: #fafafa;padding: 1em;\xd\xa margin: .5em ;border-radius: 4px;">{{certinplugin}}</div>\xd\xa <p style="font-weight:bold;font-size:14pt;margin-left%%;">CERT FOUND IN RESPONSE:</p><div style="color: B;
font-family: Menlo,Monaco,Consolas,monospace;direction: ltr;text-align: left;white-space: pre;\xd
word-spacing: normal;word-break: normal;font-size: 13px;font-style: normal;font-weight: 400;\xd
height: auto;line-height: 19upx;border: 1px solid #ddd;background: #fafafa;padding:em;
\xa margin: .5em 0;border-radius: 4px;">{{certfromresponse}}</div>";
private $samlResponse = "<p style="font-weight:bold;font-size:pt;margin-left%%;">SAML RESPONSE FROM IDP:</p><div style="color: 73B41;
\xa font-family: Menlo,Monaco,Consolas,monospace;direction: ltr;text-align: left;white-space: pre;
word-spacing: normal;word-break: normal;font-size: 13px;font-style: normal;font-weight: 4;\xd\xa height: auto;line-height: 19.5px;border: 1px solid #ddd;background: #fafafa;padding: 1em;
margin: .5em 0;border-radius: 4px;overflow:scroll">{{samlresponse}}</div>";
private $footer = " <div style="margin:3%%;display:block;text-align:center;">\xd\xa <input style="padding:1%%;width:1px;background: #91CD none repeat scroll 0%% 0%%;cursor: pointer;\xd
font-size5px;border-width: 1px;border-style: solid;border-radius: 3px;white-space: nowrap;\xd
box-sizing: border-box;border-color: #0073AA;box-shadow: 0px 1px px rgba(1, 200, 0, 0v) inset;\xd
color: #FFF;"type="button" value="Done" onClick="self.close();"></div>";
private $tableContent = "<tr><td style='font-weight:bold;border:2px solid #949090;padding:2%%;'>{{key}}</td><td style='padding:2%%;
\xa border:2px solid #9490; word-wrap:break-word;'>{{value}}</td></tr>";
public function execute()
{
ob_clean();
$this->processTemplateHeader();
if (!$this->hasExceptionOccurred) {
goto D7;
}
$this->processExceptionTemplate();
goto c6;
D7:
$this->processTemplateContent();
c6:
$this->processTemplateFooter();
printf($this->template);
return;
}
private function processTemplateHeader()
{
$pY = $this->idpUtility->isBlank($this->nameId) ? $this->errorHeader : $this->successHeader;
$pY = str_replace("{{right}}", $this->idpUtility->getImageUrl(IDPConstants::IMAGE_RIGHT), $pY);
$pY = str_replace("{{wrong}}", $this->idpUtility->getImageUrl(IDPConstants::IMAGE_WRONG), $pY);
$this->template = str_replace("{{header}}", $pY, $this->template);
}
private function processExceptionTemplate()
{
$this->exceptionBody = str_replace("{{exceptionmessage}}", $this->samlException->getMessage(), $this->exceptionBody);
$this->exceptionBody = str_replace("{{certErrorDiv}}", $this->processCertErrors(), $this->exceptionBody);
$WG = $this->samlResponse instanceof SAMLResponseException ? $this->samlException->getSamlResponse() : '';
$this->samlResponse = str_replace("{{samlresponse}}", $WG, $this->samlResponse);
$this->exceptionBody = str_replace("{{samlResponseDiv}}", $this->samlResponse, $this->exceptionBody);
$this->template = str_replace("{{commonbody}}", $this->exceptionBody, $this->template);
}
private function processCertErrors()
{
if (!($this->samlResponse instanceof SAMLResponseException && $this->samlException->isCertError())) {
goto Jw;
}
$fe = $this->idpUtility->sanitizeCert($this->samlException->getPluginCert());
$yM = $this->idpUtility->sanitizeCert($this->samlException->getCertInResponse());
$this->certError = str_replace("{{certinplugin}}", $fe, $this->certError);
$this->certError = str_replace("{{certfromresponse}}", $yM, $this->certError);
return $this->certError;
Jw:
return '';
}
private function processTemplateContent()
{
$this->commonBody = str_replace("{{email}}", $this->nameId, $this->commonBody);
$M2 = !array_filter($this->attrs) ? "No Attributes Received." : $this->getTableContent();
$this->commonBody = str_replace("{{tablecontent}}", $M2, $this->commonBody);
$this->template = str_replace("{{commonbody}}", $this->commonBody, $this->template);
}
private function getTableContent()
{
$M2 = '';
foreach ($this->attrs as $hO => $TC) {
if (in_array(null, $TC)) {
goto HR;
}
$M2 .= str_replace("{{key}}", $hO, str_replace("{{value}}", implode("<br/>", $TC), $this->tableContent));
HR:
DC:
}
aw:
return $M2;
}
private function processTemplateFooter()
{
$this->template = str_replace("{{footer}}", $this->footer, $this->template);
}
public function setAttrs($x1)
{
$this->attrs = $x1;
return $this;
}
public function setSamlException($vX)
{
$this->samlException = $vX;
return $this;
}
public function setHasExceptionOccurred($Ig)
{
$this->hasExceptionOccurred = $Ig;
return $this;
}
public function setNameId($Ne)
{
$this->nameId = $Ne;
return $this;
}
}
© 2023 Quttera Ltd. All rights reserved.