55 $this->
setError(
'Error: WLL_User: Null timestamp.');
59 if (!preg_match(
'/^\d+$/', $timestamp) || ($timestamp <= 0)) {
61 $this->
setError(
'Error: WLL_User: Invalid timestamp: ' . $timestamp);
65 $this->_timestamp = $timestamp;
88 $this->
setError(
'Error: WLL_User: Null id.');
92 if (!preg_match(
'/^\w+$/', $id)) {
94 $this->
setError(
'Error: WLL_User: Invalid id: ' . $id);
120 $this->_usePersistentCookie =
false;
121 if (preg_match(
'/^\d+$/', $flags)) {
122 $this->_usePersistentCookie = (($flags % 2) == 1);
168 $this->_token = $token;
176 $this->_error =
$str;
181 if ($this->_error !==
false)
204 return (($now-300) < $this->
getExpiry());
215 $ct = $wll->refreshConsentToken($this);
232 $wll, $delegationtoken, $refreshtoken,
233 $sessionkey, $expiry, $offers, $locationID,
$context,
234 $decodedtoken, $token
267 if (!$delegationtoken) {
269 $this->
setError(
'Error: WLL_ConsentToken: Null delegation token.');
272 $this->_delegationtoken = $delegationtoken;
293 $this->_refreshtoken = $refreshtoken;
316 $this->
setError(
'Error: WLL_ConsentToken: Null session key.');
319 $this->_sessionkey = base64_decode(urldecode($sessionkey));
342 $this->
setError(
'Error: WLL_ConsentToken: Null expiry time.');
346 if (!preg_match(
'/^\d+$/', $expiry) || ($expiry <= 0)) {
348 $this->
setError(
'Error: WLL_ConsentToken: Invalid expiry time: ' . $expiry);
351 $this->_expiry = $expiry;
387 $this->
setError(
'Error: WLL_ConsentToken: Null offers.');
391 $offers = urldecode($offers);
394 if(preg_match_all(
"/(^|;)([^:;]*)/", $offers, $arMatch))
396 $this->_offers = $arMatch[2];
397 $this->_offers_string = ltrim(implode(
",", $arMatch[2]),
",");
401 $this->_offers =
array();
402 $this->_offers_string =
"";
425 $this->
setError(
'Error: WLL_ConsentToken: Null Location ID.');
428 $this->_locationID = $locationID;
469 $this->_decodedtoken = $decodedtoken;
490 $this->_token = $token;
499 $this->_delegationtoken = $ct->_delegationtoken;
500 $this->_refreshtoken = $ct->_refreshtoken;
501 $this->_sessionkey = $ct->_sessionkey;
502 $this->_expiry = $ct->_expiry;
503 $this->_offers = $ct->_offers;
504 $this->_offers_string = $ct->_offers_string;
505 $this->_locationID = $ct->_locationID;
506 $this->_decodedtoken = $ct->_decodedtoken;
507 $this->_token = $ct->_token;
514 $this->_error =
$str;
519 if ($this->_error !==
false)
541 $this->_debug = $debug;
565 $this->
debug($string);
594 $appid=
null, $secret=
null, $securityalgorithm=
null,
595 $force_delauth_nonprovisioned=
null,
596 $policyurl=
null, $returnurl=
null
607 if ($securityalgorithm) {
643 $settings = $o->parseSettings($settingsFile);
652 if (@
$settings[
'force_delauth_nonprovisioned'] ==
'true') {
653 $o->setForceDelAuthNonProvisioned(
true);
656 $o->setForceDelAuthNonProvisioned(
false);
661 $o->setOldSecret(@
$settings[
'oldsecret']);
662 $o->setOldSecretExpiry(@
$settings[
'oldsecretexpiry']);
663 $o->setSecurityAlgorithm(@
$settings[
'securityalgorithm']);
664 $o->setPolicyUrl(@
$settings[
'policyurl']);
665 $o->setReturnUrl(@
$settings[
'returnurl']);
667 $o->setSecureUrl(@
$settings[
'secureurl']);
668 $o->setConsentBaseUrl(@
$settings[
'consenturl']);
687 $this->
fatal(
'Error: setAppId: Null application ID.');
689 if (!preg_match(
'/^\w+$/', $appid)) {
690 $this->
fatal(
"Error: setAppId: Application ID must be alpha-numeric: $appid");
692 $this->_appid = $appid;
701 if (!$this->_appid) {
702 $this->
fatal(
'Error: getAppId: Application ID was not set. Aborting.');
720 if (!$secret || (strlen($secret) < 16)) {
724 $this->
fatal(
"Error: setSecret: Secret key is expected to be non-null and longer than 16 characters.");
727 $this->_signkey = $this->
derive($secret,
"SIGNATURE");
728 $this->_cryptkey = $this->
derive($secret,
"ENCRYPTION");
756 if (strlen($secret) < 16) {
757 $this->
fatal(
"Error: setOldSecret: Secret key is expected to be non-null and longer than 16 characters.");
760 $this->_oldsignkey = $this->
derive($secret,
"SIGNATURE");
761 $this->_oldcryptkey = $this->
derive($secret,
"ENCRYPTION");
783 if (!preg_match(
'/^\d+$/', $timestamp) || ($timestamp <= 0)) {
784 $this->
fatal(
'Error: setOldSecretExpiry Invalid timestamp: '
788 $this->_oldsecretexpiry = $timestamp;
809 $this->_securityalgorithm = $securityalgorithm;
819 if (!$securityalgorithm) {
822 return $securityalgorithm;
836 $this->_force_delauth_nonprovisioned = $force_delauth_nonprovisioned;
851 $this->
fatal(
"Error: setPolicyUrl: Null policy URL given.");
854 $this->_policyurl = $policyurl;
866 $this->
debug(
"Warning: In the initial release of Delegated Auth, a Policy URL must be configured in the SDK for both provisioned and non-provisioned scenarios.");
867 if ($_force_delauth_nonprovisioned) {
868 $this->
fatal(
"Error: getPolicyUrl: Policy URL must be set in a Del Auth non-provisioned scenario. Aborting.");
890 $this->
fatal(
"Error: setReturnUrl: Null return URL given.");
893 $this->_returnurl = $returnurl;
906 $this->
fatal(
"Error: getReturnUrl: Return URL must be set in a Del Auth non-provisioned scenario. Aborting.");
924 $this->_baseurl = $baseurl;
938 return "http://login.live.com/";
953 $this->_secureurl = $secureurl;
965 return "https://login.live.com/";
980 $this->_consenturl = $consenturl;
992 return "https://consent.live.com/";
1013 $url .= ($market ?
'&mkt=' . urlencode($market) :
'');
1026 $url .= ($market ?
'&mkt=' . urlencode($market) :
'');
1043 $this->
debug(
"Warning: processLogin: query action ignored: $action");
1046 $token = @
$query[
'stoken'];
1060 $this->
debug(
'Error: processToken: Invalid token specified.');
1065 if (!$decodedToken) {
1066 $this->
debug(
"Error: processToken: Failed to decode/validate token: $token");
1070 $parsedToken = $this->
parse($decodedToken);
1071 if (!$parsedToken) {
1072 $this->
debug(
"Error: processToken: Failed to parse token after decoding: $token");
1077 $tokenappid = @$parsedToken[
'appid'];
1078 if ($appid != $tokenappid) {
1079 $this->
debug(
"Error: processToken: Application ID in token did not match ours: $tokenappid, $appid");
1086 $user =
new WLL_User(@$parsedToken[
'ts'],
1087 @$parsedToken[
'uid'],
1088 @$parsedToken[
'flags'],
1091 if ($user->getError() !==
false)
1092 $this->
debug(
"Error: processToken: Contents of token considered invalid: " + $user->getError());
1116 $type =
"image/gif";
1117 $content =
"R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAIBTAA7";
1143 $this->
setError(
'Error: getConsentUrl: Invalid offers list.');
1147 $url .=
'Delegation.aspx?ps=' . urlencode($offers);
1149 $url .= ($ru ?
'&ru=' . urlencode($ru) :
'');
1151 $url .= ($pl ?
'&pl=' . urlencode($pl) :
'');
1152 $url .= ($market ?
'&mkt=' . urlencode($market) :
'');
1153 if (!$this->_force_delauth_nonprovisioned) {
1173 $this->
setError(
'Error: getRefreshConsentTokenUrl: Invalid offers list.');
1176 if (!$refreshtoken) {
1178 $this->
setError(
'Error: getRefreshConsentTokenUrl: Invalid refresh token.');
1183 $url .=
'RefreshToken.aspx?ps=' . urlencode($offers);
1184 $url .=
'&reft=' . $refreshtoken;
1186 $url .= ($ru ?
'&ru=' . urlencode($ru) :
'');
1188 if (!$this->_force_delauth_nonprovisioned) {
1206 $url .=
'ManageConsent.aspx';
1207 $url .= ($market ?
'?mkt=' . urlencode($market) :
'');
1222 $this->
debug(
"Warning: processConsent: query action ignored: $action");
1225 $responsecode = @
$query[
'ResponseCode'];
1226 if ($responsecode !=
'RequestApproved') {
1227 $this->
debug(
"Warning: processConsent: consent was not successfully granted: $responsecode");
1230 $token = @
$query[
'ConsentToken'];
1244 $this->
debug(
'Error: processConsentToken: Null token.');
1248 $decodedToken = $token;
1249 $parsedToken = $this->
parse(urldecode($decodedToken));
1250 if (!$parsedToken) {
1251 $this->
debug(
"Error: processConsentToken: Failed to parse token: $token");
1255 $eact = @$parsedToken[
'eact'];
1258 if (!$decodedToken) {
1259 $this->
debug(
"Error: processConsentToken: Failed to decode/validate token: $token");
1262 $parsedToken = $this->
parse($decodedToken);
1263 if (!$parsedToken) {
1264 $this->
debug(
"Error: processConsentToken: Failed to parse token after decoding: $token");
1267 $decodedToken = urlencode($decodedToken);
1270 $consenttoken =
null;
1274 @$parsedToken[
'delt'],
1275 @$parsedToken[
'reft'],
1276 @$parsedToken[
'skey'],
1277 @$parsedToken[
'exp'],
1278 @$parsedToken[
'offer'],
1279 @$parsedToken[
'lid'],
1282 if($consenttoken->getError() !==
false)
1283 $this->
debug(
"Error: processConsentToken: Contents of token considered invalid: " + $consenttoken->getError());
1285 return $consenttoken;
1296 $this->
debug(
"Error: refreshConsentToken: Null consent token.");
1311 $this->
debug(
"Error: refreshConsentToken2: Failed to obtain a new token.");
1315 preg_match(
'/\{"ConsentToken":"(.*)"\}/', $body,
$matches);
1320 $this->
debug(
"Error: refreshConsentToken2: Failed to extract token: $body");
1332 $internal_allow_recursion=
true)
1341 $haveoldsecret =
false;
1346 if ($oldsecretexpiry and (time() < $oldsecretexpiry)) {
1347 if ($oldcryptkey and $oldsignkey) {
1348 $haveoldsecret =
true;
1351 $haveoldsecret = ($haveoldsecret and $internal_allow_recursion);
1359 if (!$stoken and $haveoldsecret) {
1360 $this->
debug(
"Warning: Failed to validate token with current secret, attempting old secret.");
1382 $this->
fatal(
"Error: decodeToken: Secret key was not set. Aborting.");
1386 $token = $this->
u64($token);
1387 $len = strlen($token);
1389 if (!$token || ($len <= $ivLen) || (($len % $ivLen) != 0)) {
1390 $this->
debug(
"Error: decodeToken: Attempted to decode invalid token.");
1394 $iv = substr($token, 0, 16);
1395 $crypted = substr($token, 16);
1397 return openssl_decrypt($crypted,
"AES-128-CBC", $cryptkey, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, $iv);
1411 $this->
fatal(
"Error: signToken: Secret key was not set. Aborting.");
1415 $this->
debug(
"Attempted to sign null token.");
1419 return hash_hmac(
"sha256", $token, $signkey,
true);
1432 $this->
debug(
"Error: validateToken: Invalid token.");
1436 $split = explode(
"&sig=", $token);
1437 if (
count($split) != 2) {
1438 $this->
debug(
"ERROR: validateToken: Invalid token: $token");
1441 list($body, $sig) = $split;
1443 $sig = $this->
u64($sig);
1445 $this->
debug(
"Error: validateToken: Could not extract signature from token.");
1449 $sig2 = $this->
signToken($body, $signkey);
1451 $this->
debug(
"Error: validateToken: Could not generate signature for the token.");
1456 if ($sig == $sig2) {
1460 $this->
debug(
"Error: validateToken: Signature did not match.");
1475 $token .= ($ip ?
"&ip={$ip}" :
'');
1476 $token .=
'&sig=' . $this->
e64($this->
signToken($token));
1477 return urlencode($token);
1506 $url .= ($siteid ?
"&id=$siteid" :
'');
1507 $url .= ($js ?
'&js=1' :
'');
1533 $this->
debug(
"Error: getAppSecurityToken: Could not fetch the application security token.");
1537 preg_match(
'/\{"token":"(.*)"\}/', $body,
$matches);
1542 $this->
debug(
"Error: getAppSecurityToken: Failed to extract token: $body");
1556 return 'appid=' . $this->
getAppId();
1582 $token =
"<wst:RequestSecurityTokenResponse xmlns:wst=\"http://schemas.xmlsoap.org/ws/2005/02/trust\"><wst:RequestedSecurityToken><wsse:BinarySecurityToken xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">$token</wsse:BinarySecurityToken></wst:RequestedSecurityToken><wsp:AppliesTo xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\"><wsa:EndpointReference xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/08/addressing\"><wsa:Address>uri:WindowsLiveID</wsa:Address></wsa:EndpointReference></wsp:AppliesTo></wst:RequestSecurityTokenResponse>";
1606 $this->
debug(
'Error: getTrustedToken: Null user specified.');
1610 $token =
"appid=" . $this->
getAppId() .
"&uid=" . urlencode($user)
1612 $token .=
"&sig=" . $this->
e64($this->
signToken($token));
1613 return urlencode($token);
1644 'appid' =>
'00163FFF8000E2C5',
1645 'secret' =>
'12345678901234567890',
1646 'securityalgorithm' =>
'wsignin1.0',
1651 $doc =
new DOMDocument();
1652 if (!$doc->load($settingsFile)) {
1653 $this->
fatal(
"Error: parseSettings: Error while reading $settingsFile");
1656 $nl = $doc->getElementsByTagName(
'windowslivelogin');
1657 if($nl->length != 1) {
1658 $this->
fatal(
"error: parseSettings: Failed to parse settings file:"
1662 $topnode = $nl->item(0);
1663 foreach ($topnode->childNodes as $node) {
1664 if ($node->nodeType == XML_ELEMENT_NODE) {
1665 $firstChild = $node->firstChild;
1667 $this->
fatal(
"error: parseSettings: Failed to parse settings file:"
1670 $settings[$node->nodeName] = $firstChild->nodeValue;
1684 if (!$secret || !$prefix) {
1685 $this->
fatal(
"Error: derive: secret or prefix is null.");
1689 $key = $prefix . $secret;
1693 if (!
$key || (strlen(
$key) < $keyLen)) {
1694 $this->
debug(
"Error: derive: Unable to derive key.");
1698 return substr(
$key, 0, $keyLen);
1711 $this->
debug(
"Error: parse: Null input.");
1715 $input = explode(
'&', $input);
1718 foreach ($input as $pair) {
1719 $kv = explode(
'=', $pair);
1720 if (
count($kv) != 2) {
1721 $this->
debug(
"Error: parse: Bad input to parse: " . $pair);
1724 $pairs[$kv[0]] = $kv[1];
1746 if (is_null($input)) {
1749 return urlencode(base64_encode($input));
1760 return base64_decode(urldecode($input));
1785 $http = new \Bitrix\Main\Web\HttpClient([
1786 "redirect" =>
false,
1797 $this->_error =
$str;
1802 if ($this->_error !==
false)
1812 COption::GetOptionString(
'main',
'new_user_registration',
'Y') ==
'Y' &&
1813 COption::GetOptionString(
'main',
'auth_liveid',
'N') ==
'Y'
1826 return function_exists(
'hash');
setLocationID($locationID)
setDelegationToken($delegationtoken)
setSessionKey($sessionkey)
setDecodedToken($decodedtoken)
setRefreshToken($refreshtoken)
__construct( $wll, $delegationtoken, $refreshtoken, $sessionkey, $expiry, $offers, $locationID, $context, $decodedtoken, $token)
__construct($timestamp, $id, $flags, $context, $token)
getTrustedParams($user, $retcode=null)
processToken($token, $context=null)
parseSettings($settingsFile)
getManageConsentUrl($market=null)
getRefreshConsentTokenUrl($offers, $refreshtoken, $ru=null)
$_force_delauth_nonprovisioned
setOldSecretExpiry($timestamp)
refreshConsentToken($token, $ru=null)
decodeAndValidateToken($token, $cryptkey=null, $signkey=null, $internal_allow_recursion=true)
getLoginUrl($context=null, $market=null)
setForceDelAuthNonProvisioned($force_delauth_nonprovisioned)
refreshConsentToken2($offers_string, $refreshtoken, $ru=null)
validateToken($token, $signkey=null)
signToken($token, $signkey=null)
setSecurityAlgorithm($securityalgorithm)
getLogoutUrl($market=null)
initFromXml($settingsFile)
getConsentUrl($offers, $context=null, $ru=null, $market=null)
__construct( $appid=null, $secret=null, $securityalgorithm=null, $force_delauth_nonprovisioned=null, $policyurl=null, $returnurl=null)
getAppLoginUrl($siteid=null, $ip=null, $js=null)
processConsentToken($token, $context=null)
decodeToken($token, $cryptkey=null)
setConsentBaseUrl($consenturl)
getAppSecurityToken($siteid=null, $ip=null)
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']