示例#1
1
 /**
  * @test
  *
  * @uses \Lcobucci\JWT\Signature::__construct
  * @uses \Lcobucci\JWT\Signature::__toString
  *
  * @covers \Lcobucci\JWT\Signature::verify
  */
 public function verifyMustReturnWhatSignerSays()
 {
     $this->signer->expects($this->any())->method('verify')->willReturn(true);
     $signature = new Signature('test');
     self::assertTrue($signature->verify($this->signer, 'one', 'key'));
 }
 /**
  * Cria uma assinatura a partir de um nome e valor
  *
  * @param string $name Nome da assinatura
  * @param mixed $value Valor da assinatura
  * @return Signature
  */
 public static function signature($name, $value)
 {
     $signature = new Signature();
     $signature->setName($name);
     $signature->setValue($value);
     return $signature;
 }
 /**
  * @param Signature $givenSignature
  * @param Signature $wishedSignature
  *
  * @return Diff
  */
 public function compare(Signature $givenSignature, Signature $wishedSignature)
 {
     $givenParameters = $givenSignature->getParameters();
     $wishedParameters = $wishedSignature->getParameters();
     $missingParameters = $this->getDifferentParameter($wishedParameters, $givenParameters);
     $additionalParameters = $this->getDifferentParameter($givenParameters, $wishedParameters);
     return new Diff($missingParameters, $additionalParameters);
 }
示例#4
0
 public function testAroundGetBaseUrlActive()
 {
     $this->config->expects($this->once())->method('getValue')->with(Signature::XML_PATH_STATIC_FILE_SIGNATURE)->will($this->returnValue(1));
     $this->deploymentVersion->expects($this->once())->method('getValue')->will($this->returnValue('123'));
     $url = $this->getMockForAbstractClass('\\Magento\\Framework\\Url\\ScopeInterface');
     $actualResult = $this->object->aroundGetBaseUrl($url, $this->closureMock, \Magento\Framework\UrlInterface::URL_TYPE_STATIC);
     $this->assertEquals('http://127.0.0.1/magento/pub/static/version123/', $actualResult);
 }
示例#5
0
 /**
  * @param Signature $signature
  *
  * @return boolean Whether the signature has been signed by this certificate
  */
 public function hasSigned(Signature $signature)
 {
     $key = openssl_pkey_get_public($this->x509Cert);
     try {
         $hasSigned = $signature->isSignedByKey($key);
     } catch (\Excetpion $e) {
         openssl_pkey_free($key);
         throw $e;
     }
     openssl_pkey_free($key);
     return $hasSigned;
 }
 public function verifies($hash, Signature $signature)
 {
     if (extension_loaded('gmp') && USE_EXT == 'GMP') {
         $G = $this->generator;
         $n = $this->generator->getOrder();
         $point = $this->point;
         $r = $signature->getR();
         $s = $signature->getS();
         if (gmp_cmp($r, 1) < 0 || gmp_cmp($r, gmp_sub($n, 1)) > 0) {
             return false;
         }
         if (gmp_cmp($s, 1) < 0 || gmp_cmp($s, gmp_sub($n, 1)) > 0) {
             return false;
         }
         $c = NumberTheory::inverse_mod($s, $n);
         $u1 = gmp_Utils::gmp_mod2(gmp_mul($hash, $c), $n);
         $u2 = gmp_Utils::gmp_mod2(gmp_mul($r, $c), $n);
         $xy = Point::add(Point::mul($u1, $G), Point::mul($u2, $point));
         $v = gmp_Utils::gmp_mod2($xy->getX(), $n);
         if (gmp_cmp($v, $r) == 0) {
             return true;
         } else {
             return false;
         }
     } else {
         if (extension_loaded('bcmath') && USE_EXT == 'BCMATH') {
             $G = $this->generator;
             $n = $this->generator->getOrder();
             $point = $this->point;
             $r = $signature->getR();
             $s = $signature->getS();
             if (bccomp($r, 1) == -1 || bccomp($r, bcsub($n, 1)) == 1) {
                 return false;
             }
             if (bccomp($s, 1) == -1 || bccomp($s, bcsub($n, 1)) == 1) {
                 return false;
             }
             $c = NumberTheory::inverse_mod($s, $n);
             $u1 = bcmod(bcmul($hash, $c), $n);
             $u2 = bcmod(bcmul($r, $c), $n);
             $xy = Point::add(Point::mul($u1, $G), Point::mul($u2, $point));
             $v = bcmod($xy->getX(), $n);
             if (bccomp($v, $r) == 0) {
                 return true;
             } else {
                 return false;
             }
         } else {
             throw new ErrorException("Please install BCMATH or GMP");
         }
     }
 }
示例#7
0
 public function GOST_verifies($hash, Signature $signature)
 {
     if (extension_loaded('gmp') && USE_EXT == 'GMP') {
         $G = $this->generator;
         //P
         $n = $this->generator->getOrder();
         //q
         $point = $this->point;
         //Q
         $r = $signature->getR();
         $s = $signature->getS();
         if (gmp_cmp($r, 1) < 0 || gmp_cmp($r, gmp_sub($n, 1)) > 0) {
             return false;
         }
         if (gmp_cmp($s, 1) < 0 || gmp_cmp($s, gmp_sub($n, 1)) > 0) {
             return false;
         }
         //step 3 GOST
         $e = gmp_Utils::gmp_mod2($hash, $n);
         if (gmp_cmp($e, '0') === 0) {
             $e = gmp_init('1');
         }
         // step 4 GOST
         $v = gmp_strval(gmp_invert($e, $n));
         // step 5 GOST
         $z1 = gmp_Utils::gmp_mod2(gmp_mul($s, $v), $n);
         $z2 = gmp_Utils::gmp_mod2(gmp_mul(gmp_neg($r), $v), $n);
         // step 6 GOST
         $C = Point::add(Point::mul($z1, $G), Point::mul($z2, $point));
         $R = gmp_Utils::gmp_mod2($C->getX(), $n);
         if (0) {
             echo "n - " . $n . "\n";
             echo "h - " . $hash . "\n";
             echo "e - " . gmp_Utils::gmp_dechex($e) . "\n";
             echo "v - " . gmp_Utils::gmp_dechex($v) . "\n";
             echo "r - " . $r . "\n";
             echo "s - " . $s . "\n";
             echo "z1 - " . gmp_Utils::gmp_dechex($z1) . "\nz2 - " . gmp_Utils::gmp_dechex($z2) . "\n";
             echo "Q - " . $point . "\nG - " . $G . "\n";
             echo "C - " . $C . "\nR - " . $R . "\n";
         }
         if (gmp_cmp($R, $r) == 0) {
             return true;
         } else {
             return false;
         }
     } else {
         throw new ErrorException("Please install GMP");
     }
 }
 public function destroy($id)
 {
     $signature = Signature::find($id);
     $signature->delete();
     Session::flash('success', 'Data telah dihapus');
     return Redirect::to('/admin/signature');
 }
示例#9
0
 /**
  * Creates a new osu! signature.
  *
  * @param array $user The user whom the signature will be the signature's subject
  * @param Template $template The template this signature will be based on.
  */
 public function __construct($user, $template)
 {
     $this->user = $user;
     $this->template = new $template($this);
     $width = $this->template->calculateBaseWidth() + $this->template->getImageMarginWidth();
     $height = $this->template->calculateBaseHeight() + $this->template->getImageMarginWidth();
     parent::__construct($width, $height);
 }
示例#10
0
 public function validate($response)
 {
     if ($response->getReferrer() !== self::$validReferrer) {
         throw new Exceptions\InvalidReferrerException();
     }
     $sig = Signature::generateSignature($this->merchantKey, $response->getMerchantCode(), $response->getPaymentId(), $response->getRefNo(), preg_replace('/[\\.\\,]/', '', $response->getAmount()), $response->getCurrency(), $response->getStatus());
     if ($response->getSignature() !== $sig) {
         throw new Exceptions\InvalidSignatureException();
     }
     return true;
 }
示例#11
0
 public function testSignaturesUnsetIfPresentAndSignaturesMatch()
 {
     $this->params['user'] = '******';
     $this->request->method('getMethod')->willReturn('POST');
     $this->request->method('getHost')->willReturn($this->host);
     $this->request->method('getPath')->willReturn($this->path);
     $this->request->expects($this->at(3))->method('getParams')->willReturn($this->params);
     $this->request->expects($this->at(7))->method('getParams')->willReturn(array_merge($this->params, ['signature' => 'fjdklsjflkd']));
     $this->credentials->method('getSecret')->willReturn($this->secret);
     $signature1 = $this->signature->createSignature($this->request, $this->credentials);
     $signature2 = $this->signature->createSignature($this->request, $this->credentials);
     $this->assertEquals($signature1, $signature2);
 }
示例#12
0
 /**
  * Overloads default class properties from the options.
  *
  * Any of the provider options can be set here:
  *
  * Type      | Option        | Description                                    | Default Value
  * ----------|---------------|------------------------------------------------|-----------------
  * mixed     | signature     | Signature method name or object                | provider default
  *
  * @param   array   provider options
  * @return  void
  */
 public function __construct(array $options = NULL)
 {
     if (isset($options['signature'])) {
         // Set the signature method name or object
         $this->signature = $options['signature'];
     }
     if (!is_object($this->signature)) {
         // Convert the signature name into an object
         $this->signature = Signature::forge($this->signature);
     }
     if (!$this->name) {
         // Attempt to guess the name from the class name
         $this->name = strtolower(substr(get_class($this), strlen('Provider_')));
     }
 }
 function parseAFD_Content_mainComment()
 {
     $GLOBALS['log'] .= "<span class='startCall'> ****************** Call ParseAFD_MainComment->parseAFD_Content_mainComment() <a target='_blank' <a href='GetAFDListbyDebateDateListID.php?DebateDateListID=" . $this->afd->debateDateListID . "#" . $this->afd->AFDTitleID . "'>" . $this->afd->AFDTitle . "</a> </span>";
     try {
         if (!$this->afd) {
             throw new Exception('this->afd is empty!');
         }
         //is allowed to parse the mainComment details
         if ($this->afd->flag_DoNotParse != 1) {
             //$MainEndResult = $matches_MainEndResult[1][0][0];
             //$GLOBALS['log'] .="<br/><span class='good'>Full Matched:</span>".$MainEndResult. " -- $condition_TheEndResultDate -- Start".  + ($matches_MainEndResult[0][0][1]) ." Lenght :".strlen("The result was ".$MainEndResult);
             //$startPosition_MainEndResult = $matches_MainEndResult[1][0][1] + strlen($matches_MainEndResult[1][0][0]);
             //$endResult_Middle = substr($endResult_Middle, $startPosition_MainEndResult );
             $signature = Signature::parse($this->mainComment_Html);
             if ($signature->parsedPassedNo == 4) {
                 $this->afd->parse_mainComment = 1;
             } else {
                 $this->afd->parse_mainComment = 0;
             }
             $mainComment_ExtraNote2_temp = substr($this->mainComment_Html, $signature->getAfterUTC_Position());
             if (strlen(trim($mainComment_ExtraNote2_temp)) > 15) {
                 $this->afd->mainComment_ExtraNote2 = $mainComment_ExtraNote2_temp;
                 $GLOBALS['log'] .= "<br/><span class='percentage'>MainComment_ExtraNote2:</span>" . " - lenght: " . strlen(trim($this->afd->mainComment_ExtraNote2)) . " - " . $this->afd->mainComment_ExtraNote2;
             }
             //$this->afd->endResult = $MainEndResult;
             $this->afd->mainComment_User = $signature->userID;
             $this->afd->mainComment_UserPosition = $signature->userID_StartPos;
             $this->afd->mainComment_UserTitle = $signature->userTitle;
             $this->afd->mainComment_UserURL = $signature->userURL;
             $this->afd->mainComment_UserURLType = $signature->userURLType;
             $this->afd->mainComment_Note = $signature->initialSentance;
             $this->afd->mainComment_Date = $signature->date;
             $this->afd->mainComment_Time = $signature->time;
             $this->afd->mainComment_DateTime = date('Y-m-d H:i:s', strtotime($signature->date . " " . $signature->time));
             $this->afd->updateAFD_OnlyMainComment_byAFDID();
         } else {
             $GLOBALS['log'] .= "<br/><span class='startCall'> By pass by flag_DoNotParse = 1.</span>";
         }
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
     $GLOBALS['log'] .= "<br/><span class='endCall'>**** End Called ParseAFD_EndResult->parseAFD_Content_endResult()*******************</span>";
 }
 public function run()
 {
     DB::table('users')->delete();
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Admin Network App', 'jabatan' => 'System Administrator', 'level_jabatan' => 'manager', 'is_manager_utama' => false, 'can_be_poh' => true, 'role' => 'admin', 'lokasi_kerja_id' => 1, 'need_signature' => false, 'mitra' => 1, 'nik' => '7802211', 'bank' => 'Mandiri Cab. Sorong', 'no_rekening' => '154-000-528-6053', 'no_hp' => '0811400005'));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Habibi M. Tau', 'jabatan' => 'Mgr. Network Service Palu', 'level_jabatan' => 'manager', 'is_manager_utama' => true, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 1, 'nik' => '78022', 'bank' => 'Mandiri Cab. Sorong', 'no_rekening' => '154-000-528-6053', 'no_hp' => '0811400005', 'need_signature' => false, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Joni A. Lembang', 'jabatan' => 'Spv. Core Network Operation Palu', 'level_jabatan' => 'spv', 'is_manager_utama' => false, 'can_be_poh' => true, 'role' => 'no', 'lokasi_kerja_id' => 1, 'nik' => '83022', 'bank' => 'BNI', 'no_rekening' => '0085638331', 'no_hp' => '0811470000', 'need_signature' => false, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Prasanthy Ganty', 'jabatan' => 'Spv. RTP Operation Palu', 'level_jabatan' => 'spv', 'is_manager_utama' => false, 'can_be_poh' => true, 'role' => 'no', 'lokasi_kerja_id' => 1, 'nik' => '79023', 'bank' => 'BNI Cab. Palu', 'no_rekening' => '0081771773', 'no_hp' => '0811451007', 'need_signature' => false, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Nathaniel Rombo', 'jabatan' => 'Spv. RTP Operation Tolitoli', 'level_jabatan' => 'spv', 'is_manager_utama' => false, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 2, 'nik' => '82018', 'bank' => 'BNI 46 Cab. Makassar', 'no_rekening' => '0085639196', 'no_hp' => '0811468458', 'need_signature' => true, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Mochamad Faizal', 'jabatan' => 'Staff RTP Operation Palu', 'level_jabatan' => 'staff', 'is_manager_utama' => false, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 1, 'nik' => '90085', 'bank' => 'BNI Cab. Surabaya', 'no_rekening' => '0154733317', 'no_hp' => '08114510154', 'need_signature' => false, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Ginanjar Artanto', 'jabatan' => 'Staff RTP Operation Palu', 'level_jabatan' => 'staff', 'is_manager_utama' => false, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 1, 'nik' => '90136', 'bank' => 'BNI Cab. Perintis', 'no_rekening' => '0266525334', 'no_hp' => '08111818883', 'need_signature' => false, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Fahri', 'jabatan' => 'Spv. RTP Operation Luwuk', 'level_jabatan' => 'spv', 'is_manager_utama' => false, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 3, 'nik' => '82004', 'bank' => 'BNI Cab. Palu', 'no_rekening' => '0081984873', 'no_hp' => '0811458880', 'need_signature' => true, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Ahmad Taufik', 'jabatan' => 'Spv. RTP Operation Poso', 'level_jabatan' => 'spv', 'is_manager_utama' => false, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 4, 'nik' => '78013', 'bank' => 'BNI Syariah Cab. Malang', 'no_rekening' => '0159.4792.29', 'no_hp' => '0811363111', 'need_signature' => true, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Lutfi N Rachmad', 'jabatan' => 'Staff Core Network Operation Palu', 'level_jabatan' => 'spv', 'is_manager_utama' => false, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 1, 'nik' => '92062', 'bank' => '', 'no_rekening' => '', 'no_hp' => '08118035470', 'need_signature' => false, 'mitra' => 1));
     // user TTD
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Ali Imran', 'jabatan' => 'VP ICT Network Management Area Pamasuka', 'level_jabatan' => 'manager', 'is_manager_utama' => true, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 1, 'nik' => '', 'bank' => '', 'no_rekening' => '', 'no_hp' => '', 'need_signature' => false, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Noviandri', 'jabatan' => 'GM ICT Operation Region Sulawesi', 'level_jabatan' => 'manager', 'is_manager_utama' => true, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 1, 'nik' => '', 'bank' => '', 'no_rekening' => '', 'no_hp' => '', 'need_signature' => false, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Edi Sucipto', 'jabatan' => 'Mgr. Network Operation Support Sulawesi', 'level_jabatan' => 'manager', 'is_manager_utama' => true, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 1, 'nik' => '', 'bank' => '', 'no_rekening' => '', 'no_hp' => '', 'need_signature' => false, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Ronald Limoa', 'jabatan' => 'Mgr. Core and Power Performance Assurance Sulawesi', 'level_jabatan' => 'manager', 'is_manager_utama' => true, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 1, 'nik' => '', 'bank' => '', 'no_rekening' => '', 'no_hp' => '', 'need_signature' => false, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Ma\'ruf Mustafa', 'jabatan' => 'Mgr. RAN and Transport Performance Assurance Sulawesi', 'level_jabatan' => 'manager', 'is_manager_utama' => true, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 1, 'nik' => '', 'bank' => '', 'no_rekening' => '', 'no_hp' => '', 'need_signature' => false, 'mitra' => 1));
     User::create(array('email' => '*****@*****.**', 'password' => Hash::make('12345'), 'nama' => 'Muhamad Ma\'ruf', 'jabatan' => 'Mgr. Site Management Sulawesi', 'level_jabatan' => 'manager', 'is_manager_utama' => true, 'can_be_poh' => false, 'role' => 'no', 'lokasi_kerja_id' => 1, 'nik' => '', 'bank' => '', 'no_rekening' => '', 'no_hp' => '', 'need_signature' => false, 'mitra' => 1));
     Mitra::create(array('nama' => 'PT. Kisel', 'cluster' => 'Palu_tolitoli_Santigi', 'pic' => 'Basri Marhabang', 'hp' => '082192622222', 'no_rekening' => '0104200173', 'nama_rekening' => 'Koperasi Telkomsel (Ki-SEL) Komisariat Wil. VIII', 'bank' => 'BNI 46 Cab. SUDIRMAN MAKASSAR'));
     Mitra::create(array('nama' => 'PT. Primatama', 'cluster' => 'Poso_Luwuk', 'pic' => 'Hendra C. P.', 'hp' => '082111477771', 'no_rekening' => '', 'nama_rekening' => '', 'bank' => ''));
     Mitra::create(array('nama' => 'PT. DFA EKSPRES PALU', 'cluster' => '', 'pic' => 'Waryo', 'hp' => '081341464070', 'no_rekening' => '0119464006', 'nama_rekening' => 'Waryo', 'bank' => 'BNI 46 Cab. Palu'));
     LokasiKerja::create(array('nama' => 'Palu'));
     LokasiKerja::create(array('nama' => 'Tolitoli'));
     LokasiKerja::create(array('nama' => 'Luwuk'));
     LokasiKerja::create(array('nama' => 'Poso'));
     VersheetType::create(array('doc_name' => 'FPJP'));
     VersheetType::create(array('doc_name' => 'PO'));
     VersheetType::create(array('doc_name' => 'Invoice'));
     VersheetType::create(array('doc_name' => 'Kwitansi'));
     VersheetType::create(array('doc_name' => 'Faktur Pajak'));
     VersheetType::create(array('doc_name' => 'BAST'));
     VersheetType::create(array('doc_name' => 'Berita Acara'));
     VersheetType::create(array('doc_name' => 'PKS / BAK / BAN'));
     VersheetType::create(array('doc_name' => 'Rekapitulasi'));
     Signature::create(array('user_id' => 2, 'signature_pic' => '/signature_2.png'));
     Signature::create(array('user_id' => 4, 'signature_pic' => '/signature_4.png'));
     Signature::create(array('user_id' => 5, 'signature_pic' => '/signature_5.png'));
     Signature::create(array('user_id' => 6, 'signature_pic' => '/signature_6.png'));
     Signature::create(array('user_id' => 7, 'signature_pic' => '/signature_7.png'));
     Signature::create(array('user_id' => 9, 'signature_pic' => '/signature_9.png'));
 }
 public function invoke($api, $param)
 {
     if (empty($api) || strpos($api, '.') === false) {
         return 'api not exist';
     }
     $api_arr = explode('.', $api);
     $class = $api_arr[0];
     $method = $api_arr[1];
     require_once APP_ROOT . "/data/services/{$class}.php";
     $ins = new $class();
     require_once FRAMEWORK . '/rest/Signature.class.php';
     $param['t'] = time();
     $sig_key = get_app_config()->getGlobalConfig(AppConfig::SIGNATURE_KEY);
     $param['k'] = Signature::sign($param, $sig_key, 'k');
     if (method_exists($ins, $method)) {
         return $ins->{$method}($param);
     } else {
         return "method {$method} not exist in class {$class}.";
     }
 }
示例#16
0
 public function removeLicense()
 {
     //delete all documents and associated expressions and SFX providers
     $document = new Document();
     foreach ($this->getDocuments() as $document) {
         //delete all expressions and expression notes
         $expression = new Expression();
         foreach ($document->getExpressions() as $expression) {
             $expressionNote = new ExpressionNote();
             foreach ($expression->getExpressionNotes() as $expressionNote) {
                 $expressionNote->delete();
             }
             $expression->removeQualifiers();
             $expression->delete();
         }
         $sfxProvider = new SFXProvider();
         foreach ($document->getSFXProviders() as $sfxProvider) {
             $sfxProvider->delete();
         }
         $signature = new Signature();
         foreach ($document->getSignatures() as $signature) {
             $signature->delete();
         }
         $document->delete();
     }
     //delete all attachments
     $attachment = new Attachment();
     foreach ($this->getAttachments() as $attachment) {
         $attachmentFile = new AttachmentFile();
         foreach ($attachment->getAttachmentFiles() as $attachmentFile) {
             $attachmentFile->delete();
         }
         $attachment->delete();
     }
     $this->delete();
 }
示例#17
0
	/**
	 * Verify the signature on a given file
	 *
	 * If only one argument is provided, it is expected that file contains both the file and signature as an attached sig.
	 *
	 * If two arguments are provided, the detached signature is the first argument and the content to verify is the second.
	 *
	 * @throws \Exception
	 *
	 * @param string|\Core\Filestore\File $file       Filename or File object of the file to verify
	 * @param string|\Core\Filestore\File $verifyFile Filename or File object of any detached signature
	 *
	 * @return Signature
	 */
	public function verifyFileSignature($file, $verifyFile = null){
		if($file instanceof \Core\Filestore\File){
			$filename = $file->getFilename();
		}
		else{
			$filename = $file;
		}

		if(!file_exists($filename)){
			throw new \Exception('Requested file does not exist, unable to verify signature!');
		}

		if($verifyFile === null){
			// Standard attached sig
			$result = $this->_exec('--with-fingerprint --batch --no-tty --verify ' . escapeshellarg($filename));
		}
		else{
			// Detached signature
			if($verifyFile instanceof \Core\Filestore\File){
				$sourceFilename = $verifyFile->getFilename();
			}
			else{
				$sourceFilename = $verifyFile;
			}

			$result = $this->_exec('--with-fingerprint --batch --no-tty --verify ' . escapeshellarg($filename) . ' ' . escapeshellarg($sourceFilename));
		}


		// If the result failed, then nothing else to do here.
		if($result['return'] !== 0){
			throw new \Exception($result['error']);
		}

		// Else, the calling script may want to know the results of the verification, eg: the key and date.
		// The metadata here is send to STDERR.  _Shrugs_
		$sig = new Signature();
		$sig->_parseOutputText($result['error']);
		return $sig;
	}
 /**
  * 验证rest服务必须的参数
  */
 protected function validate()
 {
     $params =& $_REQUEST;
     if (!isset($params['sig'], $params['timestamp'], $params['method'], $params['sig_appkey'])) {
         $this->errorMessage(ELEX_API_CODE_PARAMETER_ERROR, 'request parameters error.');
     }
     $request_time = $_SERVER['REQUEST_TIME'];
     if (empty($request_time)) {
         $request_time = time();
     }
     // 验证时间戳
     $timestamp = getGPC('timestamp', 'int');
     if (abs($timestamp - $request_time) > 30) {
         $this->errorMessage(ELEX_API_CODE_PARAMETER_ERROR, 'timestamp error');
     }
     // 验证签名
     require_once FRAMEWORK . '/rest/Signature.class.php';
     $sign = Signature::sign($params, API_SIG_KEY);
     $sig_request = $params['sig'];
     if ($sign != $sig_request) {
         $this->errorMessage(ELEX_API_CODE_SIGNATURE_ERROR, 'signature error.');
     }
 }
示例#19
0
文件: Card.php 项目: smartUI/weixin
<?php

namespace Weixin\Model;

// ------------------------set base_info-----------------------------
$base_info = new BaseInfo("http://www.supadmin.cn/uploads/allimg/120216/1_120216214725_1.jpg", "海底捞", 0, "132元双人火锅套餐", "Color010", "使用时向服务员出示此券", "020-88888888", "不可与其他优惠同享\n 如需团购券发票,请在消费时向商户提出\n 店内均可使用,仅限堂食\n 餐前不可打包,餐后未吃完,可打包\n 本团购券不限人数,建议2人使用,超过建议人数须另收酱料费5元/位\n 本单谢绝自带酒水饮料", new DateInfo(1, 1397577600, 1399910400), new Sku(50000000));
$base_info->set_sub_title("");
$base_info->set_use_limit(1);
$base_info->set_get_limit(3);
$base_info->set_use_custom_code(false);
$base_info->set_bind_openid(false);
$base_info->set_can_share(true);
$base_info->set_url_name_type(1);
$base_info->set_custom_url("http://www.qq.com");
// ---------------------------set_card--------------------------------
$card = new Groupon($base_info, "以下锅底2 选1(有菌王锅、麻辣锅、大骨锅、番茄锅、清补凉锅、酸菜鱼锅可选):\n 大锅1 份12 元\n 小锅2 份16 元\n 以下菜品2 选1\n 特级肥牛1 份30 元\n 洞庭鮰鱼卷1 份20元\n 其他\n鲜菇猪肉滑1 份18 元\n 金针菇1 份16 元\n 黑木耳1 份9 元\n 娃娃菜1 份8 元\n 冬瓜1份6 元\n 火锅面2 个6 元\n 欢乐畅饮2 位12 元\n 自助酱料2 位10 元");
// ----------------------check signature------------------------
$signature = new Signature();
$signature->add_data("123");
$signature->add_data("wasda");
$signature->add_data("_()@#(&");
echo $signature->get_signature();
示例#20
0
 /**
  * Encode Signature
  *
  * This function accepts a signature object, and information about
  * the txout being spent, and the relevant key for signing, and
  * encodes the signature in DER format.
  *
  * @param    \Signature $signature
  * @return    string
  */
 public static function encode_signature(\Signature $signature)
 {
     // Pad r and s to 64 characters.
     $rh = str_pad(BitcoinLib::hex_encode($signature->getR()), 64, '0', STR_PAD_LEFT);
     $sh = str_pad(BitcoinLib::hex_encode($signature->getS()), 64, '0', STR_PAD_LEFT);
     // Check if the first byte of each has its highest bit set,
     $t1 = unpack("H*", pack('H*', substr($rh, 0, 2)) & pack('H*', '80'));
     $t2 = unpack("H*", pack('H*', substr($sh, 0, 2)) & pack('H*', '80'));
     // if so, the result != 00, and must be padded.
     $r = $t1[1] !== '00' ? '00' . $rh : $rh;
     $s = $t2[1] !== '00' ? '00' . $sh : $sh;
     // Create the signature.
     $der_sig = '30' . self::_dec_to_bytes(4 + (strlen($r) + strlen($s)) / 2, 1) . '02' . self::_dec_to_bytes(strlen($r) / 2, 1) . $r . '02' . self::_dec_to_bytes(strlen($s) / 2, 1) . $s . '01';
     return $der_sig;
 }
 /**
  * 验证参数的签名是否正确
  * @param $params
  * @return void
  */
 protected function checkSignature($params)
 {
     // 签名的key必须不为空
     if (empty($params['k'])) {
         $this->throwException('signature error', GameStatusCode::DATA_ERROR);
     }
     // action_id,need_check_sleep是在happyranch.php中添加的参数,不需要作验证的
     if (isset($params['action_id'])) {
         unset($params['action_id']);
     }
     if (isset($params['need_check_sleep'])) {
         unset($params['need_check_sleep']);
     }
     $sig_key = get_app_config()->getGlobalConfig(AppConfig::SIGNATURE_KEY);
     require_once FRAMEWORK . '/rest/Signature.class.php';
     $sig = Signature::sign($params, $sig_key, 'k');
     if ($sig != $params['k']) {
         $this->throwException("signature error", GameStatusCode::DATA_ERROR);
     }
 }
示例#22
0
 public function cardSign($card_id, $outer_id = 0, $openid = '', $code = '')
 {
     $ticket = $this->getApiTicket();
     $timestamp = time();
     $signature = new Signature();
     $signature->add_data($ticket);
     $signature->add_data($card_id);
     $signature->add_data($timestamp);
     $signature->add_data($openid);
     $signature->add_data($code);
     $sign_str = $signature->get_signature();
     $sign = array('code' => $code, 'openid' => $openid, 'timestamp' => $timestamp, 'signature' => $sign_str, 'outer_id' => $outer_id);
     return json_encode($sign);
 }
示例#23
0
    private function _Signature($data) {
        $appId = C('APP_ID');
        $appSecret = C('APP_SECRET');
        $jsSign = new WxJsSign($appId, $appSecret);
        $apiTicket = $jsSign->getJsApiTicket('wx_card');
        $apiTicket = empty($apiTicket) ? $data['app_secret'] : $apiTicket;

        include_once LIB_PATH . '/Common/WXCard/CardPacket.class.php';
        $signature = new Signature();
        $signature->add_data($apiTicket);
        $signature->add_data($data['card_id']);
        $signature->add_data($data['code']);
        $signature->add_data($data['time']);
        $signature->add_data($this->_openId);
        $sign = $signature->get_signature();

        return $sign;
    }
示例#24
0
 /**
  * Sign request using proxy object
  *
  * @return string
  */
 public function sign($options = array())
 {
     $params = $this->parameters();
     $params['oauth_signature'] = Signature::sign($this, $options);
     $this->setParameters($params);
     $this->signed = true;
     return $this->signature();
 }
 //used for autocomplete of signer name
 case 'getSigners':
     if (isset($_GET['searchMode'])) {
         $searchMode = $_GET['searchMode'];
     } else {
         $searchMode = '';
     }
     if (isset($_GET['limit'])) {
         $limit = $_GET['limit'];
     } else {
         $limit = '';
     }
     $q = $_GET['q'];
     $q = str_replace(" ", "+", $q);
     $q = str_replace("&", "%", $q);
     $signature = new Signature();
     $signerArray = $signature->search($q);
     echo implode("\n", $signerArray);
     break;
     //used for autocomplete of provider names (from organizations module)
 //used for autocomplete of provider names (from organizations module)
 case 'getOrganizations':
     if (isset($_GET['searchMode'])) {
         $searchMode = $_GET['searchMode'];
     } else {
         $searchMode = '';
     }
     if (isset($_GET['limit'])) {
         $limit = $_GET['limit'];
     } else {
         $limit = '';
 public function testSignature()
 {
     $client = new Client($this->configParams);
     $parameters['SellerId'] = $this->configParams['merchant_id'];
     $parameters['AWSAccessKeyId'] = $this->configParams['access_key'];
     $parameters['Version'] = 'test';
     $parameters['SignatureMethod'] = 'HmacSHA256';
     $parameters['SignatureVersion'] = 2;
     $parameters['Timestamp'] = $this->getFormattedTimestamp();
     uksort($parameters, 'strcmp');
     $signatureObj = new Signature($this->configParams, $parameters);
     $expectedSignature = $signatureObj->getSignature();
     $this->callPrivateMethod($client, 'createServiceUrl', null);
     $signature = $this->callPrivateMethod($client, 'signParameters', $parameters);
     $this->assertEquals($signature, $expectedSignature);
 }
 function parseAFD_Content()
 {
     $GLOBALS['log'] .= "<br/> <span class='startCall'> ****************** Call ParseAFD_OtherComment->parseAFD_Content() <a target='_blank' <a href='getAFDHtmlByID.php?id=" . $this->afd->AFDID . "#" . $this->afd->AFDTitleID . "'>" . $this->afd->AFDTitle . "</a> </span>";
     try {
         if (!$this->afd) {
             throw new Exception('this->afd is empty!');
         }
         //is allowed to parse the endresult details
         if ($this->afd->flag_DoNotParse != 1) {
             $parse_otherComment = 0;
             $parse_otherComment_User = 0;
             $otherComment_Total = 0;
             $GLOBALS['log'] .= closetags($this->otherComment_Html);
             $this->distinguishComments = new DistinguishComments($this->otherComment_Html, $this->debateDate->url);
             //Update AFD table
             $this->afd->otherComment_CounterTime = $this->distinguishComments->condition_time;
             $this->afd->otherComment_CounterDate = $this->distinguishComments->condition_date;
             $this->afd->otherComment_CounterUTC = $this->distinguishComments->condition_UTC;
             $this->afd->otherComment_CounterUserNormal = $this->distinguishComments->condition_UserID1;
             $this->afd->otherComment_CounterUserTalk = $this->distinguishComments->condition_UserID2;
             $this->afd->otherComment_CounterUserNew = $this->distinguishComments->condition_UserID3;
             $this->afd->otherComment_CounterUserIP = $this->distinguishComments->condition_UserID4;
             $this->afd->parse_otherComment = $this->distinguishComments->distinguishPercentage;
             $this->afd->parse_otherComment_User = $this->distinguishComments->distinguishPercentage_User;
             $this->afd->updateAFD_OnlyOtherComment_byAFDID();
             //clear the comment table to remove the previous records to prevent dublication
             //also if there was previous mistake it make show the mistake does not effect over the quality of data
             Comment::removedAllComment_ByAFDID($this->afd->AFDID);
             //set the condition to insert into comment table
             $GLOBALS['log'] .= "<hr style='border: 0; border-top: 1px solid gray;'/>";
             //set the (other)comment table
             for ($i = 0; $i < count($this->distinguishComments->array_time); $i++) {
                 $current_comment_Html = $this->distinguishComments->array_time[$i];
                 $current_comment_UserCheck = $this->distinguishComments->array_UTC_UserCheck[$i];
                 //$comment_User and $comment_DateTime are "", this is due to further development
                 $comment = new Comment($this->afd->AFDID, $this->afd->AFDTitleID, $this->afd->debateDateListID, $current_comment_Html, "", "", "");
                 $GLOBALS['log'] .= "<table border='1'><tr><td>";
                 $signature = Signature::parse($current_comment_Html);
                 $GLOBALS['log'] .= "</td></tr></table>";
                 $beforeSignature = $signature->initialSentance;
                 $debate_included = $this->check_debate_included($beforeSignature);
                 $bBlock = $this->check_Comment_bBlock($beforeSignature);
                 $comment->AFDTitle = $this->afd->AFDTitle;
                 $comment->articleID = $this->afd->articleID;
                 $comment->comment_UserCheck = $current_comment_UserCheck;
                 //liligago need to write for comment such as delete, keep and etc.
                 $comment->comment = $bBlock[1];
                 $comment->comment_User = $signature->userID;
                 $comment->comment_UserPosition = $signature->userID_StartPos;
                 $comment->comment_UserTitle = $signature->userTitle;
                 $comment->comment_UserURL = $signature->userURL;
                 $comment->comment_UserURLType = $signature->userURLType;
                 $comment->comment_Date = $signature->date;
                 $comment->comment_Time = $signature->time;
                 $comment->comment_DateTime = date('Y-m-d H:i:s', strtotime($signature->date . " " . $signature->time));
                 $comment->comment_Note = $bBlock[2];
                 $comment->comment_ExtraNote = $debate_included[1];
                 if ($bBlock[0] == 1 && $debate_included[0] == 1) {
                     $comment->comment_Type = 1;
                 } else {
                     if ($bBlock[0] == 1) {
                         $comment->comment_Type = "1Error";
                     } else {
                         if ($debate_included[0] == 1) {
                             $comment->comment_Type = "Flag_Text";
                         } else {
                             $comment->comment_Type = 0;
                         }
                     }
                 }
                 $comment->comment_Type2 = $bBlock[3];
                 if ($this->distinguishComments->distinguishPercentage >= 80) {
                     $comment->flag_DoNotVisualize_Comment = 0;
                 } else {
                     $comment->flag_DoNotVisualize_Comment = 1;
                 }
                 $comment->distinguishPercentage = $this->distinguishComments->distinguishPercentage;
                 //if(!empty($comment->comment_Note))
                 //    $GLOBALS['log'] .="<br/><span class='percentage'> Comment Note:</span><br/> ".strip_tags($comment->comment_Note);
                 if (strlen($comment->comment_Type) == strlen("Flag_Text")) {
                     $GLOBALS['log'] .= "<br/><span class='bad'> Flag_Text</span>";
                 }
                 //update the comment table
                 $comment->update_Comment();
                 $GLOBALS['log'] .= "<hr style='border: 0; border-top: 1px solid #FF3339;'/>";
             }
         } else {
             $GLOBALS['log'] .= "<br/><span class='startCall'> By pass by flag_DoNotParse = 1.</span>";
         }
     } catch (Exception $e) {
         echo 'Caught exception: ', $e->getMessage(), "\n";
     }
     $GLOBALS['log'] .= "<br/><span class='endCall'>**** End Called ParseAFD_OtherComment->parseAFD_Content()*******************</span>";
 }
示例#28
0
 /**
  * Sign the request, setting the `oauth_signature_method` and `oauth_signature`.
  *
  * @param   Signature  signature
  * @param   Consumer   consumer
  * @param   Token      token
  * @return  $this
  * @uses    Signature::sign
  */
 public function sign(Signature $signature, Consumer $consumer, Token $token = NULL)
 {
     // Create a new signature class from the method
     $this->param('oauth_signature_method', $signature->name);
     // Sign the request using the consumer and token
     $this->param('oauth_signature', $signature->sign($this, $consumer, $token));
     return $this;
 }
示例#29
0
<?php

loader_import('saf.GUI.Pager');
if (!$parameters['offset']) {
    $parameters['offset'] = 0;
}
$limit = 100;
$signature = new Signature();
$signature->orderBy('ts asc');
$signature->limit($limit);
$signature->offset($parameters['offset']);
$parameters['list'] = $signature->find(array('petition_id' => $parameters['id']));
$parameters['total'] = $signature->total;
$pg = new Pager($parameters['offset'], $limit, $signature->total);
$pg->setUrl(site_prefix() . '/index/petition-signatures-action/id.%s?', $parameters['id']);
$pg->getInfo();
template_simple_register('pager', $pg);
foreach ($parameters['list'] as $k => $v) {
    $parameters['list'][$k]->num = $k + 1 + $parameters['offset'];
}
page_title(intl_get('Signatures'));
echo template_simple('signatures.spt', $parameters);
示例#30
-1
 /**
  * Check oauth request signature
  *
  * @params array $config
  * @return boolean
  */
 public function verifyOauthSignature($config)
 {
     $proxy =& new RequestProxyController($this->Controller);
     $params = $proxy->parameters();
     $token = '';
     if (isset($params['oauth_token'])) {
         $token = $params['oauth_token'];
     }
     $serverRegistry =& new ServerRegistry();
     $this->tokenData = $serverRegistry->AccessServerToken->find(array('AccessServerToken.token' => $token, 'AccessServerToken.authorized' => 1));
     try {
         $valid = Signature::verify($this->Controller, array('consumer_secret' => $this->tokenData['ServerRegistry']['consumer_secret'], 'token_secret' => $this->tokenData['AccessServerToken']['token_secret']));
     } catch (Exception $e) {
         $valid = false;
     }
     if (!empty($config['exit']) && !$valid) {
         Configure::write('debug', 0);
         header("HTTP/1.1 401 Unauthorized");
         echo "Invalid OAuth Request";
         exit;
     }
     return $valid;
 }