Class BackupProvider

java.lang.Object
org.eblocker.server.http.backup.BackupProvider
Direct Known Subclasses:
AppModulesBackupProvider, DevicesBackupProvider, HttpsKeysBackupProvider, OpenVpnClientBackupProvider, OpenVpnServerBackupProvider, RegistrationBackupProvider, TorConfigBackupProvider

public abstract class BackupProvider extends Object
A BackupProvider exports/imports configuration data to/from one or more files in the configuration JAR file. A new BackupProvider is created for each export, import and verification action. It stores any warnings that may have occurred during an action. For example, if the password was not provided for the import (because the user forgot it), all providers that restore encrypted data should add a warning that they could not restore it.
  • Field Details

    • encryptionEnabled

      protected boolean encryptionEnabled
  • Constructor Details

    • BackupProvider

      public BackupProvider()
    • BackupProvider

      public BackupProvider(@Nullable org.eblocker.crypto.CryptoService cryptoService)
      Create a backup provider with optional support for @JsonEncrypt annotation.
      Parameters:
      cryptoService - if not null, a JsonEncryptionModule is registered in the ObjectMapper
  • Method Details

    • exportConfiguration

      public abstract void exportConfiguration(JarOutputStream outputStream) throws IOException
      Export the configuration to the given JarOutputStream.
      Throws:
      IOException
    • importConfiguration

      public abstract void importConfiguration(JarInputStream inputStream, int schemaVersion) throws IOException
      Import the configuration from the given JarInputStream.
      Throws:
      IOException
    • verifyConfiguration

      public abstract void verifyConfiguration(JarInputStream inputStream, int schemaVersion) throws IOException
      Verify the configuration from the given JarInputStream.
      Throws:
      IOException
    • writeNextEntry

      protected static void writeNextEntry(JarOutputStream outputStream, String name, byte[] content) throws IOException
      Write the next entry into the given JarOutputStream.
      Parameters:
      outputStream - JarOutputStream
      name - name of the next entry
      content - content of the next entry
      Throws:
      IOException
    • getNextEntry

      protected static void getNextEntry(JarInputStream jarStream, String name) throws IOException
      Read the next entry from a JarInputStream and make sure it has the expected name and is not a directory
      Parameters:
      jarStream - JarInputStream
      name - expected name of the next entry. If it does not match, a CorruptedBackupException is thrown.
      Throws:
      IOException
    • addWarning

      protected void addWarning(BackupWarning warning)
    • getWarnings

      public List<BackupWarning> getWarnings()
    • canEncrypt

      public boolean canEncrypt()
    • canDecrypt

      public boolean canDecrypt()