Class EncryptionService

java.lang.Object
io.skipcheck.tm1.client.service.encryption.EncryptionService

public final class EncryptionService extends Object
Encryption at rest (schema 11.8.35, except where a method says): the model's files encrypted with a data encryption key, itself protected by a key from a key management service. The provider settings are a KeyProtectSettingsPatch (IBM Key Protect), VaultSettingsPatch (HashiCorp Vault) or LocalKeyFileProviderSettingsPatch (a key file made with the local GSKit).

What TM1 (11.8) does here that you might not expect:

  • The local key file provider needs GSKit's gsk9capicmd_64, which a TM1 install may lack (the Docker image used in this project's tests does): validation then reports "Could not generate a new key using the local GSKit installation".
  • On a server that isn't encrypted, the changing actions fail with a bare 400 and an error code's name for a message: DataModelConversion (configure, disable), DataFileConversion (encrypt or decrypt a file), DataEncryptionKeyRotationFailed and RotateDataModelKey.
  • Each must be run by a full administrator.

Encrypt the model with a key from IBM Key Protect, checking the settings first:

// Check the settings first: the report says what's wrong, without secrets
KeyProtectSettingsPatch keyProtect = KeyProtectSettingsPatch.builder()
	.serviceEndpoint("https://us-south.kms.cloud.ibm.com")
	.instanceID("8f2c1d6e-0000-4000-8000-000000000000")
	.authRef("/run/secrets/key-protect-api-key")
	.keyRef("planning-root-key")
	.build();
return tm1.encryption()
	.validate(keyProtect)
	.flatMap(report -> Boolean.TRUE.equals(report.isValid()) ? tm1.encryption().configure(keyProtect)
			: Mono.error(new IllegalStateException("Can't encrypt: " + report.issues())));

Rotate the data encryption key:

// A new data encryption key; TM1 re-encrypts the whole model with it
return tm1.encryption().rotateDataEncryptionKey();
  • Constructor Details

    • EncryptionService

      public EncryptionService(Tm1Session session)
      A service sending its requests through session.
      Parameters:
      session - the session
  • Method Details

    • validate

      @Tm1Endpoint("FunctionImport ValidateEncryptionAtRestSettings") public reactor.core.publisher.Mono<EncryptionAtRestValidationReport> validate(EncryptionAtRestProviderSettingsPatch settings)
      ValidateEncryptionAtRestSettings: checks the provider settings would work now (the key service is reachable and allows it, and the key exists), changing nothing.
      Parameters:
      settings - the provider settings
      Returns:
      the report: whether they're valid, and if not, the issues; never secrets
    • configure

      @Tm1Endpoint("ActionImport ConfigureEncryptionAtRest") public reactor.core.publisher.Mono<Void> configure(EncryptionAtRestProviderSettingsPatch settings)
      ConfigureEncryptionAtRest: validates the provider settings, then applies them; a server not yet encrypted is encrypted.
      Parameters:
      settings - the provider settings
      Returns:
      completes when they're applied
    • disable

      @Tm1Endpoint("ActionImport DisableEncryptionAtRest") public reactor.core.publisher.Mono<Void> disable()
      DisableEncryptionAtRest: decrypts the model and stops encrypting it.
      Returns:
      completes when it's done
    • rotateDataEncryptionKey

      @Tm1Endpoint("ActionImport RotateDataEncryptionKey") public reactor.core.publisher.Mono<Void> rotateDataEncryptionKey()
      RotateDataEncryptionKey: makes a new data encryption key and re-encrypts the whole model with it.
      Returns:
      completes when it's done
    • rotateDataModelKey

      @Tm1Endpoint("ActionImport RotateDataModelKey") public reactor.core.publisher.Mono<Void> rotateDataModelKey()
      RotateDataModelKey: rotates the model key.
      Returns:
      completes when it's done
    • encryptFile

      @Tm1Endpoint("ActionImport EncryptDataFile") public reactor.core.publisher.Mono<Void> encryptFile(String source, String destination, EncryptionFileType type)
      EncryptDataFile (schema 11.3.0): encrypts one file, such as an exported cube.
      Parameters:
      source - the file, relative to the data directory or absolute
      destination - where the encrypted file goes
      type - what the file is: a model object, a transaction log or an audit log
      Returns:
      completes when it's written
    • decryptFile

      @Tm1Endpoint("ActionImport DecryptDataFile") public reactor.core.publisher.Mono<Void> decryptFile(String source, String destination, EncryptionFileType type)
      DecryptDataFile (schema 11.3.0): decrypts one file.
      Parameters:
      source - the encrypted file, relative to the data directory or absolute
      destination - where the decrypted file goes
      type - what the file is
      Returns:
      completes when it's written
    • encryptModel

      @Deprecated(since="11.8.35") @Tm1Endpoint("ActionImport EncryptDataModel") public reactor.core.publisher.Mono<Void> encryptModel(@Nullable Duration timeUntilShutdown)
      Deprecated.
      Deprecated in TM1 schema 11.8.35: use configure(EncryptionAtRestProviderSettingsPatch).
      EncryptDataModel (schema 11.3.0): encrypts the model, then shuts the server down.
      Parameters:
      timeUntilShutdown - how long to wait before shutting down, or null for TM1's
      Returns:
      completes when it's started
    • decryptModel

      @Deprecated(since="11.8.35") @Tm1Endpoint("ActionImport DecryptDataModel") public reactor.core.publisher.Mono<Void> decryptModel(@Nullable Duration timeUntilShutdown)
      Deprecated.
      Deprecated in TM1 schema 11.8.35: use disable().
      DecryptDataModel (schema 11.3.0): decrypts the model, then shuts the server down.
      Parameters:
      timeUntilShutdown - how long to wait before shutting down, or null for TM1's
      Returns:
      completes when it's started