[packages/php-google-api] add support for signing via seclib

glen glen at pld-linux.org
Tue Jul 9 16:41:47 CEST 2013


commit c2d5982663793f11e866b04b1d146565ec31a7f5
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Tue Jul 9 17:37:17 2013 +0300

    add support for signing via seclib

 gapi.patch          | 45 +++++++++++++++++++++++++++++++++++++++++++++
 php-google-api.spec |  3 +++
 2 files changed, 48 insertions(+)
---
diff --git a/php-google-api.spec b/php-google-api.spec
index 2de96d8..8a278c1 100644
--- a/php-google-api.spec
+++ b/php-google-api.spec
@@ -12,6 +12,7 @@ Group:		Development/Languages/PHP
 Source0:	https://google-api-php-client.googlecode.com/files/google-api-php-client-%{version}.tar.gz
 # Source0-md5:	86db4e431096c9c32637842e214c6e26
 Patch0:		php52.patch
+Patch1:		gapi.patch
 URL:		https://code.google.com/p/google-api-php-client/
 BuildRequires:	rpm-php-pearprov >= 4.4.2-11
 BuildRequires:	rpmbuild(macros) >= 1.461
@@ -23,6 +24,7 @@ Requires:	php-hash
 Requires:	php-json
 Requires:	php-openssl
 Requires:	php-pcre
+Suggests:	php-seclib
 BuildArch:	noarch
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 
@@ -39,6 +41,7 @@ Latitude on your server.
 %setup -qc
 mv google-api-php-client/* .
 %patch0 -p1
+%patch1 -p8
 
 grep -rl require_once examples | xargs %{__sed} -i -e '
 	# fixup paths to source
diff --git a/gapi.patch b/gapi.patch
new file mode 100644
index 0000000..3e4f1a2
--- /dev/null
+++ b/gapi.patch
@@ -0,0 +1,45 @@
+# This patch file was generated by NetBeans IDE
+# This patch can be applied using context Tools: Apply Diff Patch action on respective folder.
+# It uses platform neutral UTF-8 encoding.
+# Above lines and this line are ignored by the patching process.
+--- C:/Users/ANDRES/Desktop/google-api-php-client/src/auth/Google_AssertionCredentials.php
++++ D:/xampp/htdocs/delfi/dgs/admin/library/gapi/src/auth/Google_AssertionCredentials.php
+@@ -50,7 +50,8 @@
+       $privateKey,
+       $privateKeyPassword = 'notasecret',
+       $assertionType = 'http://oauth.net/grant_type/jwt/1.0/bearer',
+-      $sub = false) {
++      $sub = false,
++      $signer = null) {
+     $this->serviceAccountName = $serviceAccountName;
+     $this->scopes = is_string($scopes) ? $scopes : implode(' ', $scopes);
+     $this->privateKey = $privateKey;
+@@ -58,6 +59,7 @@
+     $this->assertionType = $assertionType;
+     $this->sub = $sub;
+     $this->prn = $sub;
++    $this->signer = $signer;
+   }
+ 
+   public function generateAssertion() {
+@@ -94,8 +96,20 @@
+     );
+ 
+     $signingInput = implode('.', $segments);
++
++    if ($this->signer === 'phpseclib') {
++       require_once 'Crypt/RSA.php';
++       $rsa = new Crypt_RSA();
++       $rsa->setPassword($this->privateKeyPassword);
++       $rsa->loadKey($this->privateKey, CRYPT_RSA_PRIVATE_FORMAT_PKCS1);
++       $rsa->setSignatureMode(CRYPT_RSA_SIGNATURE_PKCS1);
++       $rsa->setHash('sha256');
++       $signature = $rsa->sign($signingInput);
++    } else {
+     $signer = new Google_P12Signer($this->privateKey, $this->privateKeyPassword);
+     $signature = $signer->sign($signingInput);
++    }
++
+     $segments[] = Google_Utils::urlSafeB64Encode($signature);
+ 
+     return implode(".", $segments);
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/php-google-api.git/commitdiff/c2d5982663793f11e866b04b1d146565ec31a7f5



More information about the pld-cvs-commit mailing list