]> git.mxchange.org Git - hub.git/blobdiff - application/hub/classes/package/class_NetworkPackage.php
Added code ...
[hub.git] / application / hub / classes / package / class_NetworkPackage.php
index 3fdc59eed8924de900deb1cf5ae3da6f38351ef2..af1de4a2a5319b5d33b080685f8b509014039550 100644 (file)
@@ -346,6 +346,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         *
         * @param       $decodedData    Array with decoded data
         * @return      $hash                   Private key's hash
+        * @throws      InvalidPrivateKeyHashException  If the private key's hash is not valid
         */
        private function determineSenderPrivateKeyHash (array $decodedData) {
                // Get DHT instance
@@ -360,6 +361,12 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                        //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderData=' . print_r($senderData, TRUE));
                        assert(isset($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH]));
 
+                       // Don't accept empty hashes
+                       if (empty($senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH])) {
+                               // Don't accept
+                               throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in senderData'), self::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
+                       } // END - if
+
                        // Return it
                        return $senderData[NodeDistributedHashTableDatabaseWrapper::DB_COLUMN_PRIVATE_KEY_HASH];
                } // END - if
@@ -371,7 +378,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                // Don't accept empty keys
                if (empty($decodedData[self::PACKAGE_CONTENT_PRIVATE_KEY_HASH])) {
                        // This needs fixing
-                       die('[' . __METHOD__ . ':' . __LINE__ . ':] Empty private key hash: decodedData=' . print_r($decodedData, TRUE));
+                       throw new InvalidPrivateKeyHashException(array($this, $senderData, 'empty hash in decodedData'), self::EXCEPTION_INVALID_PRIVATE_KEY_HASH);
                } // END - if
 
                // There is no DHT entry so, accept the hash from decoded data