Author: chabotc
Date: Thu Aug 14 02:05:18 2008
New Revision: 685824

URL: http://svn.apache.org/viewvc?rev=685824&view=rev
Log:
SHINDIG-514 by Artemy Tregubenko: Reduce Config::get usage in BasicBlobCrypter 
to simplify overriding

Modified:
    incubator/shindig/trunk/php/src/common/samplecontainer/BasicBlobCrypter.php

Modified: 
incubator/shindig/trunk/php/src/common/samplecontainer/BasicBlobCrypter.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/common/samplecontainer/BasicBlobCrypter.php?rev=685824&r1=685823&r2=685824&view=diff
==============================================================================
--- incubator/shindig/trunk/php/src/common/samplecontainer/BasicBlobCrypter.php 
(original)
+++ incubator/shindig/trunk/php/src/common/samplecontainer/BasicBlobCrypter.php 
Thu Aug 14 02:05:18 2008
@@ -47,11 +47,13 @@
        
        private $cipherKey;
        private $hmacKey;
+       protected $allowPlaintextToken;
 
        public function __construct()
        {
                $this->cipherKey = Config::get('token_cipher_key');
                $this->hmacKey = Config::get('token_hmac_key');
+               $this->allowPlaintextToken = 
Config::get('allow_plaintext_token');
        }
 
        /**
@@ -60,7 +62,7 @@
        public function wrap(Array $in)
        {
                $encoded = $this->serializeAndTimestamp($in);
-               if (! function_exists('mcrypt_module_open') && 
Config::get('allow_plaintext_token')) {
+               if (! function_exists('mcrypt_module_open') && 
$this->allowPlaintextToken) {
                        $cipherText = base64_encode($encoded);
                } else {
                        $cipherText = 
Crypto::aes128cbcEncrypt($this->cipherKey, $encoded);
@@ -86,7 +88,7 @@
        public function unwrap($in, $maxAgeSec)
        {
                //TODO remove this once we have a better way to generate a fake 
token in the example files
-               if (Config::get('allow_plaintext_token') && count(explode(':', 
$in)) == 6) {
+               if ($this->allowPlaintextToken && count(explode(':', $in)) == 
6) {
                        $data = explode(":", $in);
                        $out = array();
                        $out['o'] = $data[0];
@@ -100,7 +102,7 @@
                        $cipherText = substr($bin, 0, strlen($bin) - 
Crypto::$HMAC_SHA1_LEN);
                        $hmac = substr($bin, strlen($cipherText));
                        Crypto::hmacSha1Verify($this->hmacKey, $cipherText, 
$hmac);
-                       if (! function_exists('mcrypt_module_open') && 
Config::get('allow_plaintext_token')) {
+                       if (! function_exists('mcrypt_module_open') && 
$this->allowPlaintextToken) {
                                $plain = base64_decode($cipherText);
                        } else {
                                $plain = 
Crypto::aes128cbcDecrypt($this->cipherKey, $cipherText);


Reply via email to