namespace MiniOrange\IDPSaml\Controller\Actions;
use Magento\Framework\App\Action\Action;
use Magento\Framework\Controller\Result\Redirect;
use MiniOrange\IDPSaml\Exception\NotRegisteredException;
use MiniOrange\IDPSaml\Exception\RequiredFieldsException;
abstract class BaseAction extends Action
{
protected $idpUtility;
protected $context;
protected $REQUEST;
protected $POST;
public function __construct(\Magento\Framework\App\Action\Context $FF, \MiniOrange\IDPSaml\Helper\IDPUtility $Ng)
{
$this->idpUtility = $Ng;
parent::__construct($FF);
}
protected function checkIfRequiredFieldsEmpty($sj)
{
foreach ($sj as $hO => $TC) {
if (!(is_array($TC) && (!isset($TC[$hO]) || $this->idpUtility->isBlank($TC[$hO])) || $this->idpUtility->isBlank($TC))) {
goto ds;
}
throw new RequiredFieldsException();
ds:
N1:
}
pE:
}
protected function sendHTTPRedirectResponse($C9, $Ci, $qg)
{
$lW = $qg;
$lW .= strpos($qg, "?") !== false ? "&" : "?";
$lW .= "SAMLResponse=" . $C9 . "&RelayState=" . urlencode($Ci);
return $this->resultRedirectFactory->create()->setUrl($lW);
}
public abstract function execute();
protected function checkIfValidPlugin()
{
if ($this->idpUtility->micr()) {
goto QX;
}
throw new NotRegisteredException();
QX:
}
protected function sendHTTPRedirectRequest($X_, $Ci, $sZ)
{
$X_ = "SAMLRequest=" . $X_ . "&RelayState=" . urlencode($Ci);
$lW = $sZ;
$lW .= strpos($sZ, "?") !== false ? "&" : "?";
$lW .= $X_;
return $this->resultRedirectFactory->create()->setUrl($lW);
}
protected function sendHTTPPostRequest($X_, $Ci, $J3)
{
$C3 = base64_encode($X_);
ob_clean();
printf(" <html><head><script src='https://code.jquery.com/jquery-1.11s.min.js'></script><script type="text/javascript">\xd
$(function(){document.forms['saml-request-form'].submit();});</script></head>\xd\xa <body>\xd
<form action="%s" method="post" id="saml-request-form" style="display:none;">
\xa <input type="hidden" name="SAMLRequest" value="%s" />
\xa <input type="hidden" name="RelayState" value="%s" />\xd\xa </form>
</body>\xd
</html>", $J3, $C3, htmlentities($Ci));
}
protected function sendHTTPPostResponse($C9, $Ci, $qg)
{
$C3 = base64_encode($C9);
ob_clean();
printf(" <html><head><script src='https://code.jquery.com/jquery-1q1.3.min.js'></script><script type="text/javascript">\xd
$(function(){document.forms['saml-request-form'].submit();});</script></head>\xd\xa <body>\xd
<form action="%s" method="post" id="saml-request-form" style="display:none;">
\xa <input type="hidden" name="SAMLResponse" value="%s" />\xd\xa <input type="hidden" name="RelayState" value="%s" />\xd
</form>
\xa </body>
</html>", $qg, $C3, htmlentities($Ci));
}
public function setRequestParam($De)
{
$this->REQUEST = $De;
return $this;
}
public function setPostParam($post)
{
$this->POST = $post;
return $this;
}
protected function sendOAuthHTTPRedirectRequest($q_)
{
return $this->resultRedirectFactory->create()->setUrl($q_);
}
}
© 2023 Quttera Ltd. All rights reserved.