Author: chabotc
Date: Fri Aug  1 15:10:44 2008
New Revision: 681865

URL: http://svn.apache.org/viewvc?rev=681865&view=rev
Log:
Recent contributed patch changed the private key caching to cache an openssl 
-resource-, woops my bad for allowing that in. Removed caching of priv key 
handling all together, it was put there in the first place when we did an 
expensive command line key conversion, which no longer is the case

Modified:
    incubator/shindig/trunk/php/src/gadgets/SigningFetcher.php
    incubator/shindig/trunk/php/src/gadgets/SigningFetcherFactory.php

Modified: incubator/shindig/trunk/php/src/gadgets/SigningFetcher.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/SigningFetcher.php?rev=681865&r1=681864&r2=681865&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/SigningFetcher.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/SigningFetcher.php Fri Aug  1 
15:10:44 2008
@@ -227,14 +227,6 @@
                return $list;
        }
 
-       /*
-       private function allowParam($paramName)
-       {
-               $canonParamName = strtolower($paramName);
-               return (! (substr($canonParamName, 0, 5) == "oauth" || 
substr($canonParamName, 0, 6) == "xoauth" || substr($canonParamName, 0, 9) == 
"opensocial")) && ereg(SigningFetcher::$ALLOWED_PARAM_NAME, $canonParamName);
-       }
-       */
-       
        private function allowParam($paramName)
        {
                $canonParamName = strtolower($paramName);

Modified: incubator/shindig/trunk/php/src/gadgets/SigningFetcherFactory.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/gadgets/SigningFetcherFactory.php?rev=681865&r1=681864&r2=681865&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/gadgets/SigningFetcherFactory.php (original)
+++ incubator/shindig/trunk/php/src/gadgets/SigningFetcherFactory.php Fri Aug  
1 15:10:44 2008
@@ -1,4 +1,5 @@
 <?php
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -48,42 +49,31 @@
                if (! empty($keyFile)) {
                        $privateKey = null;
                        try {
-                               // check if the converted from PKCS8 key is in 
cache, if not, convert it
-                               $cache = Config::get('data_cache');
-                               $cache = new $cache();
-                               if (($cachedKey = 
$cache->get(md5("RSA_PRIVATE_KEY_" . $this->keyName))) !== false) {
-                                       $rsa_private_key = $cachedKey;
+                               if (file_exists($keyFile)) {
+                                       if (is_readable($keyFile)) {
+                                               $rsa_private_key = 
@file_get_contents($keyFile);
+                                       } else {
+                                               throw new Exception("Could not 
read keyfile ($keyFile), check the file name and permission");
+                                       }
+                               }
+                               if (! $rsa_private_key) {
+                                       $rsa_private_key = '';
                                } else {
-                                       if (file_exists($keyFile)) {
-                                               if (is_readable($keyFile)) {
-                                                       $rsa_private_key = 
@file_get_contents($keyFile);
-                                               } else {
-                                                       throw new 
Exception("Could not read keyfile ($keyFile), check the file name and 
permission");
+                                       $phrase = 
Config::get('private_key_phrase') != '' ? (Config::get('private_key_phrase')) : 
null;
+                                       if (strpos($rsa_private_key, 
"-----BEGIN") === false) {
+                                               $privateKey .= "-----BEGIN 
PRIVATE KEY-----\n";
+                                               $chunks = 
str_split($rsa_private_key, 64);
+                                               foreach ($chunks as $chunk) {
+                                                       $privateKey .= $chunk . 
"\n";
                                                }
-                                       }
-                                       if (! $rsa_private_key) {
-                                               $rsa_private_key = "";
+                                               $privateKey .= "-----END 
PRIVATE KEY-----";
                                        } else {
-                                               $phrase = 
Config::get('private_key_phrase') != '' ? (Config::get('private_key_phrase')) : 
null;
-                                               if (strpos($rsa_private_key, 
"-----BEGIN") === false) {
-                                                       $privateKey .= 
"-----BEGIN PRIVATE KEY-----\n";
-                                                       $chunks = 
str_split($rsa_private_key, 64);
-                                                       foreach ($chunks as 
$chunk) {
-                                                               $privateKey .= 
$chunk . "\n";
-                                                       }
-                                                       $privateKey .= 
"-----END PRIVATE KEY-----";
-                                               } else {
-                                                       $privateKey = 
$rsa_private_key;
-                                               }
-                                               if (! $rsa_private_key = 
@openssl_pkey_get_private($privateKey, $phrase)) {
-                                                       throw new 
Exception("Could not create the key");
-                                               }
-                                       }
-                                       $cache->set(md5("RSA_PRIVATE_KEY_" . 
$this->keyName), $rsa_private_key);
-                                       if (! $rsa_private_key = 
@openssl_pkey_get_private($privateKey, $phrase)) {
-                                               throw new Exception("Could not 
create the key");
+                                               $privateKey = $rsa_private_key;
                                        }
                                }
+                               if (! $rsa_private_key = 
@openssl_pkey_get_private($privateKey, $phrase)) {
+                                       throw new Exception("Could not create 
the key");
+                               }
                        } catch (Exception $e) {
                                throw new Exception("Error loading private key: 
" . $e);
                        }


Reply via email to