@@ -39,8 +39,8 @@ discard block |
||
| 39 | 39 | public function setValue($key, $value, $expire=0) |
| 40 | 40 | { |
| 41 | 41 | $envelope = array("expire"=>$expire, |
| 42 | - "createdAt"=>time(), |
|
| 43 | - "value"=>$value); |
|
| 42 | + "createdAt"=>time(), |
|
| 43 | + "value"=>$value); |
|
| 44 | 44 | $filename = $this->_stateFilename($key); |
| 45 | 45 | |
| 46 | 46 | file_put_contents($filename, serialize($envelope)); |
@@ -70,11 +70,11 @@ discard block |
||
| 70 | 70 | if (file_exists($filename)) { |
| 71 | 71 | $envelope = unserialize(file_get_contents($filename)); |
| 72 | 72 | if ($envelope["expire"]!=0) { |
| 73 | - // This data is time-limited. If it's too old we discard it. |
|
| 74 | - if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
| 75 | - $this->unsetValue($key); |
|
| 76 | - return NULL; |
|
| 77 | - } |
|
| 73 | + // This data is time-limited. If it's too old we discard it. |
|
| 74 | + if (time()-$envelope["createdAt"] > $envelope["expire"]) { |
|
| 75 | + $this->unsetValue($key); |
|
| 76 | + return NULL; |
|
| 77 | + } |
|
| 78 | 78 | } |
| 79 | 79 | return $envelope["value"]; |
| 80 | 80 | } |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | public function encrypt($data); |
| 42 | 42 | |
| 43 | 43 | /** |
| 44 | - * Decrypts the given data. |
|
| 44 | + * Decrypts the given data. |
|
| 45 | 45 | * |
| 46 | 46 | * @param String $data Data to decrypt. |
| 47 | 47 | * |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | /** |
| 60 | - * Decrypts the given data. |
|
| 60 | + * Decrypts the given data. |
|
| 61 | 61 | * |
| 62 | 62 | * @param String $data Data to decrypt. |
| 63 | 63 | * |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | protected $_userSecretStorage; |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * Constructor. |
|
| 38 | + * Constructor. |
|
| 39 | 39 | */ |
| 40 | 40 | public function __construct($config, $secretconfig = array()) |
| 41 | 41 | { |
@@ -127,7 +127,7 @@ |
||
| 127 | 127 | */ |
| 128 | 128 | public function __construct($config, $secretconfig = array()) |
| 129 | 129 | { |
| 130 | - parent::__construct($config, $secretconfig); |
|
| 130 | + parent::__construct($config, $secretconfig); |
|
| 131 | 131 | |
| 132 | 132 | $this->_userClass = isset($config['userClass']) ? $config['userClass'] : "tiqrPerson"; |
| 133 | 133 | $this->_dnPattern = isset($config['dnPattern']) ? $config['dnPattern'] : "%s"; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | public function createUser($userId, $displayName) |
| 44 | 44 | { |
| 45 | 45 | $user = array("userId"=>$userId, |
| 46 | - "displayName"=>$displayName); |
|
| 46 | + "displayName"=>$displayName); |
|
| 47 | 47 | return $this->_saveUser($userId, $user); |
| 48 | 48 | } |
| 49 | 49 | |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | { |
| 78 | 78 | if ($data = $this->_loadUser($userId)) { |
| 79 | 79 | if (isset($data["notificationType"])) { |
| 80 | - return $data["notificationType"]; |
|
| 80 | + return $data["notificationType"]; |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | return NULL; |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | if ($data = $this->_loadUser($userId)) { |
| 104 | 104 | if (isset($data["notificationAddress"])) { |
| 105 | - return $data["notificationAddress"]; |
|
| 105 | + return $data["notificationAddress"]; |
|
| 106 | 106 | } |
| 107 | 107 | } |
| 108 | 108 | return NULL; |
@@ -94,8 +94,8 @@ |
||
| 94 | 94 | */ |
| 95 | 95 | public function getPath() |
| 96 | 96 | { |
| 97 | - if (substr($this->_path, -1)!="/") return $this->_path."/"; |
|
| 98 | - return $this->_path; |
|
| 97 | + if (substr($this->_path, -1)!="/") return $this->_path."/"; |
|
| 98 | + return $this->_path; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | } |
@@ -90,9 +90,9 @@ |
||
| 90 | 90 | */ |
| 91 | 91 | public function verifyResponse($response, $secret, $challenge, $sessionKey) |
| 92 | 92 | { |
| 93 | - $expected = $this->calculateResponse($secret, $challenge, $sessionKey); |
|
| 93 | + $expected = $this->calculateResponse($secret, $challenge, $sessionKey); |
|
| 94 | 94 | |
| 95 | - return ($expected == $response); |
|
| 95 | + return ($expected == $response); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -48,24 +48,24 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | protected function _getHash ($secret, $counter) |
| 50 | 50 | { |
| 51 | - // Counter |
|
| 52 | - //the counter value can be more than one byte long, so we need to go multiple times |
|
| 53 | - $cur_counter = array(0,0,0,0,0,0,0,0); |
|
| 54 | - for($i=7;$i>=0;$i--) |
|
| 55 | - { |
|
| 56 | - $cur_counter[$i] = pack ('C*', $counter); |
|
| 57 | - $counter = $counter >> 8; |
|
| 58 | - } |
|
| 59 | - $bin_counter = implode($cur_counter); |
|
| 60 | - // Pad to 8 chars |
|
| 61 | - if (strlen ($bin_counter) < 8) |
|
| 62 | - { |
|
| 63 | - $bin_counter = str_repeat (chr(0), 8 - strlen ($bin_counter)) . $bin_counter; |
|
| 64 | - } |
|
| 51 | + // Counter |
|
| 52 | + //the counter value can be more than one byte long, so we need to go multiple times |
|
| 53 | + $cur_counter = array(0,0,0,0,0,0,0,0); |
|
| 54 | + for($i=7;$i>=0;$i--) |
|
| 55 | + { |
|
| 56 | + $cur_counter[$i] = pack ('C*', $counter); |
|
| 57 | + $counter = $counter >> 8; |
|
| 58 | + } |
|
| 59 | + $bin_counter = implode($cur_counter); |
|
| 60 | + // Pad to 8 chars |
|
| 61 | + if (strlen ($bin_counter) < 8) |
|
| 62 | + { |
|
| 63 | + $bin_counter = str_repeat (chr(0), 8 - strlen ($bin_counter)) . $bin_counter; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - // HMAC |
|
| 67 | - $hash = hash_hmac ('sha1', $bin_counter, $secret); |
|
| 68 | - return $hash; |
|
| 66 | + // HMAC |
|
| 67 | + $hash = hash_hmac ('sha1', $bin_counter, $secret); |
|
| 68 | + return $hash; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | /** |
@@ -76,22 +76,22 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | protected function _truncate($hash, $length = 6) |
| 78 | 78 | { |
| 79 | - // Convert to dec |
|
| 80 | - foreach(str_split($hash,2) as $hex) |
|
| 81 | - { |
|
| 82 | - $hmac_result[]=hexdec($hex); |
|
| 83 | - } |
|
| 79 | + // Convert to dec |
|
| 80 | + foreach(str_split($hash,2) as $hex) |
|
| 81 | + { |
|
| 82 | + $hmac_result[]=hexdec($hex); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - // Find offset |
|
| 86 | - $offset = $hmac_result[19] & 0xf; |
|
| 85 | + // Find offset |
|
| 86 | + $offset = $hmac_result[19] & 0xf; |
|
| 87 | 87 | |
| 88 | - // Algorithm from RFC |
|
| 89 | - return |
|
| 90 | - ( |
|
| 91 | - (($hmac_result[$offset+0] & 0x7f) << 24 ) | |
|
| 92 | - (($hmac_result[$offset+1] & 0xff) << 16 ) | |
|
| 93 | - (($hmac_result[$offset+2] & 0xff) << 8 ) | |
|
| 94 | - ($hmac_result[$offset+3] & 0xff) |
|
| 95 | - ) % pow(10,$length); |
|
| 88 | + // Algorithm from RFC |
|
| 89 | + return |
|
| 90 | + ( |
|
| 91 | + (($hmac_result[$offset+0] & 0x7f) << 24 ) | |
|
| 92 | + (($hmac_result[$offset+1] & 0xff) << 16 ) | |
|
| 93 | + (($hmac_result[$offset+2] & 0xff) << 8 ) | |
|
| 94 | + ($hmac_result[$offset+3] & 0xff) |
|
| 95 | + ) % pow(10,$length); |
|
| 96 | 96 | } |
| 97 | 97 | } |