namespace MiniOrange\IDPSaml\Helper;
use MiniOrange\IDPSaml\Helper\IDPConstants;
use MiniOrange\IDPSaml\Helper\Curl;
use MiniOrange\IDPSaml\Helper\Data;
use MiniOrange\IDPSaml\Helper\Saml2\Lib\AESEncryption;
use MiniOrange\IDPSaml\Helper\Saml2\SAML2Utilities;
use Psr\Log\LoggerInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\ResourceConnection;
use MiniOrange\IDPSaml\Model\OAuthServerUsersFactory;
use MiniOrange\IDPSaml\Model\MiniOrangeSpTableFactory;
use Magento\Framework\Stdlib\DateTime\DateTime;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\UrlInterface;
use DOMElement;
use DOMDocument;
use DOMNode;
use DOMXPath;
class IDPUtility extends Data
{
protected $adminSession;
protected $customerSession;
protected $authSession;
protected $cacheTypeList;
protected $cacheFrontendPool;
protected $fileSystem;
protected $reinitableConfig;
protected $userGroupModel;
protected $adminRoleModel;
protected $adminUserModel;
protected $customerModel;
protected $resource;
protected $logger;
protected $oauthServerUsers;
protected $miniOrangeOAuthClientsFactory;
protected $productMetadata;
protected $dateTime;
public $customerRepository;
protected $response;
protected $urlBuilder;
protected $responseFactory;
protected $messageManager;
public function __construct(ManagerInterface $Hr, \Magento\Framework\App\Config\ScopeConfigInterface $uI, \Magento\User\Model\UserFactory $RK, \Magento\Customer\Model\CustomerFactory $o2, \Magento\Framework\UrlInterface $L8, \Magento\Framework\App\Config\Storage\WriterInterface $FL, \Magento\Framework\View\Asset\Repository $pC, \Magento\Backend\Helper\Data $Db, \Magento\Framework\Url $xA, \Magento\Backend\Model\Session $sf, \Magento\Customer\Model\Session $d9, \Magento\Backend\Model\Auth\Session $dl, \Magento\Framework\App\Cache\TypeListInterface $GL, \Magento\Framework\App\Cache\Frontend\Pool $II, \Magento\Framework\Filesystem\Driver\File $MF, \Magento\Framework\App\Config\ReinitableConfigInterface $WE, \Magento\Customer\Model\ResourceModel\Group\Collection $kg, \Magento\Authorization\Model\ResourceModel\Role\Collection $w5, \Magento\User\Model\User $g2, \Magento\Customer\Model\Customer $VZ, \Magento\Framework\App\ResourceConnection $Fe, \MiniOrange\IDPSaml\Logger\Logger $Vg, OAuthServerUsersFactory $lz, MiniOrangeSpTableFactory $eq, \Magento\Framework\App\ProductMetadataInterface $nA, DateTime $TT, CustomerRepositoryInterface $ql, LoggerInterface $ce, UrlInterface $S7, ResponseInterface $WG, \Magento\Framework\App\ResponseFactory $Pd)
{
$this->adminSession = $sf;
$this->customerSession = $d9;
$this->authSession = $dl;
$this->cacheTypeList = $GL;
$this->cacheFrontendPool = $II;
$this->fileSystem = $MF;
$this->reinitableConfig = $WE;
$this->logger = $ce;
$this->customerModel = $VZ;
$this->userGroupModel = $kg;
$this->resource = $Fe;
$this->adminRoleModel = $w5;
$this->adminUserModel = $g2;
$this->_logger = $Vg;
$this->oauthServerUsers = $lz;
$this->miniOrangeOAuthClientsFactory = $eq;
$this->productMetadata = $nA;
$this->dateTime = $TT;
$this->customerRepository = $ql;
$this->messageManager = $Hr;
$this->urlBuilder = $S7;
$this->response = $WG;
$this->responseFactory = $Pd;
parent::__construct($uI, $RK, $o2, $L8, $FL, $pC, $Db, $xA, $lz, $eq, $TT, $nA);
}
public function getHiddenPhone($MZ)
{
$b7 = "xxxxxxx" . substr($MZ, strlen($MZ) - 3);
return $b7;
}
public function isBlank($TC)
{
if (!(!isset($TC) || empty($TC))) {
goto Hs;
}
return true;
Hs:
return false;
}
public function isCurlInstalled()
{
if (in_array("curl", get_loaded_extensions())) {
goto lH;
}
return 0;
goto nC;
lH:
return 1;
nC:
}
public function validatePhoneNumber($MZ)
{
if (!preg_match(MoIDPConstants::PATTERN_PHONE, $MZ, $SB)) {
goto Z_;
}
return true;
goto rR;
Z_:
return false;
rR:
}
public function getHiddenEmail($Wc)
{
if (!(!isset($Wc) || trim($Wc) === '')) {
goto wC;
}
return '';
wC:
$a4 = strlen($Wc);
$fo = substr($Wc, 0, 1);
$Qx = strrpos($Wc, "@");
$lH = substr($Wc, $Qx - 1, $a4);
$gS = 1;
dF:
if (!($gS < $Qx)) {
goto V0;
}
$fo = $fo . "x";
cw:
$gS++;
goto dF;
V0:
$dn = $fo . $lH;
return $dn;
}
public function setAdminSessionData($hO, $TC)
{
return $this->adminSession->setData($hO, $TC);
}
public function getAdminSessionData($hO, $MI = false)
{
return $this->adminSession->getData($hO, $MI);
}
public function setSessionData($hO, $TC)
{
return $this->customerSession->setData($hO, $TC);
}
public function getSessionData($hO, $MI = false)
{
return $this->customerSession->getData($hO, $MI);
}
public function unsetSessionData($hO, $MI = false)
{
return $this->customerSession->unsetData($hO, $MI);
}
public function setSessionDataForCurrentUser($hO, $TC)
{
if ($this->customerSession->isLoggedIn()) {
goto Ei;
}
if ($this->authSession->isLoggedIn()) {
goto zj;
}
goto La;
Ei:
$this->setSessionData($hO, $TC);
goto La;
zj:
$this->setAdminSessionData($hO, $TC);
La:
}
public function isSPConfigured()
{
$PL = $this->getStoreConfig(IDPConstants::SAML_SSO_URL);
return $this->isBlank($PL) ? false : true;
}
public function micr()
{
$Wc = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$hO = $this->getStoreConfig(IDPConstants::SAML_IDP_KEY);
return !$this->isBlank($Wc) && !$this->isBlank($hO) ? true : false;
}
public function isUserLoggedIn()
{
return $this->customerSession->isLoggedIn() || $this->authSession->isLoggedIn();
}
public function getCurrentAdminUser()
{
return $this->authSession->getUser();
}
public function getCurrentUser()
{
$TV = \Magento\Framework\App\ObjectManager::getInstance();
$d9 = $TV->get("Magento\Customer\Model\Session");
$Qq = $d9->getCustomer()->getEmail();
return $d9->getCustomer();
}
public function getAcsUrl()
{
return $this->getStoreConfig(IDPConstants::SAML_SSO_URL);
}
public function getAdminLoginUrl()
{
return $this->getAdminUrl("adminhtml/auth/login");
}
public function getCustomerLoginUrl()
{
return $this->getUrl("customer/account/login");
}
public function getCustomer($ST)
{
return $this->customerRepository->getById($ST);
}
public function desanitizeCert($r3)
{
return SAML2Utilities::desanitize_certificate($r3);
}
public function sanitizeCert($r3)
{
return SAML2Utilities::sanitize_certificate($r3);
}
public function flushCache()
{
$WX = ["db_ddl"];
foreach ($WX as $bc) {
$this->cacheTypeList->cleanType($bc);
vm:
}
ed:
foreach ($this->cacheFrontendPool as $DR) {
$DR->getBackend()->clean();
Kl:
}
mT:
}
public function getFileContents($LK)
{
return $this->fileSystem->fileGetContents($LK);
}
public function putFileContents($LK, $Ti)
{
$this->fileSystem->filePutContents($LK, $Ti);
}
public function getAdminSession()
{
return $this->adminSession;
}
public function reinitConfig()
{
$this->reinitableConfig->reinit();
}
public function parseBoolean(DOMElement $y8, $pW, $fv = null)
{
if ($y8->hasAttribute($pW)) {
goto O2;
}
return $fv;
O2:
$TC = $y8->getAttribute($pW);
switch (strtolower($TC)) {
case "0":
case "false":
return FALSE;
case "1":
case "true":
return TRUE;
default:
throw new \Exception("Invalid value of boolean attribute " . var_export($pW, TRUE) . ": " . var_export($TC, TRUE));
}
Km:
hl:
}
public function xpQuery(DOMNode $y8, $Y9)
{
static $dJ = NULL;
if ($y8 instanceof DOMDocument) {
goto eZ;
}
$ky = $y8->ownerDocument;
goto Su;
eZ:
$ky = $y8;
Su:
if (!($dJ === NULL || !$dJ->document->isSameNode($ky))) {
goto es;
}
$dJ = new DOMXPath($ky);
$dJ->registerNamespace("soap-env", "http://schemas.xmlsoap.org/soap/envelope/");
$dJ->registerNamespace("saml_protocol", "urn:oasis:names:tc:SAML:2.0:protocol");
$dJ->registerNamespace("saml_assertion", "urn:oasis:names:tc:SAML:2p:assertion");
$dJ->registerNamespace("saml_metadata", "urn:oasis:names:tc:SAML:2.0:metadata");
$dJ->registerNamespace("ds", "http://www.w3.orgz0/09/xmldsig#");
$dJ->registerNamespace("xenc", "http://www.w3.orgz1/04/xmlenc#");
es:
$c_ = $dJ->query($Y9, $y8);
$We = array();
$gS = 0;
Pf:
if (!($gS < $c_->length)) {
goto WP;
}
$We[$gS] = $c_->item($gS);
CZ:
$gS++;
goto Pf;
WP:
return $We;
}
private function getRoleIdByName($bA)
{
$cO = $this->adminRoleModel->toOptionArray();
foreach ($cO as $fV) {
if (!($bA == $fV["label"])) {
goto oF;
}
return $fV["value"];
oF:
Hv:
}
nS:
}
private function getGroupIdByName($Mx)
{
$bx = $this->userGroupModel->toOptionArray();
foreach ($bx as $cV) {
if (!($Mx == $cV["label"])) {
goto jc;
}
return $cV["value"];
jc:
A1:
}
R1:
}
public function log_debug($w3 = '', $W6 = null)
{
if (is_object($w3)) {
goto oz;
}
$this->customlog("MO IDP SAML PLugin : " . $w3);
goto Tr;
oz:
$this->customlog("MO IDP SAML PLugin : " . print_r($W6, true));
Tr:
if (!($W6 != null)) {
goto Ik;
}
$this->customlog("MO IDP SAML PLugin : " . var_export($W6, true));
Ik:
}
public function checkIfUserLeft($user)
{
if ($this->cleu()) {
goto lh;
}
$this->log_debug("in addUserInList");
$Y2 = "customer_entity";
$oh = "idp_user";
$hs = 1;
$sU = $user->getId();
$this->updateColumnInTable($Y2, $oh, $hs, IDPConstants::COLUMN_ENTITY, $sU, $user);
goto Qi;
lh:
$Ij = $this->customerSession->getId();
if (!$Ij) {
goto Zz;
}
$this->customerSession->logout();
Zz:
$this->messageManager->addErrorMessage("You have exceeded the User Limit Please contact your adminstrator.");
$nZ = $this->urlBuilder->getUrl("customer/account/login");
$this->responseFactory->create()->setRedirect($nZ)->sendResponse();
exit;
Qi:
}
public function cleu()
{
$this->flushCache();
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
$SS = $this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT);
if (!($SS == null)) {
goto Bl;
}
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
Bl:
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$qk = $DI - $gs;
$Bw = $DI / 10;
if ($qk <= $Bw && $qk > 10) {
goto ZB;
}
if ($qk <= 10 && $qk > 0) {
goto Is;
}
if ($qk < 0 && $qk > -(int) $Bw) {
goto MK;
}
if (!($qk <= -(int) $Bw)) {
goto p9;
}
$this->flushCache();
$J8 = $this->getStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT);
if (!($J8 == NULL || $J8 > -(int) $Bw)) {
goto CB;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$qk = $DI - $gs;
if (!($qk <= -(int) $Bw)) {
goto PD;
}
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, $qk);
$this->suea($DI);
PD:
CB:
return true;
p9:
goto Yc;
MK:
$this->flushCache();
$J8 = $this->getStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT);
if (!($J8 == 0 || $J8 == NULL || $J8 > 0)) {
goto Yo;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$qk = $DI - $gs;
if (!($qk < 0 && $qk > -(int) $Bw)) {
goto uf;
}
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, $qk);
$this->suea($DI);
uf:
Yo:
Yc:
goto Y6;
ZB:
$this->flushCache();
$J8 = $this->getStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT);
if (!($J8 == 0 || $J8 == NULL)) {
goto xZ;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$qk = $DI - $gs;
$Bw = $DI / 10;
if (!($qk <= $Bw && $qk > 10)) {
goto UA;
}
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, $qk);
$this->sue($DI, $qk);
UA:
xZ:
goto Y6;
Is:
$this->flushCache();
$J8 = $this->getStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT);
if (!($J8 == 0 || $J8 == NULL || $J8 > 10)) {
goto WZ;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$qk = $DI - $gs;
if (!($qk <= 10 && $qk > 0)) {
goto LN;
}
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, $qk);
$this->sue($DI, $qk);
LN:
WZ:
Y6:
return false;
}
public function suea($Wy)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>You have purchased license for miniOrange Magento IDP Plugin for <b>" . $Wy . " users</b>. \xd
\x9 \x9\x9\x9As number of users on your site have grown to more than " . $Wy . " users now, new users will not be able to use SSO capabilities for your site <br><br>
\xa\x9\x9 \x9\x9 Please reach out to us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> or use the Support Form in the plugin to upgrade the license to continue using our plugin.
\xa \x9 \x9\x9\x9<br><br>Thanks,<br>miniOrange";
$Y1 = "Exceeded License Limit For No Of Users - Magento IDP Plugin";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function sue($Wy, $qk)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>You have purchased license for miniOrange Magento IDP Plugin for <b>" . $Wy . " users</b>. \xd\xa \x9\x9 \x9 As number of users on your site have grown to more than " . ($Wy - $qk) . " users now .You have left with " . $qk . " user for SSO
\xa\x9 \x9\x9\x9Please reach out to us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> or use the Support Form if you wish to upgrade the license.
\x9\x9\x9 \x9 <br><br>Thanks,<br>miniOrange";
$Y1 = "Exceeded License Limit For No Of Users - Magento IDP Plugin";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function ccl()
{
$sK = $this->getStoreConfig(IDPConstants::SAML_IDP_KEY);
$Ua = $this->getStoreConfig(IDPConstants::API_KEY);
$Ib = Curl::ccl($sK, $Ua);
return $Ib;
}
public function checkIfValidLicense()
{
if (!($this->cled() <= -10)) {
goto nv;
}
$Ij = $this->customerSession->getId();
if (!$Ij) {
goto IX;
}
$this->customerSession->logout();
IX:
$this->messageManager->addErrorMessage("Your License is expired Please contact your adminstrator.");
$nZ = $this->urlBuilder->getUrl("customer/account/login");
$this->responseFactory->create()->setRedirect($nZ)->sendResponse();
exit;
nv:
}
public function cled()
{
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = null;
if ($aB == null) {
goto y3;
}
$NX = AESEncryption::decrypt_data($aB, $hO);
goto r0;
y3:
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
r0:
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= 30)) {
goto iH;
}
$this->flushCache();
$this->reinitConfig();
$vT = $this->getStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT);
if ($Di > 7) {
goto yy;
}
if ($Di <= 7 && $Di > 0) {
goto eX;
}
if ($Di < 0 && $Di > -10) {
goto OY;
}
if (!($Di <= -10)) {
goto q7;
}
if (!($vT == 0 || $vT == null || $vT > -10)) {
goto Z4;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = AESEncryption::decrypt_data($aB, $hO);
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= -10)) {
goto Li;
}
$this->spdae();
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, $Di);
Li:
Z4:
q7:
goto kv;
OY:
if (!($vT == 0 || $vT == null || $vT > 0)) {
goto N4;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = AESEncryption::decrypt_data($aB, $hO);
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di < 0 && $Di > -10)) {
goto WB;
}
$this->slrfae();
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, $Di);
WB:
N4:
kv:
goto gr;
eX:
if (!($vT == 0 || $vT == null || $vT > 7)) {
goto Nm;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = AESEncryption::decrypt_data($aB, $hO);
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= 7 && $Di > 0)) {
goto Zv;
}
$this->slrae($Di);
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, $Di);
Zv:
Nm:
gr:
goto vW;
yy:
if (!($vT == 0 || $vT == null)) {
goto vF;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = AESEncryption::decrypt_data($aB, $hO);
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= 30 && $Di > 7)) {
goto ad;
}
$this->slrae($Di);
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, $Di);
ad:
vF:
vW:
iH:
return $Di;
}
public function slrae($le)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>This email is to notify you that your 1 year license for Magento IDP Plugin will expire
\x9\x9 \x9in " . $le . " days. The plugin will stop working after the licensed period expires.<br><br>
\x9 You will need to renew your license to continue using the plugin on your website .\xd
\x9\x9<br><br>Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "Magento IDP Plugin License will expire in " . $le . " days.";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function slrfae()
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>Your 1 year license for Magento IDP Plugin has expired for your website . \xd
\x9\x9 The plugin will stop working soon.<br><br>You will need to renew your license to continue using the plugin.You have0 days grace period to renew your licence after that your SSO will be disabled on your website\xd\xa\x9\x9\x9 \x9 Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expired - Magento IDP Plugin ";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function spdae()
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>Your year license for Magento IDP Plugin has expired. You have not renewed your license within
\xa \x9 \x9the 10 days grace period given to you. The SSO has been disabled on your website .<br><br>
\x9 \x9\x9\x9Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expired - Magento IDP Plugin ";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function vml($Tv)
{
$sK = $this->getStoreConfig(IDPConstants::SAML_IDP_KEY);
$Ua = $this->getStoreConfig(IDPConstants::API_KEY);
$Ib = Curl::vml($sK, $Ua, $Tv, $this->getBaseUrl());
return $Ib;
}
public function mius()
{
$sK = $this->getStoreConfig(IDPConstants::SAML_IDP_KEY);
$Ua = $this->getStoreConfig(IDPConstants::API_KEY);
$q2 = $this->getStoreConfig(IDPConstants::TOKEN);
$Tv = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::SAML_IDP_LK), $q2);
$Ib = Curl::mius($sK, $Ua, $Tv);
return $Ib;
}
public function mclv()
{
$q2 = $this->getStoreConfig(IDPConstants::TOKEN);
$Ku = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::SAML_IDP_CKL), $q2);
$EZ = $this->getStoreConfig(IDPConstants::SAML_IDP_LK);
return $Ku == "true" && !$this->isBlank($EZ) ? TRUE : FALSE;
}
public function addUserInList($user)
{
$this->log_debug("in addUserInList");
if (!$this->cleu()) {
goto AJ;
}
$Y2 = "customer_entity";
$oh = "idp_user";
$hs = 1;
$sU = $user->getId();
$this->updateColumnInTable($Y2, $oh, $hs, IDPConstants::COLUMN_ENTITY, $sU, $user);
AJ:
}
public function updateColumnInTable($Y2, $x8, $OZ, $fW, $Y6, $user)
{
$this->log_debug("Updating colum in table");
$ie = $this->resource->getConnection();
if (!($ie->tableColumnExists($Y2, $x8) === false)) {
goto Ht;
}
$ie->addColumn($Y2, $x8, array("type" => "text", "nullable" => false, "length" => 255, "after" => null, "comment" => $x8));
Ht:
$this->log_debug("User does not exist");
$this->resource->getConnection()->update($Y2, [$x8 => $OZ], [$fW . " = ?" => $Y6]);
$this->flushCache();
if ($this->check_plan(2)) {
goto uu;
}
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
goto J4;
uu:
$hO = "E7XIXCVVUOYAIA2";
J4:
$vU = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$OI = $this->getcount();
$sA = max($vU, $OI);
$this->log_debug("before count: ", $sA);
$sA = $sA + 1;
$sA = AESEncryption::encrypt_data($sA, $hO);
$this->setStoreConfig(IDPConstants::IDP_USERS_COUNT, $sA);
$this->reinitConfig();
$this->log_debug("after count: ", $this->getStoreConfig(IDPConstants::IDP_USERS_COUNT));
}
public function getRemainingUsersCount()
{
$this->flushCache();
$this->reinitConfig();
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$vU = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$OI = $this->getcount();
$gs = max($vU, $OI);
$this->setStoreConfig(IDPConstants::IDP_USERS_COUNT, AESEncryption::encrypt_data($gs, $hO));
$qk = $DI - $gs;
return $qk;
}
public function getFieldNames()
{
$nP = $this->resource->getConnection()->describeTable("customer_entity");
return $nP;
}
public function getMoTfaUserDetails($Y2)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["sp_name"]);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getAllid($Y2)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["id"]);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getAllRedirectUri($Y2)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["redirect_url"]);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getAllissuer($Y2)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["issuer"]);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetails($Y2, $Y0 = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2)->where("sp_name='" . $Y0 . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetailsusingid($Y2, $ST = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2)->where("id='" . $ST . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetailsusingRedirectUri($Y2, $pj = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2)->where("redirect_url='" . $pj . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetailsusingredirecturl($Y2, $ST = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2)->where("id='" . $ST . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetailsusingIssuer($Y2, $cZ = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2)->where("issuer='" . $cZ . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function deleteRowInTable($Y2, $fW, $Y6)
{
$K5 = $this->resource->getConnection();
$Ah = "DELETE FROM " . $Y2 . " WHERE " . $fW . "=" . $Y6;
$K5->exec($Ah);
}
public function getissuer($Y2, $nE = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["acs_url"])->where("issuer='" . $nE . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getacs($Y2, $cZ = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["acs_url"])->where("issuer='" . $cZ . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getslo($Y2, $nE = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["logout_url"])->where("issuer='" . $nE . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function insertRowInTable($Y2, $Ti)
{
$this->resource->getConnection()->insertMultiple($Y2, $Ti);
}
public function updateColumn($Y2, $x8, $OZ, $fW, $Y6)
{
$this->log_debug("updateColumnInTable " . $x8);
$ie = $this->resource->getConnection();
if (!($ie->tableColumnExists($Y2, $x8) === false)) {
goto sm;
}
$ie->addColumn($Y2, $x8, array("type" => "text", "nullable" => false, "length" => 255, "after" => null, "comment" => $x8));
sm:
$this->resource->getConnection()->update($Y2, [$x8 => $OZ], [$fW . " = ?" => $Y6]);
}
public function isOAuthServerConfigured()
{
$PL = $this->getStoreConfig(IDPConstants::AUTHORIZE_URL);
return $this->isBlank($PL) ? false : true;
}
public function generateRandom($B5 = 30)
{
$ms = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ036789";
$UY = strlen($ms);
$iM = '';
$gS = 0;
uU:
if (!($gS < $B5)) {
goto ww;
}
$iM .= $ms[rand(0, $UY - 1)];
c8:
$gS++;
goto uU;
ww:
return $iM;
}
public function oauthserver_server_sso_validate_code($Tv, $zG, $T7)
{
$s6 = time();
if (!($s6 - $T7 >= 400)) {
goto tq;
}
return "Your authentication code has expired. Please try again.";
tq:
if (!($Tv != $zG)) {
goto B0;
}
return "Incorrect Code";
B0:
}
public function oauthserver_server_sso_validate_grant($sG)
{
if (!($sG != "authorization_code")) {
goto C2;
}
return "Only Authorization Code grant type supported";
C2:
}
public function oauthserver_server_sso_validate_redirectUrl($pj, $OW)
{
if ($OW != '' && $pj != '') {
goto Bw;
}
return "Redirect URL is not configured";
goto eB;
Bw:
if (!($pj != $OW)) {
goto KH;
}
return "Redirect URL mismatch";
KH:
eB:
}
public function ValidateAccessToken($T7)
{
$s6 = time();
if (!($s6 - $T7 >= 900)) {
goto Ul;
}
return true;
Ul:
}
public function validateClient($N8, $qW, $OW, $wK, $Kr)
{
if (!(trim($N8) != trim($qW) || trim($OW) != trim($wK) || $Kr != "code")) {
goto Uu;
}
return "Invalid Client";
Uu:
}
public function update_status($Tv)
{
$sK = $this->getStoreConfig(IDPConstants::CUSTOMER_KEY);
$Ua = $this->getStoreConfig(IDPConstants::API_KEY);
$Ib = Curl::update_status($sK, $Ua, $Tv, $this->getBaseUrl());
return $Ib;
}
public function oauth_server_sso_validate_clientId($sg, $N8)
{
if (!empty($sg) && !empty($N8)) {
goto SM;
}
return "Client ID missing. To fix the issue, please send Client ID from your OAuth Client.";
goto MS;
SM:
if (!($N8 != $sg)) {
goto bV;
}
return "Incorrect Client ID";
bV:
MS:
}
public function oauth_server_sso_validate_clientSecret($TA, $tZ)
{
if (!empty($TA) && !empty($tZ)) {
goto B_;
}
return "Client Secret missing. To fix the issue, please send Client Secret from your OAuth Client.";
goto ai;
B_:
if (!($TA != $tZ)) {
goto MU;
}
return "Incorrect Client Secret";
MU:
ai:
}
public function getEavAttrFieldNames()
{
$Y9 = $this->resource->getConnection()->select()->from("eav_attribute", ["attribute_code", "frontend_label"])->where("entity_type_id = ?", 1)->orWhere("entity_type_id = ?", 2);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function check_license_expiry_date()
{
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
$aB = $this->getStoreConfig(IDPConstants::LICENSE_EXPIRY_DATE);
$NX = null;
if ($aB == null) {
goto Ql;
}
$NX = AESEncryption::decrypt_data($aB, $hO);
goto uT;
Ql:
$Ib = json_decode(self::ccl(), true);
$P1 = array_key_exists("noOfUsers", $Ib) ? $Ib["noOfUsers"] : null;
$NX = array_key_exists("licenseExpiry", $Ib) ? strtotime($Ib["licenseExpiry"]) === false ? null : strtotime($Ib["licenseExpiry"]) : null;
if ($this->isBlank($P1)) {
goto EP;
}
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data($P1, $hO));
EP:
if ($this->isBlank($NX)) {
goto im;
}
$this->setStoreConfig(IDPConstants::LICENSE_EXPIRY_DATE, AESEncryption::encrypt_data($NX, $hO));
im:
uT:
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= 30)) {
goto wR;
}
$this->flushCache();
$vT = $this->getStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT);
if ($Di > 7) {
goto Gg;
}
if ($Di <= 7 && $Di > 0) {
goto zm;
}
if ($Di <= 0 && $Di > -10) {
goto ob;
}
if ($Di <= -10) {
goto eI;
}
goto o6;
Gg:
if (!($vT == null)) {
goto NU;
}
$this->send_notification_before_expiry($Di);
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT, $Di);
NU:
goto o6;
zm:
if (!($vT == null || $vT > 7)) {
goto gv;
}
$this->send_notification_before_expiry($Di);
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT, $Di);
gv:
goto o6;
ob:
if (!($vT == null || $vT > -1)) {
goto ly;
}
$this->send_notification_after_expiry_with_grace();
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT, $Di);
ly:
goto o6;
eI:
if (!($vT == null || $vT >= 0)) {
goto Aw;
}
$this->send_notification_after_expiry();
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT, 0);
Aw:
o6:
wR:
return $Di;
}
public function send_notification_before_expiry($le)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>This email is to notify you that your 1 year license for Magento OAuth Server Premium Plugin will expire
in " . $le . " days. The plugin will stop working after the licensed period expires.<br><br>
You need to renew your license to continue using the service.\xd
<br><br>Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expiry - Magento OAuth Server Premium Plugin";
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function send_notification_after_expiry_with_grace()
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>Your 1 year license for Magento OAuth Server Premium Plugin has expired for your website . \xd\xa The plugin will stop working soon.<br><br>You will need to renew your license to continue using the plugin.You have 10 days grace period to renew your licence after that your SSO will be disabled on your website
Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expired - Magento OAuth Server Premium Plugin ";
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function send_notification_after_expiry()
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>Your 1 year license for Magento OAuth Server Premium Plugin has expired. You have not renewed your license within \xd
the 10 days grace period given to you. The SSO has been disabled on your website .<br><br>
Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expired - Magento OAuth Server Premium Plugin ";
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function user_limit_expired_notification($Wy)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>You have purchased license for Magento OAuth Server Plan for <b>" . $Wy . " users</b>. \xd
As number of users on your site have grown to more than " . $Wy . " users now, new users will not be able to use SSO capabilities for your site <br><br>
Please reach out to us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> or use the Support Form in the plugin to upgrade the license to continue using our plugin.\xd\xa <br><br>Thanks,<br>miniOrange";
$Y1 = "Exceeded License Limit For No Of Users - Magento OAuth Server Premium Plugin";
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_USER_EXCEEDED_ALERT_SENT, 0);
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function user_limit_expiring_soon_notification($Wy, $qk)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>You have purchased license for Magento OAuthServer Premium Plugin for <b>" . $Wy . " users</b>.
\xa As number of users on your site have grown to more than " . ($Wy - $qk) . " users now .You have left with " . $qk . " user for SSO
Please reach out to us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> or use the Support Form if you wish to upgrade the license.
\xa <br><br>Thanks,<br>miniOrange";
$Y1 = "Exceeded License Limit For No Of Users - Magento OAuth Server Premium Plugin";
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_USER_EXCEEDED_ALERT_SENT, $qk);
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function fetchLicense()
{
$this->log_debug("In function fetchLicense ");
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
$Wa = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$aB = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::SAML_IDP_LED), $hO);
$ox = json_decode($this->ccl(), true);
if ($ox["status"] == "SUCCESS") {
goto Xs;
}
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data(0, $hO));
$this->setStoreConfig(IDPConstants::SAML_IDP_LED, AESEncryption::encrypt_data(strtotime("h0-00 00:00:p"), $hO));
goto ee;
Xs:
$ix = $ox["noOfUsers"];
$xY = strtotime($ox["licenseExpiry"]);
if (!($Wa == null || $Wa == 0 || empty($Wa))) {
goto KW;
}
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data($ix, $hO));
KW:
if (!($aB == null || $aB == 0 || empty($aB))) {
goto Yx;
}
$this->setStoreConfig(IDPConstants::SAML_IDP_LED, AESEncryption::encrypt_data($xY, $hO));
Yx:
$vU = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$OI = $this->getcount();
if (!($vU == null || $vU == 0 || $vU != $OI)) {
goto ta;
}
$z6 = max($vU, $OI);
$this->setStoreConfig(IDPConstants::IDP_USERS_COUNT, AESEncryption::encrypt_data($z6, $hO));
ta:
if ($aB < strtotime($ox["licenseExpiry"])) {
goto Z1;
}
if ($Wa < $ox["noOfUsers"]) {
goto rZ;
}
goto Cm;
Z1:
$aB = strtotime($ox["licenseExpiry"]);
$this->setStoreConfig(IDPConstants::SAML_IDP_LED, AESEncryption::encrypt_data($aB, $hO));
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data($ix, $hO));
$this->setStoreConfig(IDPConstants::IDP_USERS_COUNT, AESEncryption::encrypt_data(0, $hO));
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, NULL);
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, NULL);
$ie = $this->resource->getConnection();
$Lj = $this->resource->getTableName("miniorange_oauth_server_users");
$ie->delete($Lj);
if (!$ie->tableColumnExists("customer_entity", "idp_user")) {
goto WM;
}
$ie->dropColumn("customer_entity", "idp_user");
WM:
$this->log_debug("updated expiry date: " . $ox["licenseExpiry"]);
$this->log_debug("updated users limit: " . $ix);
goto Cm;
rZ:
$this->setStoreConfig(IDPConstants::SAML_IDP_LED, AESEncryption::encrypt_data($aB, $hO));
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data($ix, $hO));
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, NULL);
Cm:
ee:
$this->flushCache();
$this->reinitConfig();
}
public function getcount()
{
$this->flushCache();
$this->reinitConfig();
$ie = $this->resource->getConnection();
$Lj = "customer_entity";
$aw = "idp_user";
$ym = $ie->describeTable($Lj);
if (isset($ym[$aw])) {
goto zo;
}
return 0;
goto UK;
zo:
$XA = $ie->select();
$XA->from($Lj, "COUNT(*)")->where($aw . " = ?", 1);
return (int) $ie->fetchOne($XA);
UK:
}
public function setCookie($uM, $TC, $VM)
{
$OC = $this->cookieMetadataFactory->createPublicCookieMetadata()->setDuration($VM)->setPath("/")->setHttpOnly(false);
$this->cookieManager->setPublicCookie($uM, $TC, $OC);
}
public function getCookie($uM)
{
return $this->cookieManager->getCookie($uM);
}
public function deleteCookie($uM)
{
$OC = $this->cookieMetadataFactory->createCookieMetadata();
$OC->setPath("/");
$this->cookieManager->deleteCookie($uM, $OC);
}
public function customlog($hy)
{
$this->isLogEnable() ? $this->_logger->debug($hy) : NULL;
}
public function isCustomLogExist()
{
if ($this->fileSystem->isExists("../var/log/mo_idp.log")) {
goto gR;
}
if ($this->fileSystem->isExists("var/log/mo_idp.log")) {
goto ge;
}
goto bn;
gR:
return 1;
goto bn;
ge:
return 1;
bn:
return 0;
}
public function deleteCustomLogFile()
{
if ($this->fileSystem->isExists("../var/log/mo_idp.log")) {
goto z8;
}
if ($this->fileSystem->isExists("var/log/mo_idp.log")) {
goto Gs;
}
goto BO;
z8:
$this->fileSystem->deleteFile("../var/log/mo_idp.log");
goto BO;
Gs:
$this->fileSystem->deleteFile("var/log/mo_idp.log");
BO:
}
public function getProductVersion()
{
return $this->productMetadata->getVersion();
}
public function isLogEnable()
{
return $this->getStoreConfig(IDPConstants::ENABLE_DEBUG_LOG);
}
public function getCurrentDate()
{
return $this->dateTime->gmtDate("Y-m-d H:i");
}
public function isExistingSSOUser($Y2, $MW = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2)->where("entity_id='" . $MW . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function check_plan($EP)
{
return $this->get_versi() >= $EP;
}
public function get_versi()
{
$cr = IDPConstants::LICENSE_PLAN;
return $cr === "magento_saml_idp_trial_plan" ? 2 : ($cr === "magento_saml_idp_premium_plan" ? 1 : 0);
}
public function checkTrialExpiry()
{
if (!$this->isTrialExpired()) {
goto ZV;
}
$Ij = $this->customerSession->getId();
if (!$Ij) {
goto Pc;
}
$this->customerSession->logout();
Pc:
$this->messageManager->addErrorMessage("Your Demo account has expired. Please contact to magentosupport@xecurify.com");
$nZ = $this->urlBuilder->getUrl("customer/account/login");
$this->responseFactory->create()->setRedirect($nZ)->sendResponse();
exit;
ZV:
}
public function checkTrialUserLeft($user)
{
$hO = "E7XIXCVVUOYAIA2";
$DI = (int) AESEncryption::decrypt_data("Y3Vn", $hO);
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
if ($gs > $DI) {
goto ws;
}
$this->log_debug("in addUserInList");
$Y2 = "customer_entity";
$oh = "idp_user";
$hs = 1;
$sU = $user->getId();
$this->updateColumnInTable($Y2, $oh, $hs, IDPConstants::COLUMN_ENTITY, $sU, $user);
goto kM;
ws:
$Ij = $this->customerSession->getId();
if (!$Ij) {
goto Mh;
}
$this->customerSession->logout();
Mh:
$this->messageManager->addErrorMessage("Your Demo account has expired. Please contact to magentosupport@xecurify.com");
$nZ = $this->urlBuilder->getUrl("customer/account/login");
$this->responseFactory->create()->setRedirect($nZ)->sendResponse();
exit;
kM:
}
}
namespace MiniOrange\IDPSaml\Helper;
use MiniOrange\IDPSaml\Helper\IDPConstants;
use MiniOrange\IDPSaml\Helper\Curl;
use MiniOrange\IDPSaml\Helper\Data;
use MiniOrange\IDPSaml\Helper\Saml2\Lib\AESEncryption;
use MiniOrange\IDPSaml\Helper\Saml2\SAML2Utilities;
use Psr\Log\LoggerInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\ResourceConnection;
use MiniOrange\IDPSaml\Model\OAuthServerUsersFactory;
use MiniOrange\IDPSaml\Model\MiniOrangeSpTableFactory;
use Magento\Framework\Stdlib\DateTime\DateTime;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\UrlInterface;
use DOMElement;
use DOMDocument;
use DOMNode;
use DOMXPath;
class IDPUtility extends Data
{
protected $adminSession;
protected $customerSession;
protected $authSession;
protected $cacheTypeList;
protected $cacheFrontendPool;
protected $fileSystem;
protected $reinitableConfig;
protected $userGroupModel;
protected $adminRoleModel;
protected $adminUserModel;
protected $customerModel;
protected $resource;
protected $logger;
protected $oauthServerUsers;
protected $miniOrangeOAuthClientsFactory;
protected $productMetadata;
protected $dateTime;
public $customerRepository;
protected $response;
protected $urlBuilder;
protected $responseFactory;
protected $messageManager;
public function __construct(ManagerInterface $Hr, \Magento\Framework\App\Config\ScopeConfigInterface $uI, \Magento\User\Model\UserFactory $RK, \Magento\Customer\Model\CustomerFactory $o2, \Magento\Framework\UrlInterface $L8, \Magento\Framework\App\Config\Storage\WriterInterface $FL, \Magento\Framework\View\Asset\Repository $pC, \Magento\Backend\Helper\Data $Db, \Magento\Framework\Url $xA, \Magento\Backend\Model\Session $sf, \Magento\Customer\Model\Session $d9, \Magento\Backend\Model\Auth\Session $dl, \Magento\Framework\App\Cache\TypeListInterface $GL, \Magento\Framework\App\Cache\Frontend\Pool $II, \Magento\Framework\Filesystem\Driver\File $MF, \Magento\Framework\App\Config\ReinitableConfigInterface $WE, \Magento\Customer\Model\ResourceModel\Group\Collection $kg, \Magento\Authorization\Model\ResourceModel\Role\Collection $w5, \Magento\User\Model\User $g2, \Magento\Customer\Model\Customer $VZ, \Magento\Framework\App\ResourceConnection $Fe, \MiniOrange\IDPSaml\Logger\Logger $Vg, OAuthServerUsersFactory $lz, MiniOrangeSpTableFactory $eq, \Magento\Framework\App\ProductMetadataInterface $nA, DateTime $TT, CustomerRepositoryInterface $ql, LoggerInterface $ce, UrlInterface $S7, ResponseInterface $WG, \Magento\Framework\App\ResponseFactory $Pd)
{
$this->adminSession = $sf;
$this->customerSession = $d9;
$this->authSession = $dl;
$this->cacheTypeList = $GL;
$this->cacheFrontendPool = $II;
$this->fileSystem = $MF;
$this->reinitableConfig = $WE;
$this->logger = $ce;
$this->customerModel = $VZ;
$this->userGroupModel = $kg;
$this->resource = $Fe;
$this->adminRoleModel = $w5;
$this->adminUserModel = $g2;
$this->_logger = $Vg;
$this->oauthServerUsers = $lz;
$this->miniOrangeOAuthClientsFactory = $eq;
$this->productMetadata = $nA;
$this->dateTime = $TT;
$this->customerRepository = $ql;
$this->messageManager = $Hr;
$this->urlBuilder = $S7;
$this->response = $WG;
$this->responseFactory = $Pd;
parent::__construct($uI, $RK, $o2, $L8, $FL, $pC, $Db, $xA, $lz, $eq, $TT, $nA);
}
public function getHiddenPhone($MZ)
{
$b7 = "xxxxxxx" . substr($MZ, strlen($MZ) - 3);
return $b7;
}
public function isBlank($TC)
{
if (!(!isset($TC) || empty($TC))) {
goto Hs;
}
return true;
Hs:
return false;
}
public function isCurlInstalled()
{
if (in_array("curl", get_loaded_extensions())) {
goto lH;
}
return 0;
goto nC;
lH:
return 1;
nC:
}
public function validatePhoneNumber($MZ)
{
if (!preg_match(MoIDPConstants::PATTERN_PHONE, $MZ, $SB)) {
goto Z_;
}
return true;
goto rR;
Z_:
return false;
rR:
}
public function getHiddenEmail($Wc)
{
if (!(!isset($Wc) || trim($Wc) === '')) {
goto wC;
}
return '';
wC:
$a4 = strlen($Wc);
$fo = substr($Wc, 0, 1);
$Qx = strrpos($Wc, "@");
$lH = substr($Wc, $Qx - 1, $a4);
$gS = 1;
dF:
if (!($gS < $Qx)) {
goto V0;
}
$fo = $fo . "x";
cw:
$gS++;
goto dF;
V0:
$dn = $fo . $lH;
return $dn;
}
public function setAdminSessionData($hO, $TC)
{
return $this->adminSession->setData($hO, $TC);
}
public function getAdminSessionData($hO, $MI = false)
{
return $this->adminSession->getData($hO, $MI);
}
public function setSessionData($hO, $TC)
{
return $this->customerSession->setData($hO, $TC);
}
public function getSessionData($hO, $MI = false)
{
return $this->customerSession->getData($hO, $MI);
}
public function unsetSessionData($hO, $MI = false)
{
return $this->customerSession->unsetData($hO, $MI);
}
public function setSessionDataForCurrentUser($hO, $TC)
{
if ($this->customerSession->isLoggedIn()) {
goto Ei;
}
if ($this->authSession->isLoggedIn()) {
goto zj;
}
goto La;
Ei:
$this->setSessionData($hO, $TC);
goto La;
zj:
$this->setAdminSessionData($hO, $TC);
La:
}
public function isSPConfigured()
{
$PL = $this->getStoreConfig(IDPConstants::SAML_SSO_URL);
return $this->isBlank($PL) ? false : true;
}
public function micr()
{
$Wc = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$hO = $this->getStoreConfig(IDPConstants::SAML_IDP_KEY);
return !$this->isBlank($Wc) && !$this->isBlank($hO) ? true : false;
}
public function isUserLoggedIn()
{
return $this->customerSession->isLoggedIn() || $this->authSession->isLoggedIn();
}
public function getCurrentAdminUser()
{
return $this->authSession->getUser();
}
public function getCurrentUser()
{
$TV = \Magento\Framework\App\ObjectManager::getInstance();
$d9 = $TV->get("Magento\Customer\Model\Session");
$Qq = $d9->getCustomer()->getEmail();
return $d9->getCustomer();
}
public function getAcsUrl()
{
return $this->getStoreConfig(IDPConstants::SAML_SSO_URL);
}
public function getAdminLoginUrl()
{
return $this->getAdminUrl("adminhtml/auth/login");
}
public function getCustomerLoginUrl()
{
return $this->getUrl("customer/account/login");
}
public function getCustomer($ST)
{
return $this->customerRepository->getById($ST);
}
public function desanitizeCert($r3)
{
return SAML2Utilities::desanitize_certificate($r3);
}
public function sanitizeCert($r3)
{
return SAML2Utilities::sanitize_certificate($r3);
}
public function flushCache()
{
$WX = ["db_ddl"];
foreach ($WX as $bc) {
$this->cacheTypeList->cleanType($bc);
vm:
}
ed:
foreach ($this->cacheFrontendPool as $DR) {
$DR->getBackend()->clean();
Kl:
}
mT:
}
public function getFileContents($LK)
{
return $this->fileSystem->fileGetContents($LK);
}
public function putFileContents($LK, $Ti)
{
$this->fileSystem->filePutContents($LK, $Ti);
}
public function getAdminSession()
{
return $this->adminSession;
}
public function reinitConfig()
{
$this->reinitableConfig->reinit();
}
public function parseBoolean(DOMElement $y8, $pW, $fv = null)
{
if ($y8->hasAttribute($pW)) {
goto O2;
}
return $fv;
O2:
$TC = $y8->getAttribute($pW);
switch (strtolower($TC)) {
case "0":
case "false":
return FALSE;
case "1":
case "true":
return TRUE;
default:
throw new \Exception("Invalid value of boolean attribute " . var_export($pW, TRUE) . ": " . var_export($TC, TRUE));
}
Km:
hl:
}
public function xpQuery(DOMNode $y8, $Y9)
{
static $dJ = NULL;
if ($y8 instanceof DOMDocument) {
goto eZ;
}
$ky = $y8->ownerDocument;
goto Su;
eZ:
$ky = $y8;
Su:
if (!($dJ === NULL || !$dJ->document->isSameNode($ky))) {
goto es;
}
$dJ = new DOMXPath($ky);
$dJ->registerNamespace("soap-env", "http://schemas.xmlsoap.org/soap/envelope/");
$dJ->registerNamespace("saml_protocol", "urn:oasis:names:tc:SAML:2.0:protocol");
$dJ->registerNamespace("saml_assertion", "urn:oasis:names:tc:SAML:2p:assertion");
$dJ->registerNamespace("saml_metadata", "urn:oasis:names:tc:SAML:2.0:metadata");
$dJ->registerNamespace("ds", "http://www.w3.orgz0/09/xmldsig#");
$dJ->registerNamespace("xenc", "http://www.w3.orgz1/04/xmlenc#");
es:
$c_ = $dJ->query($Y9, $y8);
$We = array();
$gS = 0;
Pf:
if (!($gS < $c_->length)) {
goto WP;
}
$We[$gS] = $c_->item($gS);
CZ:
$gS++;
goto Pf;
WP:
return $We;
}
private function getRoleIdByName($bA)
{
$cO = $this->adminRoleModel->toOptionArray();
foreach ($cO as $fV) {
if (!($bA == $fV["label"])) {
goto oF;
}
return $fV["value"];
oF:
Hv:
}
nS:
}
private function getGroupIdByName($Mx)
{
$bx = $this->userGroupModel->toOptionArray();
foreach ($bx as $cV) {
if (!($Mx == $cV["label"])) {
goto jc;
}
return $cV["value"];
jc:
A1:
}
R1:
}
public function log_debug($w3 = '', $W6 = null)
{
if (is_object($w3)) {
goto oz;
}
$this->customlog("MO IDP SAML PLugin : " . $w3);
goto Tr;
oz:
$this->customlog("MO IDP SAML PLugin : " . print_r($W6, true));
Tr:
if (!($W6 != null)) {
goto Ik;
}
$this->customlog("MO IDP SAML PLugin : " . var_export($W6, true));
Ik:
}
public function checkIfUserLeft($user)
{
if ($this->cleu()) {
goto lh;
}
$this->log_debug("in addUserInList");
$Y2 = "customer_entity";
$oh = "idp_user";
$hs = 1;
$sU = $user->getId();
$this->updateColumnInTable($Y2, $oh, $hs, IDPConstants::COLUMN_ENTITY, $sU, $user);
goto Qi;
lh:
$Ij = $this->customerSession->getId();
if (!$Ij) {
goto Zz;
}
$this->customerSession->logout();
Zz:
$this->messageManager->addErrorMessage("You have exceeded the User Limit Please contact your adminstrator.");
$nZ = $this->urlBuilder->getUrl("customer/account/login");
$this->responseFactory->create()->setRedirect($nZ)->sendResponse();
exit;
Qi:
}
public function cleu()
{
$this->flushCache();
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
$SS = $this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT);
if (!($SS == null)) {
goto Bl;
}
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
Bl:
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$qk = $DI - $gs;
$Bw = $DI / 10;
if ($qk <= $Bw && $qk > 10) {
goto ZB;
}
if ($qk <= 10 && $qk > 0) {
goto Is;
}
if ($qk < 0 && $qk > -(int) $Bw) {
goto MK;
}
if (!($qk <= -(int) $Bw)) {
goto p9;
}
$this->flushCache();
$J8 = $this->getStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT);
if (!($J8 == NULL || $J8 > -(int) $Bw)) {
goto CB;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$qk = $DI - $gs;
if (!($qk <= -(int) $Bw)) {
goto PD;
}
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, $qk);
$this->suea($DI);
PD:
CB:
return true;
p9:
goto Yc;
MK:
$this->flushCache();
$J8 = $this->getStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT);
if (!($J8 == 0 || $J8 == NULL || $J8 > 0)) {
goto Yo;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$qk = $DI - $gs;
if (!($qk < 0 && $qk > -(int) $Bw)) {
goto uf;
}
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, $qk);
$this->suea($DI);
uf:
Yo:
Yc:
goto Y6;
ZB:
$this->flushCache();
$J8 = $this->getStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT);
if (!($J8 == 0 || $J8 == NULL)) {
goto xZ;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$qk = $DI - $gs;
$Bw = $DI / 10;
if (!($qk <= $Bw && $qk > 10)) {
goto UA;
}
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, $qk);
$this->sue($DI, $qk);
UA:
xZ:
goto Y6;
Is:
$this->flushCache();
$J8 = $this->getStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT);
if (!($J8 == 0 || $J8 == NULL || $J8 > 10)) {
goto WZ;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$qk = $DI - $gs;
if (!($qk <= 10 && $qk > 0)) {
goto LN;
}
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, $qk);
$this->sue($DI, $qk);
LN:
WZ:
Y6:
return false;
}
public function suea($Wy)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>You have purchased license for miniOrange Magento IDP Plugin for <b>" . $Wy . " users</b>. \xd
\x9 \x9\x9s number of users on your site have grown to more than " . $Wy . " users now, new users will not be able to use SSO capabilities for your site <br><br>
\xa\x9\x9 \x9\x9 Please reach out to us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> or use the Support Form in the plugin to upgrade the license to continue using our plugin.
\xa \x9 \x9\x9\x9<br><br>Thanks,<br>miniOrange";
$Y1 = "Exceeded License Limit For No Of Users - Magento IDP Plugin";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function sue($Wy, $qk)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>You have purchased license for miniOrange Magento IDP Plugin for <b>" . $Wy . " users</b>. \xd\xa \x9\x9 \x9 As number of users on your site have grown to more than " . ($Wy - $qk) . " users now .You have left with " . $qk . " user for SSO
\xa\x9 \x9\x9\x9Please reach out to us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> or use the Support Form if you wish to upgrade the license.
\x9\x9\x9 \x9 <br><br>Thanks,<br>miniOrange";
$Y1 = "Exceeded License Limit For No Of Users - Magento IDP Plugin";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function ccl()
{
$sK = $this->getStoreConfig(IDPConstants::SAML_IDP_KEY);
$Ua = $this->getStoreConfig(IDPConstants::API_KEY);
$Ib = Curl::ccl($sK, $Ua);
return $Ib;
}
public function checkIfValidLicense()
{
if (!($this->cled() <= -10)) {
goto nv;
}
$Ij = $this->customerSession->getId();
if (!$Ij) {
goto IX;
}
$this->customerSession->logout();
IX:
$this->messageManager->addErrorMessage("Your License is expired Please contact your adminstrator.");
$nZ = $this->urlBuilder->getUrl("customer/account/login");
$this->responseFactory->create()->setRedirect($nZ)->sendResponse();
exit;
nv:
}
public function cled()
{
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = null;
if ($aB == null) {
goto y3;
}
$NX = AESEncryption::decrypt_data($aB, $hO);
goto r0;
y3:
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
r0:
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= 30)) {
goto iH;
}
$this->flushCache();
$this->reinitConfig();
$vT = $this->getStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT);
if ($Di > 7) {
goto yy;
}
if ($Di <= 7 && $Di > 0) {
goto eX;
}
if ($Di < 0 && $Di > -10) {
goto OY;
}
if (!($Di <= -10)) {
goto q7;
}
if (!($vT == 0 || $vT == null || $vT > -10)) {
goto Z4;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = AESEncryption::decrypt_data($aB, $hO);
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= -10)) {
goto Li;
}
$this->spdae();
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, $Di);
Li:
Z4:
q7:
goto kv;
OY:
if (!($vT == 0 || $vT == null || $vT > 0)) {
goto N4;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = AESEncryption::decrypt_data($aB, $hO);
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di < 0 && $Di > -10)) {
goto WB;
}
$this->slrfae();
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, $Di);
WB:
N4:
kv:
goto gr;
eX:
if (!($vT == 0 || $vT == null || $vT > 7)) {
goto Nm;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = AESEncryption::decrypt_data($aB, $hO);
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= 7 && $Di > 0)) {
goto Zv;
}
$this->slrae($Di);
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, $Di);
Zv:
Nm:
gr:
goto vW;
yy:
if (!($vT == 0 || $vT == null)) {
goto vF;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = AESEncryption::decrypt_data($aB, $hO);
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= 30 && $Di > 7)) {
goto ad;
}
$this->slrae($Di);
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, $Di);
ad:
vF:
vW:
iH:
return $Di;
}
public function slrae($le)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>This email is to notify you that your 1 year license for Magento IDP Plugin will expire
\x9\x9 \x9in " . $le . " days. The plugin will stop working after the licensed period expires.<br><br>
\x9 You will need to renew your license to continue using the plugin on your website .\xd
\x9\x9<br><br>Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "Magento IDP Plugin License will expire in " . $le . " days.";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function slrfae()
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>Your 1 year license for Magento IDP Plugin has expired for your website . \xd
\x9\x9 The plugin will stop working soon.<br><br>You will need to renew your license to continue using the plugin.You have0 days grace period to renew your licence after that your SSO will be disabled on your website\xd\xa\x9\x9\x9 \x9 Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expired - Magento IDP Plugin ";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function spdae()
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>Your year license for Magento IDP Plugin has expired. You have not renewed your license within
\xa \x9 \x9the 10 days grace period given to you. The SSO has been disabled on your website .<br><br>
\x9 \x9\x9ontact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expired - Magento IDP Plugin ";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function vml($Tv)
{
$sK = $this->getStoreConfig(IDPConstants::SAML_IDP_KEY);
$Ua = $this->getStoreConfig(IDPConstants::API_KEY);
$Ib = Curl::vml($sK, $Ua, $Tv, $this->getBaseUrl());
return $Ib;
}
public function mius()
{
$sK = $this->getStoreConfig(IDPConstants::SAML_IDP_KEY);
$Ua = $this->getStoreConfig(IDPConstants::API_KEY);
$q2 = $this->getStoreConfig(IDPConstants::TOKEN);
$Tv = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::SAML_IDP_LK), $q2);
$Ib = Curl::mius($sK, $Ua, $Tv);
return $Ib;
}
public function mclv()
{
$q2 = $this->getStoreConfig(IDPConstants::TOKEN);
$Ku = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::SAML_IDP_CKL), $q2);
$EZ = $this->getStoreConfig(IDPConstants::SAML_IDP_LK);
return $Ku == "true" && !$this->isBlank($EZ) ? TRUE : FALSE;
}
public function addUserInList($user)
{
$this->log_debug("in addUserInList");
if (!$this->cleu()) {
goto AJ;
}
$Y2 = "customer_entity";
$oh = "idp_user";
$hs = 1;
$sU = $user->getId();
$this->updateColumnInTable($Y2, $oh, $hs, IDPConstants::COLUMN_ENTITY, $sU, $user);
AJ:
}
public function updateColumnInTable($Y2, $x8, $OZ, $fW, $Y6, $user)
{
$this->log_debug("Updating colum in table");
$ie = $this->resource->getConnection();
if (!($ie->tableColumnExists($Y2, $x8) === false)) {
goto Ht;
}
$ie->addColumn($Y2, $x8, array("type" => "text", "nullable" => false, "length" => 255, "after" => null, "comment" => $x8));
Ht:
$this->log_debug("User does not exist");
$this->resource->getConnection()->update($Y2, [$x8 => $OZ], [$fW . " = ?" => $Y6]);
$this->flushCache();
if ($this->check_plan(2)) {
goto uu;
}
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
goto J4;
uu:
$hO = "E7XIXCVVUOYAIA2";
J4:
$vU = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$OI = $this->getcount();
$sA = max($vU, $OI);
$this->log_debug("before count: ", $sA);
$sA = $sA + 1;
$sA = AESEncryption::encrypt_data($sA, $hO);
$this->setStoreConfig(IDPConstants::IDP_USERS_COUNT, $sA);
$this->reinitConfig();
$this->log_debug("after count: ", $this->getStoreConfig(IDPConstants::IDP_USERS_COUNT));
}
public function getRemainingUsersCount()
{
$this->flushCache();
$this->reinitConfig();
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$vU = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$OI = $this->getcount();
$gs = max($vU, $OI);
$this->setStoreConfig(IDPConstants::IDP_USERS_COUNT, AESEncryption::encrypt_data($gs, $hO));
$qk = $DI - $gs;
return $qk;
}
public function getFieldNames()
{
$nP = $this->resource->getConnection()->describeTable("customer_entity");
return $nP;
}
public function getMoTfaUserDetails($Y2)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["sp_name"]);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getAllid($Y2)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["id"]);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getAllRedirectUri($Y2)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["redirect_url"]);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getAllissuer($Y2)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["issuer"]);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetails($Y2, $Y0 = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2)->where("sp_name='" . $Y0 . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetailsusingid($Y2, $ST = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2)->where("id='" . $ST . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetailsusingRedirectUri($Y2, $pj = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2)->where("redirect_url='" . $pj . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetailsusingredirecturl($Y2, $ST = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2)->where("id='" . $ST . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetailsusingIssuer($Y2, $cZ = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2)->where("issuer='" . $cZ . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function deleteRowInTable($Y2, $fW, $Y6)
{
$K5 = $this->resource->getConnection();
$Ah = "DELETE FROM " . $Y2 . " WHERE " . $fW . "=" . $Y6;
$K5->exec($Ah);
}
public function getissuer($Y2, $nE = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["acs_url"])->where("issuer='" . $nE . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getacs($Y2, $cZ = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["acs_url"])->where("issuer='" . $cZ . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getslo($Y2, $nE = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2, ["logout_url"])->where("issuer='" . $nE . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function insertRowInTable($Y2, $Ti)
{
$this->resource->getConnection()->insertMultiple($Y2, $Ti);
}
public function updateColumn($Y2, $x8, $OZ, $fW, $Y6)
{
$this->log_debug("updateColumnInTable " . $x8);
$ie = $this->resource->getConnection();
if (!($ie->tableColumnExists($Y2, $x8) === false)) {
goto sm;
}
$ie->addColumn($Y2, $x8, array("type" => "text", "nullable" => false, "length" => 255, "after" => null, "comment" => $x8));
sm:
$this->resource->getConnection()->update($Y2, [$x8 => $OZ], [$fW . " = ?" => $Y6]);
}
public function isOAuthServerConfigured()
{
$PL = $this->getStoreConfig(IDPConstants::AUTHORIZE_URL);
return $this->isBlank($PL) ? false : true;
}
public function generateRandom($B5 = 30)
{
$ms = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ036789";
$UY = strlen($ms);
$iM = '';
$gS = 0;
uU:
if (!($gS < $B5)) {
goto ww;
}
$iM .= $ms[rand(0, $UY - 1)];
c8:
$gS++;
goto uU;
ww:
return $iM;
}
public function oauthserver_server_sso_validate_code($Tv, $zG, $T7)
{
$s6 = time();
if (!($s6 - $T7 >= 400)) {
goto tq;
}
return "Your authentication code has expired. Please try again.";
tq:
if (!($Tv != $zG)) {
goto B0;
}
return "Incorrect Code";
B0:
}
public function oauthserver_server_sso_validate_grant($sG)
{
if (!($sG != "authorization_code")) {
goto C2;
}
return "Only Authorization Code grant type supported";
C2:
}
public function oauthserver_server_sso_validate_redirectUrl($pj, $OW)
{
if ($OW != '' && $pj != '') {
goto Bw;
}
return "Redirect URL is not configured";
goto eB;
Bw:
if (!($pj != $OW)) {
goto KH;
}
return "Redirect URL mismatch";
KH:
eB:
}
public function ValidateAccessToken($T7)
{
$s6 = time();
if (!($s6 - $T7 >= 900)) {
goto Ul;
}
return true;
Ul:
}
public function validateClient($N8, $qW, $OW, $wK, $Kr)
{
if (!(trim($N8) != trim($qW) || trim($OW) != trim($wK) || $Kr != "code")) {
goto Uu;
}
return "Invalid Client";
Uu:
}
public function update_status($Tv)
{
$sK = $this->getStoreConfig(IDPConstants::CUSTOMER_KEY);
$Ua = $this->getStoreConfig(IDPConstants::API_KEY);
$Ib = Curl::update_status($sK, $Ua, $Tv, $this->getBaseUrl());
return $Ib;
}
public function oauth_server_sso_validate_clientId($sg, $N8)
{
if (!empty($sg) && !empty($N8)) {
goto SM;
}
return "Client ID missing. To fix the issue, please send Client ID from your OAuth Client.";
goto MS;
SM:
if (!($N8 != $sg)) {
goto bV;
}
return "Incorrect Client ID";
bV:
MS:
}
public function oauth_server_sso_validate_clientSecret($TA, $tZ)
{
if (!empty($TA) && !empty($tZ)) {
goto B_;
}
return "Client Secret missing. To fix the issue, please send Client Secret from your OAuth Client.";
goto ai;
B_:
if (!($TA != $tZ)) {
goto MU;
}
return "Incorrect Client Secret";
MU:
ai:
}
public function getEavAttrFieldNames()
{
$Y9 = $this->resource->getConnection()->select()->from("eav_attribute", ["attribute_code", "frontend_label"])->where("entity_type_id = ?", 1)->orWhere("entity_type_id = ?", 2);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function check_license_expiry_date()
{
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
$aB = $this->getStoreConfig(IDPConstants::LICENSE_EXPIRY_DATE);
$NX = null;
if ($aB == null) {
goto Ql;
}
$NX = AESEncryption::decrypt_data($aB, $hO);
goto uT;
Ql:
$Ib = json_decode(self::ccl(), true);
$P1 = array_key_exists("noOfUsers", $Ib) ? $Ib["noOfUsers"] : null;
$NX = array_key_exists("licenseExpiry", $Ib) ? strtotime($Ib["licenseExpiry"]) === false ? null : strtotime($Ib["licenseExpiry"]) : null;
if ($this->isBlank($P1)) {
goto EP;
}
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data($P1, $hO));
EP:
if ($this->isBlank($NX)) {
goto im;
}
$this->setStoreConfig(IDPConstants::LICENSE_EXPIRY_DATE, AESEncryption::encrypt_data($NX, $hO));
im:
uT:
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= 30)) {
goto wR;
}
$this->flushCache();
$vT = $this->getStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT);
if ($Di > 7) {
goto Gg;
}
if ($Di <= 7 && $Di > 0) {
goto zm;
}
if ($Di <= 0 && $Di > -10) {
goto ob;
}
if ($Di <= -10) {
goto eI;
}
goto o6;
Gg:
if (!($vT == null)) {
goto NU;
}
$this->send_notification_before_expiry($Di);
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT, $Di);
NU:
goto o6;
zm:
if (!($vT == null || $vT > 7)) {
goto gv;
}
$this->send_notification_before_expiry($Di);
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT, $Di);
gv:
goto o6;
ob:
if (!($vT == null || $vT > -1)) {
goto ly;
}
$this->send_notification_after_expiry_with_grace();
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT, $Di);
ly:
goto o6;
eI:
if (!($vT == null || $vT >= 0)) {
goto Aw;
}
$this->send_notification_after_expiry();
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT, 0);
Aw:
o6:
wR:
return $Di;
}
public function send_notification_before_expiry($le)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>This email is to notify you that your 1 year license for Magento OAuth Server Premium Plugin will expire
in " . $le . " days. The plugin will stop working after the licensed period expires.<br><br>
You need to renew your license to continue using the service.\xd
<br><br>Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expiry - Magento OAuth Server Premium Plugin";
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function send_notification_after_expiry_with_grace()
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>Your 1 year license for Magento OAuth Server Premium Plugin has expired for your website . \xd\xa The plugin will stop working soon.<br><br>You will need to renew your license to continue using the plugin.You have 10 days grace period to renew your licence after that your SSO will be disabled on your website
Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expired - Magento OAuth Server Premium Plugin ";
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function send_notification_after_expiry()
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>Your 1 year license for Magento OAuth Server Premium Plugin has expired. You have not renewed your license within \xd
the 10 days grace period given to you. The SSO has been disabled on your website .<br><br>
Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expired - Magento OAuth Server Premium Plugin ";
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function user_limit_expired_notification($Wy)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>You have purchased license for Magento OAuth Server Plan for <b>" . $Wy . " users</b>. \xd
As number of users on your site have grown to more than " . $Wy . " users now, new users will not be able to use SSO capabilities for your site <br><br>
Please reach out to us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> or use the Support Form in the plugin to upgrade the license to continue using our plugin.\xd\xa <br><br>Thanks,<br>miniOrange";
$Y1 = "Exceeded License Limit For No Of Users - Magento OAuth Server Premium Plugin";
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_USER_EXCEEDED_ALERT_SENT, 0);
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function user_limit_expiring_soon_notification($Wy, $qk)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>You have purchased license for Magento OAuthServer Premium Plugin for <b>" . $Wy . " users</b>.
\xa As number of users on your site have grown to more than " . ($Wy - $qk) . " users now .You have left with " . $qk . " user for SSO
Please reach out to us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> or use the Support Form if you wish to upgrade the license.
\xa <br><br>Thanks,<br>miniOrange";
$Y1 = "Exceeded License Limit For No Of Users - Magento OAuth Server Premium Plugin";
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_USER_EXCEEDED_ALERT_SENT, $qk);
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function fetchLicense()
{
$this->log_debug("In function fetchLicense ");
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
$Wa = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), $hO);
$aB = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::SAML_IDP_LED), $hO);
$ox = json_decode($this->ccl(), true);
if ($ox["status"] == "SUCCESS") {
goto Xs;
}
$hO = $this->getStoreConfig(IDPConstants::TOKEN);
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data(0, $hO));
$this->setStoreConfig(IDPConstants::SAML_IDP_LED, AESEncryption::encrypt_data(strtotime("h0-00 00:00:p"), $hO));
goto ee;
Xs:
$ix = $ox["noOfUsers"];
$xY = strtotime($ox["licenseExpiry"]);
if (!($Wa == null || $Wa == 0 || empty($Wa))) {
goto KW;
}
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data($ix, $hO));
KW:
if (!($aB == null || $aB == 0 || empty($aB))) {
goto Yx;
}
$this->setStoreConfig(IDPConstants::SAML_IDP_LED, AESEncryption::encrypt_data($xY, $hO));
Yx:
$vU = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
$OI = $this->getcount();
if (!($vU == null || $vU == 0 || $vU != $OI)) {
goto ta;
}
$z6 = max($vU, $OI);
$this->setStoreConfig(IDPConstants::IDP_USERS_COUNT, AESEncryption::encrypt_data($z6, $hO));
ta:
if ($aB < strtotime($ox["licenseExpiry"])) {
goto Z1;
}
if ($Wa < $ox["noOfUsers"]) {
goto rZ;
}
goto Cm;
Z1:
$aB = strtotime($ox["licenseExpiry"]);
$this->setStoreConfig(IDPConstants::SAML_IDP_LED, AESEncryption::encrypt_data($aB, $hO));
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data($ix, $hO));
$this->setStoreConfig(IDPConstants::IDP_USERS_COUNT, AESEncryption::encrypt_data(0, $hO));
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, NULL);
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, NULL);
$ie = $this->resource->getConnection();
$Lj = $this->resource->getTableName("miniorange_oauth_server_users");
$ie->delete($Lj);
if (!$ie->tableColumnExists("customer_entity", "idp_user")) {
goto WM;
}
$ie->dropColumn("customer_entity", "idp_user");
WM:
$this->log_debug("updated expiry date: " . $ox["licenseExpiry"]);
$this->log_debug("updated users limit: " . $ix);
goto Cm;
rZ:
$this->setStoreConfig(IDPConstants::SAML_IDP_LED, AESEncryption::encrypt_data($aB, $hO));
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data($ix, $hO));
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, NULL);
Cm:
ee:
$this->flushCache();
$this->reinitConfig();
}
public function getcount()
{
$this->flushCache();
$this->reinitConfig();
$ie = $this->resource->getConnection();
$Lj = "customer_entity";
$aw = "idp_user";
$ym = $ie->describeTable($Lj);
if (isset($ym[$aw])) {
goto zo;
}
return 0;
goto UK;
zo:
$XA = $ie->select();
$XA->from($Lj, "COUNT(*)")->where($aw . " = ?", 1);
return (int) $ie->fetchOne($XA);
UK:
}
public function setCookie($uM, $TC, $VM)
{
$OC = $this->cookieMetadataFactory->createPublicCookieMetadata()->setDuration($VM)->setPath("/")->setHttpOnly(false);
$this->cookieManager->setPublicCookie($uM, $TC, $OC);
}
public function getCookie($uM)
{
return $this->cookieManager->getCookie($uM);
}
public function deleteCookie($uM)
{
$OC = $this->cookieMetadataFactory->createCookieMetadata();
$OC->setPath("/");
$this->cookieManager->deleteCookie($uM, $OC);
}
public function customlog($hy)
{
$this->isLogEnable() ? $this->_logger->debug($hy) : NULL;
}
public function isCustomLogExist()
{
if ($this->fileSystem->isExists("../var/log/mo_idp.log")) {
goto gR;
}
if ($this->fileSystem->isExists("var/log/mo_idp.log")) {
goto ge;
}
goto bn;
gR:
return 1;
goto bn;
ge:
return 1;
bn:
return 0;
}
public function deleteCustomLogFile()
{
if ($this->fileSystem->isExists("../var/log/mo_idp.log")) {
goto z8;
}
if ($this->fileSystem->isExists("var/log/mo_idp.log")) {
goto Gs;
}
goto BO;
z8:
$this->fileSystem->deleteFile("../var/log/mo_idp.log");
goto BO;
Gs:
$this->fileSystem->deleteFile("var/log/mo_idp.log");
BO:
}
public function getProductVersion()
{
return $this->productMetadata->getVersion();
}
public function isLogEnable()
{
return $this->getStoreConfig(IDPConstants::ENABLE_DEBUG_LOG);
}
public function getCurrentDate()
{
return $this->dateTime->gmtDate("Y-m-d H:i");
}
public function isExistingSSOUser($Y2, $MW = false)
{
$Y9 = $this->resource->getConnection()->select()->from($Y2)->where("entity_id='" . $MW . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function check_plan($EP)
{
return $this->get_versi() >= $EP;
}
public function get_versi()
{
$cr = IDPConstants::LICENSE_PLAN;
return $cr === "magento_saml_idp_trial_plan" ? 2 : ($cr === "magento_saml_idp_premium_plan" ? 1 : 0);
}
public function checkTrialExpiry()
{
if (!$this->isTrialExpired()) {
goto ZV;
}
$Ij = $this->customerSession->getId();
if (!$Ij) {
goto Pc;
}
$this->customerSession->logout();
Pc:
$this->messageManager->addErrorMessage("Your Demo account has expired. Please contact to magentosupport@xecurify.com");
$nZ = $this->urlBuilder->getUrl("customer/account/login");
$this->responseFactory->create()->setRedirect($nZ)->sendResponse();
exit;
ZV:
}
public function checkTrialUserLeft($user)
{
$hO = "E7XIXCVVUOYAIA2";
$DI = (int) AESEncryption::decrypt_data("Y3Vn", $hO);
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), $hO);
if ($gs > $DI) {
goto ws;
}
$this->log_debug("in addUserInList");
$Y2 = "customer_entity";
$oh = "idp_user";
$hs = 1;
$sU = $user->getId();
$this->updateColumnInTable($Y2, $oh, $hs, IDPConstants::COLUMN_ENTITY, $sU, $user);
goto kM;
ws:
$Ij = $this->customerSession->getId();
if (!$Ij) {
goto Mh;
}
$this->customerSession->logout();
Mh:
$this->messageManager->addErrorMessage("Your Demo account has expired. Please contact to magentosupport@xecurify.com");
$nZ = $this->urlBuilder->getUrl("customer/account/login");
$this->responseFactory->create()->setRedirect($nZ)->sendResponse();
exit;
kM:
}
}
namespace MiniOrange\IDPSaml\Helper;
use MiniOrange\IDPSaml\Helper\IDPConstants;
use MiniOrange\IDPSaml\Helper\Curl;
use MiniOrange\IDPSaml\Helper\Data;
use MiniOrange\IDPSaml\Helper\Saml2\Lib\AESEncryption;
use MiniOrange\IDPSaml\Helper\Saml2\SAML2Utilities;
use Psr\Log\LoggerInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\ResourceConnection;
use MiniOrange\IDPSaml\Model\OAuthServerUsersFactory;
use MiniOrange\IDPSaml\Model\MiniOrangeSpTableFactory;
use Magento\Framework\Stdlib\DateTime\DateTime;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\UrlInterface;
use DOMElement;
use DOMDocument;
use DOMNode;
use DOMXPath;
class IDPUtility extends Data
{
protected $adminSession;
protected $customerSession;
protected $authSession;
protected $cacheTypeList;
protected $cacheFrontendPool;
protected $fileSystem;
protected $reinitableConfig;
protected $userGroupModel;
protected $adminRoleModel;
protected $adminUserModel;
protected $customerModel;
protected $resource;
protected $logger;
protected $oauthServerUsers;
protected $miniOrangeOAuthClientsFactory;
protected $productMetadata;
protected $dateTime;
public $customerRepository;
protected $response;
protected $urlBuilder;
protected $responseFactory;
protected $messageManager;
public function __construct(ManagerInterface $Hr, \Magento\Framework\App\Config\ScopeConfigInterface $uI, \Magento\User\Model\UserFactory $RK, \Magento\Customer\Model\CustomerFactory $o2, \Magento\Framework\UrlInterface $L8, \Magento\Framework\App\Config\Storage\WriterInterface $FL, \Magento\Framework\View\Asset\Repository $pC, \Magento\Backend\Helper\Data $Db, \Magento\Framework\Url $xA, \Magento\Backend\Model\Session $sf, \Magento\Customer\Model\Session $d9, \Magento\Backend\Model\Auth\Session $dl, \Magento\Framework\App\Cache\TypeListInterface $GL, \Magento\Framework\App\Cache\Frontend\Pool $II, \Magento\Framework\Filesystem\Driver\File $MF, \Magento\Framework\App\Config\ReinitableConfigInterface $WE, \Magento\Customer\Model\ResourceModel\Group\Collection $kg, \Magento\Authorization\Model\ResourceModel\Role\Collection $w5, \Magento\User\Model\User $g2, \Magento\Customer\Model\Customer $VZ, \Magento\Framework\App\ResourceConnection $Fe, \MiniOrange\IDPSaml\Logger\Logger $Vg, OAuthServerUsersFactory $lz, MiniOrangeSpTableFactory $eq, \Magento\Framework\App\ProductMetadataInterface $nA, DateTime $TT, CustomerRepositoryInterface $ql, LoggerInterface $ce, UrlInterface $S7, ResponseInterface $WG, \Magento\Framework\App\ResponseFactory $Pd)
{
$this->adminSession = $sf;
$this->customerSession = $d9;
$this->authSession = $dl;
$this->cacheTypeList = $GL;
$this->cacheFrontendPool = $II;
$this->fileSystem = $MF;
$this->reinitableConfig = $WE;
$this->logger = $ce;
$this->customerModel = $VZ;
$this->userGroupModel = $kg;
$this->resource = $Fe;
$this->adminRoleModel = $w5;
$this->adminUserModel = $g2;
$this->_logger = $Vg;
$this->oauthServerUsers = $lz;
$this->miniOrangeOAuthClientsFactory = $eq;
$this->productMetadata = $nA;
$this->dateTime = $TT;
$this->customerRepository = $ql;
$this->messageManager = $Hr;
$this->urlBuilder = $S7;
$this->response = $WG;
$this->responseFactory = $Pd;
parent::__construct($uI, $RK, $o2, $L8, $FL, $pC, $Db, $xA, $lz, $eq, $TT, $nA);
}
public function getHiddenPhone($MZ)
{
$b7 = "xxxxxxx" . substr($MZ, strlen($MZ) - 3);
return $b7;
}
public function isBlank($TC)
{
if (!(!isset($TC) || empty($TC))) {
goto Hs;
}
return true;
Hs:
return false;
}
public function isCurlInstalled()
{
if (in_array("curl", get_loaded_extensions())) {
goto lH;
}
return 0;
goto nC;
lH:
return 1;
nC:
}
public function validatePhoneNumber($MZ)
{
if (!preg_match(MoIDPConstants::PATTERN_PHONE, $MZ, $SB)) {
goto Z_;
}
return true;
goto rR;
Z_:
return false;
rR:
}
public function getHiddenEmail($Wc)
{
if (!(!isset($Wc) || trim($Wc) === '')) {
goto wC;
}
return '';
wC:
$a4 = strlen($Wc);
$fo = substr($Wc, 0, 1);
$Qx = strrpos($Wc, "@");
$lH = substr($Wc, $Qx - 1, $a4);
$gS = 1;
dF:
if (!($gS < $Qx)) {
goto V0;
}
$fo = $fo . "x";
cw:
$gS++;
goto dF;
V0:
$dn = $fo . $lH;
return $dn;
}
public function setAdminSessionData("E7XIXCVVUOYAIA2", $TC)
{
return $this->adminSession->setData("E7XIXCVVUOYAIA2", $TC);
}
public function getAdminSessionData("E7XIXCVVUOYAIA2", $MI = false)
{
return $this->adminSession->getData("E7XIXCVVUOYAIA2", $MI);
}
public function setSessionData("E7XIXCVVUOYAIA2", $TC)
{
return $this->customerSession->setData("E7XIXCVVUOYAIA2", $TC);
}
public function getSessionData("E7XIXCVVUOYAIA2", $MI = false)
{
return $this->customerSession->getData("E7XIXCVVUOYAIA2", $MI);
}
public function unsetSessionData("E7XIXCVVUOYAIA2", $MI = false)
{
return $this->customerSession->unsetData("E7XIXCVVUOYAIA2", $MI);
}
public function setSessionDataForCurrentUser("E7XIXCVVUOYAIA2", $TC)
{
if ($this->customerSession->isLoggedIn()) {
goto Ei;
}
if ($this->authSession->isLoggedIn()) {
goto zj;
}
goto La;
Ei:
$this->setSessionData("E7XIXCVVUOYAIA2", $TC);
goto La;
zj:
$this->setAdminSessionData("E7XIXCVVUOYAIA2", $TC);
La:
}
public function isSPConfigured()
{
$PL = $this->getStoreConfig(IDPConstants::SAML_SSO_URL);
return $this->isBlank($PL) ? false : true;
}
public function micr()
{
$Wc = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
"E7XIXCVVUOYAIA2" = $this->getStoreConfig(IDPConstants::SAML_IDP_KEY);
return !$this->isBlank($Wc) && !$this->isBlank("E7XIXCVVUOYAIA2") ? true : false;
}
public function isUserLoggedIn()
{
return $this->customerSession->isLoggedIn() || $this->authSession->isLoggedIn();
}
public function getCurrentAdminUser()
{
return $this->authSession->getUser();
}
public function getCurrentUser()
{
$TV = \Magento\Framework\App\ObjectManager::getInstance();
$d9 = $TV->get("Magento\Customer\Model\Session");
$Qq = $d9->getCustomer()->getEmail();
return $d9->getCustomer();
}
public function getAcsUrl()
{
return $this->getStoreConfig(IDPConstants::SAML_SSO_URL);
}
public function getAdminLoginUrl()
{
return $this->getAdminUrl("adminhtml/auth/login");
}
public function getCustomerLoginUrl()
{
return $this->getUrl("customer/account/login");
}
public function getCustomer($ST)
{
return $this->customerRepository->getById($ST);
}
public function desanitizeCert($r3)
{
return SAML2Utilities::desanitize_certificate($r3);
}
public function sanitizeCert($r3)
{
return SAML2Utilities::sanitize_certificate($r3);
}
public function flushCache()
{
$WX = ["db_ddl"];
foreach ($WX as $bc) {
$this->cacheTypeList->cleanType($bc);
vm:
}
ed:
foreach ($this->cacheFrontendPool as $DR) {
$DR->getBackend()->clean();
Kl:
}
mT:
}
public function getFileContents($LK)
{
return $this->fileSystem->fileGetContents($LK);
}
public function putFileContents($LK, $Ti)
{
$this->fileSystem->filePutContents($LK, $Ti);
}
public function getAdminSession()
{
return $this->adminSession;
}
public function reinitConfig()
{
$this->reinitableConfig->reinit();
}
public function parseBoolean(DOMElement $y8, $pW, $fv = null)
{
if ($y8->hasAttribute($pW)) {
goto O2;
}
return $fv;
O2:
$TC = $y8->getAttribute($pW);
switch (strtolower($TC)) {
case "0":
case "false":
return FALSE;
case "1":
case "true":
return TRUE;
default:
throw new \Exception("Invalid value of boolean attribute " . var_export($pW, TRUE) . ": " . var_export($TC, TRUE));
}
Km:
hl:
}
public function xpQuery(DOMNode $y8, $Y9)
{
static $dJ = NULL;
if ($y8 instanceof DOMDocument) {
goto eZ;
}
$ky = $y8->ownerDocument;
goto Su;
eZ:
$ky = $y8;
Su:
if (!($dJ === NULL || !$dJ->document->isSameNode($ky))) {
goto es;
}
$dJ = new DOMXPath($ky);
$dJ->registerNamespace("soap-env", "http://schemas.xmlsoap.org/soap/envelope/");
$dJ->registerNamespace("saml_protocol", "urn:oasis:names:tc:SAML:2.0:protocol");
$dJ->registerNamespace("saml_assertion", "urn:oasis:names:tc:SAML:2p:assertion");
$dJ->registerNamespace("saml_metadata", "urn:oasis:names:tc:SAML:2.0:metadata");
$dJ->registerNamespace("ds", "http://www.w3.orgz0/09/xmldsig#");
$dJ->registerNamespace("xenc", "http://www.w3.orgz1/04/xmlenc#");
es:
$c_ = $dJ->query($Y9, $y8);
$We = array();
$gS = 0;
Pf:
if (!($gS < $c_->length)) {
goto WP;
}
$We[$gS] = $c_->item($gS);
CZ:
$gS++;
goto Pf;
WP:
return $We;
}
private function getRoleIdByName($bA)
{
$cO = $this->adminRoleModel->toOptionArray();
foreach ($cO as $fV) {
if (!($bA == $fV["label"])) {
goto oF;
}
return $fV["value"];
oF:
Hv:
}
nS:
}
private function getGroupIdByName($Mx)
{
$bx = $this->userGroupModel->toOptionArray();
foreach ($bx as $cV) {
if (!($Mx == $cV["label"])) {
goto jc;
}
return $cV["value"];
jc:
A1:
}
R1:
}
public function log_debug($w3 = '', $W6 = null)
{
if (is_object($w3)) {
goto oz;
}
$this->customlog("MO IDP SAML PLugin : " . $w3);
goto Tr;
oz:
$this->customlog("MO IDP SAML PLugin : " . print_r($W6, true));
Tr:
if (!($W6 != null)) {
goto Ik;
}
$this->customlog("MO IDP SAML PLugin : " . var_export($W6, true));
Ik:
}
public function checkIfUserLeft($user)
{
if ($this->cleu()) {
goto lh;
}
$this->log_debug("in addUserInList");
$hs = 1;
$sU = $user->getId();
$this->updateColumnInTable("customer_entity", "idp_user", $hs, IDPConstants::COLUMN_ENTITY, $sU, $user);
goto Qi;
lh:
$Ij = $this->customerSession->getId();
if (!$Ij) {
goto Zz;
}
$this->customerSession->logout();
Zz:
$this->messageManager->addErrorMessage("You have exceeded the User Limit Please contact your adminstrator.");
$nZ = $this->urlBuilder->getUrl("customer/account/login");
$this->responseFactory->create()->setRedirect($nZ)->sendResponse();
exit;
Qi:
}
public function cleu()
{
$this->flushCache();
"E7XIXCVVUOYAIA2" = $this->getStoreConfig(IDPConstants::TOKEN);
$SS = $this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT);
if (!($SS == null)) {
goto Bl;
}
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
Bl:
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), "E7XIXCVVUOYAIA2");
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), "E7XIXCVVUOYAIA2");
$qk = $DI - $gs;
$Bw = $DI / 10;
if ($qk <= $Bw && $qk > 10) {
goto ZB;
}
if ($qk <= 10 && $qk > 0) {
goto Is;
}
if ($qk < 0 && $qk > -(int) $Bw) {
goto MK;
}
if (!($qk <= -(int) $Bw)) {
goto p9;
}
$this->flushCache();
$J8 = $this->getStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT);
if (!($J8 == NULL || $J8 > -(int) $Bw)) {
goto CB;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), "E7XIXCVVUOYAIA2");
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), "E7XIXCVVUOYAIA2");
$qk = $DI - $gs;
if (!($qk <= -(int) $Bw)) {
goto PD;
}
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, $qk);
$this->suea($DI);
PD:
CB:
return true;
p9:
goto Yc;
MK:
$this->flushCache();
$J8 = $this->getStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT);
if (!($J8 == 0 || $J8 == NULL || $J8 > 0)) {
goto Yo;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), "E7XIXCVVUOYAIA2");
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), "E7XIXCVVUOYAIA2");
$qk = $DI - $gs;
if (!($qk < 0 && $qk > -(int) $Bw)) {
goto uf;
}
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, $qk);
$this->suea($DI);
uf:
Yo:
Yc:
goto Y6;
ZB:
$this->flushCache();
$J8 = $this->getStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT);
if (!($J8 == 0 || $J8 == NULL)) {
goto xZ;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), "E7XIXCVVUOYAIA2");
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), "E7XIXCVVUOYAIA2");
$qk = $DI - $gs;
$Bw = $DI / 10;
if (!($qk <= $Bw && $qk > 10)) {
goto UA;
}
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, $qk);
$this->sue($DI, $qk);
UA:
xZ:
goto Y6;
Is:
$this->flushCache();
$J8 = $this->getStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT);
if (!($J8 == 0 || $J8 == NULL || $J8 > 10)) {
goto WZ;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), "E7XIXCVVUOYAIA2");
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), "E7XIXCVVUOYAIA2");
$qk = $DI - $gs;
if (!($qk <= 10 && $qk > 0)) {
goto LN;
}
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, $qk);
$this->sue($DI, $qk);
LN:
WZ:
Y6:
return false;
}
public function suea($Wy)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>You have purchased license for miniOrange Magento IDP Plugin for <b>" . $Wy . " users</b>. \xd
\x9 \x9\x9s number of users on your site have grown to more than " . $Wy . " users now, new users will not be able to use SSO capabilities for your site <br><br>
\xa\x9\x9 \x9\x9 Please reach out to us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> or use the Support Form in the plugin to upgrade the license to continue using our plugin.
\xa \x9 \x9\x9\x9<br><br>Thanks,<br>miniOrange";
$Y1 = "Exceeded License Limit For No Of Users - Magento IDP Plugin";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function sue($Wy, $qk)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>You have purchased license for miniOrange Magento IDP Plugin for <b>" . $Wy . " users</b>. \xd\xa \x9\x9 \x9 As number of users on your site have grown to more than " . ($Wy - $qk) . " users now .You have left with " . $qk . " user for SSO
\xa\x9 \x9\x9\x9Please reach out to us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> or use the Support Form if you wish to upgrade the license.
\x9\x9\x9 \x9 <br><br>Thanks,<br>miniOrange";
$Y1 = "Exceeded License Limit For No Of Users - Magento IDP Plugin";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function ccl()
{
$sK = $this->getStoreConfig(IDPConstants::SAML_IDP_KEY);
$Ua = $this->getStoreConfig(IDPConstants::API_KEY);
$Ib = Curl::ccl($sK, $Ua);
return $Ib;
}
public function checkIfValidLicense()
{
if (!($this->cled() <= -10)) {
goto nv;
}
$Ij = $this->customerSession->getId();
if (!$Ij) {
goto IX;
}
$this->customerSession->logout();
IX:
$this->messageManager->addErrorMessage("Your License is expired Please contact your adminstrator.");
$nZ = $this->urlBuilder->getUrl("customer/account/login");
$this->responseFactory->create()->setRedirect($nZ)->sendResponse();
exit;
nv:
}
public function cled()
{
"E7XIXCVVUOYAIA2" = $this->getStoreConfig(IDPConstants::TOKEN);
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = null;
if ($aB == null) {
goto y3;
}
$NX = AESEncryption::decrypt_data($aB, "E7XIXCVVUOYAIA2");
goto r0;
y3:
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
r0:
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= 30)) {
goto iH;
}
$this->flushCache();
$this->reinitConfig();
$vT = $this->getStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT);
if ($Di > 7) {
goto yy;
}
if ($Di <= 7 && $Di > 0) {
goto eX;
}
if ($Di < 0 && $Di > -10) {
goto OY;
}
if (!($Di <= -10)) {
goto q7;
}
if (!($vT == 0 || $vT == null || $vT > -10)) {
goto Z4;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = AESEncryption::decrypt_data($aB, "E7XIXCVVUOYAIA2");
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= -10)) {
goto Li;
}
$this->spdae();
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, $Di);
Li:
Z4:
q7:
goto kv;
OY:
if (!($vT == 0 || $vT == null || $vT > 0)) {
goto N4;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = AESEncryption::decrypt_data($aB, "E7XIXCVVUOYAIA2");
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di < 0 && $Di > -10)) {
goto WB;
}
$this->slrfae();
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, $Di);
WB:
N4:
kv:
goto gr;
eX:
if (!($vT == 0 || $vT == null || $vT > 7)) {
goto Nm;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = AESEncryption::decrypt_data($aB, "E7XIXCVVUOYAIA2");
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= 7 && $Di > 0)) {
goto Zv;
}
$this->slrae($Di);
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, $Di);
Zv:
Nm:
gr:
goto vW;
yy:
if (!($vT == 0 || $vT == null)) {
goto vF;
}
$this->log_debug("Inside function is used to check active users");
$this->fetchLicense();
$this->flushCache();
$this->reinitConfig();
$aB = $this->getStoreConfig(IDPConstants::SAML_IDP_LED);
$NX = AESEncryption::decrypt_data($aB, "E7XIXCVVUOYAIA2");
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= 30 && $Di > 7)) {
goto ad;
}
$this->slrae($Di);
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, $Di);
ad:
vF:
vW:
iH:
return $Di;
}
public function slrae($le)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>This email is to notify you that your 1 year license for Magento IDP Plugin will expire
\x9\x9 \x9in " . $le . " days. The plugin will stop working after the licensed period expires.<br><br>
\x9 You will need to renew your license to continue using the plugin on your website .\xd
\x9\x9<br><br>Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "Magento IDP Plugin License will expire in " . $le . " days.";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function slrfae()
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>Your 1 year license for Magento IDP Plugin has expired for your website . \xd
\x9\x9 The plugin will stop working soon.<br><br>You will need to renew your license to continue using the plugin.You have0 days grace period to renew your licence after that your SSO will be disabled on your website\xd\xa\x9\x9\x9 \x9 Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expired - Magento IDP Plugin ";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function spdae()
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::SAML_IDP_EMAIL);
$Ib = "Hello,<br><br>Your year license for Magento IDP Plugin has expired. You have not renewed your license within
\xa \x9 \x9the 10 days grace period given to you. The SSO has been disabled on your website .<br><br>
\x9 \x9\x9ontact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expired - Magento IDP Plugin ";
CURL::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function vml($Tv)
{
$sK = $this->getStoreConfig(IDPConstants::SAML_IDP_KEY);
$Ua = $this->getStoreConfig(IDPConstants::API_KEY);
$Ib = Curl::vml($sK, $Ua, $Tv, $this->getBaseUrl());
return $Ib;
}
public function mius()
{
$sK = $this->getStoreConfig(IDPConstants::SAML_IDP_KEY);
$Ua = $this->getStoreConfig(IDPConstants::API_KEY);
$q2 = $this->getStoreConfig(IDPConstants::TOKEN);
$Tv = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::SAML_IDP_LK), $q2);
$Ib = Curl::mius($sK, $Ua, $Tv);
return $Ib;
}
public function mclv()
{
$q2 = $this->getStoreConfig(IDPConstants::TOKEN);
$Ku = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::SAML_IDP_CKL), $q2);
$EZ = $this->getStoreConfig(IDPConstants::SAML_IDP_LK);
return $Ku == "true" && !$this->isBlank($EZ) ? TRUE : FALSE;
}
public function addUserInList($user)
{
$this->log_debug("in addUserInList");
if (!$this->cleu()) {
goto AJ;
}
$hs = 1;
$sU = $user->getId();
$this->updateColumnInTable("customer_entity", "idp_user", $hs, IDPConstants::COLUMN_ENTITY, $sU, $user);
AJ:
}
public function updateColumnInTable("customer_entity", $x8, $OZ, $fW, $Y6, $user)
{
$this->log_debug("Updating colum in table");
$ie = $this->resource->getConnection();
if (!($ie->tableColumnExists("customer_entity", $x8) === false)) {
goto Ht;
}
$ie->addColumn("customer_entity", $x8, array("type" => "text", "nullable" => false, "length" => 255, "after" => null, "comment" => $x8));
Ht:
$this->log_debug("User does not exist");
$this->resource->getConnection()->update("customer_entity", [$x8 => $OZ], [$fW . " = ?" => $Y6]);
$this->flushCache();
if ($this->check_plan(2)) {
goto uu;
}
"E7XIXCVVUOYAIA2" = $this->getStoreConfig(IDPConstants::TOKEN);
goto J4;
uu:
J4:
$vU = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), "E7XIXCVVUOYAIA2");
$OI = $this->getcount();
$sA = max($vU, $OI);
$this->log_debug("before count: ", $sA);
$sA = $sA + 1;
$sA = AESEncryption::encrypt_data($sA, "E7XIXCVVUOYAIA2");
$this->setStoreConfig(IDPConstants::IDP_USERS_COUNT, $sA);
$this->reinitConfig();
$this->log_debug("after count: ", $this->getStoreConfig(IDPConstants::IDP_USERS_COUNT));
}
public function getRemainingUsersCount()
{
$this->flushCache();
$this->reinitConfig();
"E7XIXCVVUOYAIA2" = $this->getStoreConfig(IDPConstants::TOKEN);
$DI = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), "E7XIXCVVUOYAIA2");
$vU = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), "E7XIXCVVUOYAIA2");
$OI = $this->getcount();
$gs = max($vU, $OI);
$this->setStoreConfig(IDPConstants::IDP_USERS_COUNT, AESEncryption::encrypt_data($gs, "E7XIXCVVUOYAIA2"));
$qk = $DI - $gs;
return $qk;
}
public function getFieldNames()
{
$nP = $this->resource->getConnection()->describeTable("customer_entity");
return $nP;
}
public function getMoTfaUserDetails("customer_entity")
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity", ["sp_name"]);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getAllid("customer_entity")
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity", ["id"]);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getAllRedirectUri("customer_entity")
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity", ["redirect_url"]);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getAllissuer("customer_entity")
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity", ["issuer"]);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetails("customer_entity", $Y0 = false)
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity")->where("sp_name='" . $Y0 . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetailsusingid("customer_entity", $ST = false)
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity")->where("id='" . $ST . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetailsusingRedirectUri("customer_entity", $pj = false)
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity")->where("redirect_url='" . $pj . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetailsusingredirecturl("customer_entity", $ST = false)
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity")->where("id='" . $ST . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function fetchspallDetailsusingIssuer("customer_entity", $cZ = false)
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity")->where("issuer='" . $cZ . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function deleteRowInTable("customer_entity", $fW, $Y6)
{
$K5 = $this->resource->getConnection();
$Ah = "DELETE FROM customer_entity WHERE " . $fW . "=" . $Y6;
$K5->exec($Ah);
}
public function getissuer("customer_entity", $nE = false)
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity", ["acs_url"])->where("issuer='" . $nE . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getacs("customer_entity", $cZ = false)
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity", ["acs_url"])->where("issuer='" . $cZ . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function getslo("customer_entity", $nE = false)
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity", ["logout_url"])->where("issuer='" . $nE . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function insertRowInTable("customer_entity", $Ti)
{
$this->resource->getConnection()->insertMultiple("customer_entity", $Ti);
}
public function updateColumn("customer_entity", $x8, $OZ, $fW, $Y6)
{
$this->log_debug("updateColumnInTable " . $x8);
$ie = $this->resource->getConnection();
if (!($ie->tableColumnExists("customer_entity", $x8) === false)) {
goto sm;
}
$ie->addColumn("customer_entity", $x8, array("type" => "text", "nullable" => false, "length" => 255, "after" => null, "comment" => $x8));
sm:
$this->resource->getConnection()->update("customer_entity", [$x8 => $OZ], [$fW . " = ?" => $Y6]);
}
public function isOAuthServerConfigured()
{
$PL = $this->getStoreConfig(IDPConstants::AUTHORIZE_URL);
return $this->isBlank($PL) ? false : true;
}
public function generateRandom($B5 = 30)
{
$ms = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ036789";
$UY = strlen($ms);
$iM = '';
$gS = 0;
uU:
if (!($gS < $B5)) {
goto ww;
}
$iM .= $ms[rand(0, $UY - 1)];
c8:
$gS++;
goto uU;
ww:
return $iM;
}
public function oauthserver_server_sso_validate_code($Tv, $zG, $T7)
{
$s6 = time();
if (!($s6 - $T7 >= 400)) {
goto tq;
}
return "Your authentication code has expired. Please try again.";
tq:
if (!($Tv != $zG)) {
goto B0;
}
return "Incorrect Code";
B0:
}
public function oauthserver_server_sso_validate_grant($sG)
{
if (!($sG != "authorization_code")) {
goto C2;
}
return "Only Authorization Code grant type supported";
C2:
}
public function oauthserver_server_sso_validate_redirectUrl($pj, $OW)
{
if ($OW != '' && $pj != '') {
goto Bw;
}
return "Redirect URL is not configured";
goto eB;
Bw:
if (!($pj != $OW)) {
goto KH;
}
return "Redirect URL mismatch";
KH:
eB:
}
public function ValidateAccessToken($T7)
{
$s6 = time();
if (!($s6 - $T7 >= 900)) {
goto Ul;
}
return true;
Ul:
}
public function validateClient($N8, $qW, $OW, $wK, $Kr)
{
if (!(trim($N8) != trim($qW) || trim($OW) != trim($wK) || $Kr != "code")) {
goto Uu;
}
return "Invalid Client";
Uu:
}
public function update_status($Tv)
{
$sK = $this->getStoreConfig(IDPConstants::CUSTOMER_KEY);
$Ua = $this->getStoreConfig(IDPConstants::API_KEY);
$Ib = Curl::update_status($sK, $Ua, $Tv, $this->getBaseUrl());
return $Ib;
}
public function oauth_server_sso_validate_clientId($sg, $N8)
{
if (!empty($sg) && !empty($N8)) {
goto SM;
}
return "Client ID missing. To fix the issue, please send Client ID from your OAuth Client.";
goto MS;
SM:
if (!($N8 != $sg)) {
goto bV;
}
return "Incorrect Client ID";
bV:
MS:
}
public function oauth_server_sso_validate_clientSecret($TA, $tZ)
{
if (!empty($TA) && !empty($tZ)) {
goto B_;
}
return "Client Secret missing. To fix the issue, please send Client Secret from your OAuth Client.";
goto ai;
B_:
if (!($TA != $tZ)) {
goto MU;
}
return "Incorrect Client Secret";
MU:
ai:
}
public function getEavAttrFieldNames()
{
$Y9 = $this->resource->getConnection()->select()->from("eav_attribute", ["attribute_code", "frontend_label"])->where("entity_type_id = ?", 1)->orWhere("entity_type_id = ?", 2);
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function check_license_expiry_date()
{
"E7XIXCVVUOYAIA2" = $this->getStoreConfig(IDPConstants::TOKEN);
$aB = $this->getStoreConfig(IDPConstants::LICENSE_EXPIRY_DATE);
$NX = null;
if ($aB == null) {
goto Ql;
}
$NX = AESEncryption::decrypt_data($aB, "E7XIXCVVUOYAIA2");
goto uT;
Ql:
$Ib = json_decode(self::ccl(), true);
$P1 = array_key_exists("noOfUsers", $Ib) ? $Ib["noOfUsers"] : null;
$NX = array_key_exists("licenseExpiry", $Ib) ? strtotime($Ib["licenseExpiry"]) === false ? null : strtotime($Ib["licenseExpiry"]) : null;
if ($this->isBlank($P1)) {
goto EP;
}
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data($P1, "E7XIXCVVUOYAIA2"));
EP:
if ($this->isBlank($NX)) {
goto im;
}
$this->setStoreConfig(IDPConstants::LICENSE_EXPIRY_DATE, AESEncryption::encrypt_data($NX, "E7XIXCVVUOYAIA2"));
im:
uT:
$o1 = new \DateTime("@{$NX}");
$f5 = new \DateTime();
$Di = $f5->diff($o1)->format("%r%a");
if (!($Di <= 30)) {
goto wR;
}
$this->flushCache();
$vT = $this->getStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT);
if ($Di > 7) {
goto Gg;
}
if ($Di <= 7 && $Di > 0) {
goto zm;
}
if ($Di <= 0 && $Di > -10) {
goto ob;
}
if ($Di <= -10) {
goto eI;
}
goto o6;
Gg:
if (!($vT == null)) {
goto NU;
}
$this->send_notification_before_expiry($Di);
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT, $Di);
NU:
goto o6;
zm:
if (!($vT == null || $vT > 7)) {
goto gv;
}
$this->send_notification_before_expiry($Di);
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT, $Di);
gv:
goto o6;
ob:
if (!($vT == null || $vT > -1)) {
goto ly;
}
$this->send_notification_after_expiry_with_grace();
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT, $Di);
ly:
goto o6;
eI:
if (!($vT == null || $vT >= 0)) {
goto Aw;
}
$this->send_notification_after_expiry();
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_LICENSE_ALERT_SENT, 0);
Aw:
o6:
wR:
return $Di;
}
public function send_notification_before_expiry($le)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>This email is to notify you that your 1 year license for Magento OAuth Server Premium Plugin will expire
in " . $le . " days. The plugin will stop working after the licensed period expires.<br><br>
You need to renew your license to continue using the service.\xd
<br><br>Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expiry - Magento OAuth Server Premium Plugin";
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function send_notification_after_expiry_with_grace()
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>Your 1 year license for Magento OAuth Server Premium Plugin has expired for your website . \xd\xa The plugin will stop working soon.<br><br>You will need to renew your license to continue using the plugin.You have 10 days grace period to renew your licence after that your SSO will be disabled on your website
Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expired - Magento OAuth Server Premium Plugin ";
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function send_notification_after_expiry()
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>Your 1 year license for Magento OAuth Server Premium Plugin has expired. You have not renewed your license within \xd
the 10 days grace period given to you. The SSO has been disabled on your website .<br><br>
Contact us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> if you wish to renew your license.<br><br>Thanks,<br>miniOrange";
$Y1 = "License Expired - Magento OAuth Server Premium Plugin ";
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function user_limit_expired_notification($Wy)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>You have purchased license for Magento OAuth Server Plan for <b>" . $Wy . " users</b>. \xd
As number of users on your site have grown to more than " . $Wy . " users now, new users will not be able to use SSO capabilities for your site <br><br>
Please reach out to us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> or use the Support Form in the plugin to upgrade the license to continue using our plugin.\xd\xa <br><br>Thanks,<br>miniOrange";
$Y1 = "Exceeded License Limit For No Of Users - Magento OAuth Server Premium Plugin";
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_USER_EXCEEDED_ALERT_SENT, 0);
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function user_limit_expiring_soon_notification($Wy, $qk)
{
$sK = IDPConstants::DEFAULT_CUSTOMER_KEY;
$Ua = IDPConstants::DEFAULT_API_KEY;
$uh = $this->getStoreConfig(IDPConstants::CUSTOMER_EMAIL);
$Ib = "Hello,<br><br>You have purchased license for Magento OAuthServer Premium Plugin for <b>" . $Wy . " users</b>.
\xa As number of users on your site have grown to more than " . ($Wy - $qk) . " users now .You have left with " . $qk . " user for SSO
Please reach out to us at <a href='mailto:magentosupport@xecurify.com'>magentosupport@xecurify.com</a> or use the Support Form if you wish to upgrade the license.
\xa <br><br>Thanks,<br>miniOrange";
$Y1 = "Exceeded License Limit For No Of Users - Magento OAuth Server Premium Plugin";
$this->setStoreConfig(IDPConstants::OAUTH_SERVER_USER_EXCEEDED_ALERT_SENT, $qk);
Curl::notify($sK, $Ua, $uh, $Ib, $Y1);
}
public function fetchLicense()
{
$this->log_debug("In function fetchLicense ");
"E7XIXCVVUOYAIA2" = $this->getStoreConfig(IDPConstants::TOKEN);
$Wa = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_LIMIT), "E7XIXCVVUOYAIA2");
$aB = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::SAML_IDP_LED), "E7XIXCVVUOYAIA2");
$ox = json_decode($this->ccl(), true);
if ($ox["status"] == "SUCCESS") {
goto Xs;
}
"E7XIXCVVUOYAIA2" = $this->getStoreConfig(IDPConstants::TOKEN);
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data(0, "E7XIXCVVUOYAIA2"));
$this->setStoreConfig(IDPConstants::SAML_IDP_LED, AESEncryption::encrypt_data(strtotime("h0-00 00:00:p"), "E7XIXCVVUOYAIA2"));
goto ee;
Xs:
$ix = $ox["noOfUsers"];
$xY = strtotime($ox["licenseExpiry"]);
if (!($Wa == null || $Wa == 0 || empty($Wa))) {
goto KW;
}
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data($ix, "E7XIXCVVUOYAIA2"));
KW:
if (!($aB == null || $aB == 0 || empty($aB))) {
goto Yx;
}
$this->setStoreConfig(IDPConstants::SAML_IDP_LED, AESEncryption::encrypt_data($xY, "E7XIXCVVUOYAIA2"));
Yx:
$vU = AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), "E7XIXCVVUOYAIA2");
$OI = $this->getcount();
if (!($vU == null || $vU == 0 || $vU != $OI)) {
goto ta;
}
$z6 = max($vU, $OI);
$this->setStoreConfig(IDPConstants::IDP_USERS_COUNT, AESEncryption::encrypt_data($z6, "E7XIXCVVUOYAIA2"));
ta:
if ($aB < strtotime($ox["licenseExpiry"])) {
goto Z1;
}
if ($Wa < $ox["noOfUsers"]) {
goto rZ;
}
goto Cm;
Z1:
$aB = strtotime($ox["licenseExpiry"]);
$this->setStoreConfig(IDPConstants::SAML_IDP_LED, AESEncryption::encrypt_data($aB, "E7XIXCVVUOYAIA2"));
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data($ix, "E7XIXCVVUOYAIA2"));
$this->setStoreConfig(IDPConstants::IDP_USERS_COUNT, AESEncryption::encrypt_data(0, "E7XIXCVVUOYAIA2"));
$this->setStoreConfig(IDPConstants::IDP_LICENSE_ALERT_SENT, NULL);
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, NULL);
$ie = $this->resource->getConnection();
"customer_entity" = $this->resource->getTableName("miniorange_oauth_server_users");
$ie->delete("customer_entity");
if (!$ie->tableColumnExists("customer_entity", "idp_user")) {
goto WM;
}
$ie->dropColumn("customer_entity", "idp_user");
WM:
$this->log_debug("updated expiry date: " . $ox["licenseExpiry"]);
$this->log_debug("updated users limit: " . $ix);
goto Cm;
rZ:
$this->setStoreConfig(IDPConstants::SAML_IDP_LED, AESEncryption::encrypt_data($aB, "E7XIXCVVUOYAIA2"));
$this->setStoreConfig(IDPConstants::IDP_USERS_LIMIT, AESEncryption::encrypt_data($ix, "E7XIXCVVUOYAIA2"));
$this->setStoreConfig(IDPConstants::IDP_USER_EXCEEDED_ALERT_SENT, NULL);
Cm:
ee:
$this->flushCache();
$this->reinitConfig();
}
public function getcount()
{
$this->flushCache();
$this->reinitConfig();
$ie = $this->resource->getConnection();
$ym = $ie->describeTable("customer_entity");
if (isset($ym["idp_user"])) {
goto zo;
}
return 0;
goto UK;
zo:
$XA = $ie->select();
$XA->from("customer_entity", "COUNT(*)")->where("idp_user = ?", 1);
return (int) $ie->fetchOne($XA);
UK:
}
public function setCookie($uM, $TC, $VM)
{
$OC = $this->cookieMetadataFactory->createPublicCookieMetadata()->setDuration($VM)->setPath("/")->setHttpOnly(false);
$this->cookieManager->setPublicCookie($uM, $TC, $OC);
}
public function getCookie($uM)
{
return $this->cookieManager->getCookie($uM);
}
public function deleteCookie($uM)
{
$OC = $this->cookieMetadataFactory->createCookieMetadata();
$OC->setPath("/");
$this->cookieManager->deleteCookie($uM, $OC);
}
public function customlog($hy)
{
$this->isLogEnable() ? $this->_logger->debug($hy) : NULL;
}
public function isCustomLogExist()
{
if ($this->fileSystem->isExists("../var/log/mo_idp.log")) {
goto gR;
}
if ($this->fileSystem->isExists("var/log/mo_idp.log")) {
goto ge;
}
goto bn;
gR:
return 1;
goto bn;
ge:
return 1;
bn:
return 0;
}
public function deleteCustomLogFile()
{
if ($this->fileSystem->isExists("../var/log/mo_idp.log")) {
goto z8;
}
if ($this->fileSystem->isExists("var/log/mo_idp.log")) {
goto Gs;
}
goto BO;
z8:
$this->fileSystem->deleteFile("../var/log/mo_idp.log");
goto BO;
Gs:
$this->fileSystem->deleteFile("var/log/mo_idp.log");
BO:
}
public function getProductVersion()
{
return $this->productMetadata->getVersion();
}
public function isLogEnable()
{
return $this->getStoreConfig(IDPConstants::ENABLE_DEBUG_LOG);
}
public function getCurrentDate()
{
return $this->dateTime->gmtDate("Y-m-d H:i");
}
public function isExistingSSOUser("customer_entity", $MW = false)
{
$Y9 = $this->resource->getConnection()->select()->from("customer_entity")->where("entity_id='" . $MW . "'");
$s4 = $this->resource->getConnection()->fetchAll($Y9);
return $s4;
}
public function check_plan($EP)
{
return $this->get_versi() >= $EP;
}
public function get_versi()
{
$cr = IDPConstants::LICENSE_PLAN;
return $cr === "magento_saml_idp_trial_plan" ? 2 : ($cr === "magento_saml_idp_premium_plan" ? 1 : 0);
}
public function checkTrialExpiry()
{
if (!$this->isTrialExpired()) {
goto ZV;
}
$Ij = $this->customerSession->getId();
if (!$Ij) {
goto Pc;
}
$this->customerSession->logout();
Pc:
$this->messageManager->addErrorMessage("Your Demo account has expired. Please contact to magentosupport@xecurify.com");
$nZ = $this->urlBuilder->getUrl("customer/account/login");
$this->responseFactory->create()->setRedirect($nZ)->sendResponse();
exit;
ZV:
}
public function checkTrialUserLeft($user)
{
$DI = (int) AESEncryption::decrypt_data("Y3Vn", "E7XIXCVVUOYAIA2");
$gs = (int) AESEncryption::decrypt_data($this->getStoreConfig(IDPConstants::IDP_USERS_COUNT), "E7XIXCVVUOYAIA2");
if ($gs > $DI) {
goto ws;
}
$this->log_debug("in addUserInList");
$hs = 1;
$sU = $user->getId();
$this->updateColumnInTable("customer_entity", "idp_user", $hs, IDPConstants::COLUMN_ENTITY, $sU, $user);
goto kM;
ws:
$Ij = $this->customerSession->getId();
if (!$Ij) {
goto Mh;
}
$this->customerSession->logout();
Mh:
$this->messageManager->addErrorMessage("Your Demo account has expired. Please contact to magentosupport@xecurify.com");
$nZ = $this->urlBuilder->getUrl("customer/account/login");
$this->responseFactory->create()->setRedirect($nZ)->sendResponse();
exit;
kM:
}
}
© 2023 Quttera Ltd. All rights reserved.