/**
  * Checks if keys are missing in any of the storages and generates them if so.
  */
 protected function checkMissingKeysAndGenerate()
 {
     $settings = new Settings();
     if ($settings->publicKey->getValue() == $settings->publicKey->defaultValue or Crypto::getKeyGenTime() == Crypto::KEY_GENERATION_TIME_UNKNOWN or !file_exists(__DIR__ . Crypto::PUBLIC_KEY_JS_FILE)) {
         $this->generateKeysAndStoreAll();
     }
 }
 private function createPublicKeySetting()
 {
     $this->publicKey = new SystemSetting('publicKey', Piwik::translate('LoginEncrypted_SettingsPublicKeyTitle'));
     $this->publicKey->readableByCurrentUser = true;
     $this->publicKey->uiControlType = static::CONTROL_TEXTAREA;
     $this->publicKey->uiControlAttributes = array('readonly' => 'readonly');
     $this->publicKey->description = Piwik::translate('LoginEncrypted_SettingsPublicKeyDescription') . Crypto::getKeyGenTime();
     $this->publicKey->defaultValue = "None";
     $this->addSetting($this->publicKey);
 }