Ejemplo n.º 1
0
 public static function startKSession($partner_id, $partner_secret, $puser_id, &$ks_str, $desired_expiry_in_seconds = 86400, $admin = false, $partner_key = "", $privileges = "", $master_partner_id = null, $additional_data = null)
 {
     $ks_max_expiry_in_seconds = "";
     // see if we want to use the generic setting of the partner
     ks::validatePrivileges($privileges, $partner_id);
     $result = myPartnerUtils::isValidSecret($partner_id, $partner_secret, $partner_key, $ks_max_expiry_in_seconds, $admin);
     if ($result >= 0) {
         if ($ks_max_expiry_in_seconds && $ks_max_expiry_in_seconds < $desired_expiry_in_seconds) {
             $desired_expiry_in_seconds = $ks_max_expiry_in_seconds;
         }
         //	echo "startKSession: from DB: $ks_max_expiry_in_seconds | desired: $desired_expiry_in_seconds " ;
         $ks = new ks();
         $ks->valid_until = kApiCache::getTime() + $desired_expiry_in_seconds;
         // store in milliseconds to make comparison easier at validation time
         //			$ks->type = $admin ? ks::TYPE_KAS : ks::TYPE_KS;
         if ($admin == false) {
             $ks->type = ks::TYPE_KS;
         } else {
             $ks->type = $admin;
         }
         // if the admin > 1 - use it rather than automatially setting it to be 2
         $ks->partner_id = $partner_id;
         $ks->master_partner_id = $master_partner_id;
         $ks->partner_pattern = $partner_id;
         $ks->error = 0;
         $ks->rand = microtime(true);
         $ks->user = $puser_id;
         $ks->privileges = $privileges;
         $ks->additional_data = $additional_data;
         $ks_str = $ks->toSecureString();
         return 0;
     } else {
         return $result;
     }
 }
Ejemplo n.º 2
0
 public static function startKSession($partner_id, $partner_secret, $puser_id, &$ks_str, $desired_expiry_in_seconds = 86400, $admin = false, $partner_key = "", $privileges = "", $master_partner_id = null, $additional_data = null)
 {
     $ks_max_expiry_in_seconds = "";
     // see if we want to use the generic setting of the partner
     ks::validatePrivileges($privileges, $partner_id);
     $result = myPartnerUtils::isValidSecret($partner_id, $partner_secret, $partner_key, $ks_max_expiry_in_seconds, $admin);
     if ($result >= 0) {
         if ($ks_max_expiry_in_seconds && $ks_max_expiry_in_seconds < $desired_expiry_in_seconds) {
             $desired_expiry_in_seconds = $ks_max_expiry_in_seconds;
         }
         //	echo "startKSession: from DB: $ks_max_expiry_in_seconds | desired: $desired_expiry_in_seconds " ;
         $ks_type = ks::TYPE_KS;
         if ($admin) {
             $ks_type = $admin;
         }
         // if the admin > 1 - use it rather than automatially setting it to be 2
         $ks = self::createKSession($partner_id, $partner_secret, $puser_id, $desired_expiry_in_seconds, $ks_type, $privileges, $additional_data, $master_partner_id);
         $ks_str = $ks->toSecureString();
         return 0;
     } else {
         return $result;
     }
 }