@@ -29,8 +29,8 @@ |
||
29 | 29 | * @param string $message exception message |
30 | 30 | * @param Exception $parent parent exception |
31 | 31 | */ |
32 | - public function __construct($message, $parent=null) |
|
33 | - { |
|
34 | - parent::__construct($message, 0, $parent); |
|
35 | - } |
|
32 | + public function __construct($message, $parent=null) |
|
33 | + { |
|
34 | + parent::__construct($message, 0, $parent); |
|
35 | + } |
|
36 | 36 | } |
37 | 37 | \ No newline at end of file |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | */ |
37 | 37 | private static function _hmac(string $crypto, string $keyBytes, string $text) : string |
38 | 38 | { |
39 | - $hash = hash_hmac($crypto, $text, $keyBytes); |
|
40 | - if (false === $hash) { |
|
41 | - throw new Exception("calculating hash_hmac failed"); |
|
42 | - } |
|
43 | - return $hash; |
|
39 | + $hash = hash_hmac($crypto, $text, $keyBytes); |
|
40 | + if (false === $hash) { |
|
41 | + throw new Exception("calculating hash_hmac failed"); |
|
42 | + } |
|
43 | + return $hash; |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | * alternative to "-S064" |
100 | 100 | */ |
101 | 101 | static function generateOCRA(string $ocraSuite, |
102 | - string $key, |
|
103 | - string $counter, |
|
104 | - string $question, |
|
105 | - string $password, |
|
106 | - string $sessionInformation, |
|
107 | - string $timeStamp) : string |
|
102 | + string $key, |
|
103 | + string $counter, |
|
104 | + string $question, |
|
105 | + string $password, |
|
106 | + string $sessionInformation, |
|
107 | + string $timeStamp) : string |
|
108 | 108 | { |
109 | 109 | $codeDigits = 0; |
110 | 110 | $crypto = ""; |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | public function createUser(string $userId, string $displayName) : void |
61 | 61 | { |
62 | 62 | $user = array("userId"=>$userId, |
63 | - "displayName"=>$displayName); |
|
63 | + "displayName"=>$displayName); |
|
64 | 64 | $this->_saveUser($userId, $user); |
65 | 65 | } |
66 | 66 | |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | { |
91 | 91 | if ($data = $this->_loadUser($userId)) { |
92 | 92 | if (isset($data["notificationType"])) { |
93 | - return $data["notificationType"]; |
|
93 | + return $data["notificationType"]; |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | return ''; |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | { |
114 | 114 | if ($data = $this->_loadUser($userId)) { |
115 | 115 | if (isset($data["notificationAddress"])) { |
116 | - return $data["notificationAddress"]; |
|
116 | + return $data["notificationAddress"]; |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | $this->logger->info('Unable to find notification address for user'); |
@@ -54,8 +54,8 @@ |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | $envelope = array("expire"=>$expire, |
57 | - "createdAt"=>time(), |
|
58 | - "value"=>$value); |
|
57 | + "createdAt"=>time(), |
|
58 | + "value"=>$value); |
|
59 | 59 | $filename = $this->getFilenameByKey($key); |
60 | 60 | |
61 | 61 | if (!file_put_contents($filename, serialize($envelope))) { |
@@ -571,17 +571,17 @@ discard block |
||
571 | 571 | } |
572 | 572 | |
573 | 573 | $metadata = array("service"=> |
574 | - array("displayName" => $this->_name, |
|
575 | - "identifier" => $this->_identifier, |
|
576 | - "logoUrl" => $this->_logoUrl, |
|
577 | - "infoUrl" => $this->_infoUrl, |
|
578 | - "authenticationUrl" => $authenticationUrl, |
|
579 | - "ocraSuite" => $this->_ocraSuite, |
|
580 | - "enrollmentUrl" => $enrollmentUrl |
|
581 | - ), |
|
582 | - "identity"=> |
|
583 | - array("identifier" =>$data["userId"], |
|
584 | - "displayName"=>$data["displayName"])); |
|
574 | + array("displayName" => $this->_name, |
|
575 | + "identifier" => $this->_identifier, |
|
576 | + "logoUrl" => $this->_logoUrl, |
|
577 | + "infoUrl" => $this->_infoUrl, |
|
578 | + "authenticationUrl" => $authenticationUrl, |
|
579 | + "ocraSuite" => $this->_ocraSuite, |
|
580 | + "enrollmentUrl" => $enrollmentUrl |
|
581 | + ), |
|
582 | + "identity"=> |
|
583 | + array("identifier" =>$data["userId"], |
|
584 | + "displayName"=>$data["displayName"])); |
|
585 | 585 | |
586 | 586 | $this->_unsetStateValue(self::PREFIX_ENROLLMENT, $enrollmentKey); |
587 | 587 | |
@@ -611,28 +611,28 @@ discard block |
||
611 | 611 | */ |
612 | 612 | public function getEnrollmentSecret(string $enrollmentKey): string |
613 | 613 | { |
614 | - $data = $this->_getStateValue(self::PREFIX_ENROLLMENT, $enrollmentKey); |
|
615 | - if (!is_array($data)) { |
|
616 | - $this->logger->error('getEnrollmentSecret: enrollment key not found'); |
|
617 | - throw new RuntimeException('enrollment key not found'); |
|
618 | - } |
|
619 | - $userId = $data["userId"] ?? NULL; |
|
620 | - $sessionId = $data["sessionId"] ?? NULL; |
|
621 | - if (!is_string($userId) || !(is_string($sessionId))) { |
|
622 | - throw new RuntimeException('getEnrollmentSecret: invalid enrollment data'); |
|
623 | - } |
|
624 | - $enrollmentData = [ |
|
625 | - "userId" => $userId, |
|
626 | - "sessionId" => $sessionId |
|
627 | - ]; |
|
628 | - $enrollmentSecret = $this->_uniqueSessionKey(); |
|
629 | - $this->_setStateValue( |
|
630 | - self::PREFIX_ENROLLMENT_SECRET, |
|
631 | - $enrollmentSecret, |
|
632 | - $enrollmentData, |
|
633 | - self::ENROLLMENT_EXPIRE |
|
634 | - ); |
|
635 | - return $enrollmentSecret; |
|
614 | + $data = $this->_getStateValue(self::PREFIX_ENROLLMENT, $enrollmentKey); |
|
615 | + if (!is_array($data)) { |
|
616 | + $this->logger->error('getEnrollmentSecret: enrollment key not found'); |
|
617 | + throw new RuntimeException('enrollment key not found'); |
|
618 | + } |
|
619 | + $userId = $data["userId"] ?? NULL; |
|
620 | + $sessionId = $data["sessionId"] ?? NULL; |
|
621 | + if (!is_string($userId) || !(is_string($sessionId))) { |
|
622 | + throw new RuntimeException('getEnrollmentSecret: invalid enrollment data'); |
|
623 | + } |
|
624 | + $enrollmentData = [ |
|
625 | + "userId" => $userId, |
|
626 | + "sessionId" => $sessionId |
|
627 | + ]; |
|
628 | + $enrollmentSecret = $this->_uniqueSessionKey(); |
|
629 | + $this->_setStateValue( |
|
630 | + self::PREFIX_ENROLLMENT_SECRET, |
|
631 | + $enrollmentSecret, |
|
632 | + $enrollmentData, |
|
633 | + self::ENROLLMENT_EXPIRE |
|
634 | + ); |
|
635 | + return $enrollmentSecret; |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -35,7 +35,6 @@ |
||
35 | 35 | * Supported options: |
36 | 36 | * path : Path to the directory where the user data is stored |
37 | 37 | * |
38 | - |
|
39 | 38 | */ |
40 | 39 | class Tiqr_UserSecretStorage_File implements Tiqr_UserSecretStorage_Interface |
41 | 40 | { |
@@ -42,7 +42,6 @@ |
||
42 | 42 | userid varchar(30) NOT NULL UNIQUE, |
43 | 43 | secret varchar(128), |
44 | 44 | ); |
45 | - |
|
46 | 45 | * @see Tiqr_UserSecretStorage::getSecretStorage() |
47 | 46 | * @see Tiqr_UserSecretStorage_Interface |
48 | 47 | * |
@@ -59,7 +59,6 @@ |
||
59 | 59 | ); |
60 | 60 | |
61 | 61 | CREATE INDEX IF NOT EXISTS index_tiqrstate_expire ON tiqrstate (expire); |
62 | - |
|
63 | 62 | * @see Tiqr_StateStorage::getStorage() |
64 | 63 | * @see Tiqr_StateStorage_StateStorageInterface |
65 | 64 | * |
@@ -54,7 +54,7 @@ |
||
54 | 54 | if ($prefix === $this->encryption->get_type()) { |
55 | 55 | // Decrypt the secret if it is prefixed with the current encryption type |
56 | 56 | // Remove the encryption type prefix before decrypting |
57 | - return $this->encryption->decrypt( substr($encryptedSecret, $pos+1) ); |
|
57 | + return $this->encryption->decrypt( substr($encryptedSecret, $pos+1) ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // Check the decryption array for the encryption type to see if there is an encryption |