All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.sap.cloud.mt.subscription.HanaEncryptionTool Maven / Gradle / Ivy

There is a newer version: 3.3.3
Show newest version
package com.sap.cloud.mt.subscription;

import com.sap.cloud.mt.subscription.exceptions.InternalError;
import com.sap.xsa.core.instancemanager.client.InstanceCreationOptions;

import java.util.HashMap;
import java.util.Map;

public class HanaEncryptionTool {
    private HanaEncryptionTool() {
    }

    public static void addEncryptionParameter(InstanceCreationOptions instanceCreationOptions, DbEncryptionMode encryptionMode,
                                              String globalAccountId,
                                              String subAccountId,
                                              String applicationName) throws InternalError {
        if (encryptionMode == null) {
            return;
        }
        if (instanceCreationOptions == null) {
            throw new InternalError("Instance create options is initial");
        }
        Map parameters = instanceCreationOptions.getProvisioningParameters();
        if (parameters == null) {
            parameters = new HashMap<>();
        }
        Map dataEncryption = new HashMap<>();
        dataEncryption.put("mode", encryptionMode.getValue());
        parameters.put("dataEncryption", dataEncryption);
        Map subscriptionContext = new HashMap<>();
        subscriptionContext.put("globalAccountID", globalAccountId);
        subscriptionContext.put("subAccountID", subAccountId);
        subscriptionContext.put("applicationName", applicationName);
        parameters.put("subscriptionContext", subscriptionContext);
        instanceCreationOptions.withProvisioningParameters(parameters);
    }

    public enum DbEncryptionMode {
        DEDICATED_KEY("DEDICATED_KEY"), MANAGED_KEY("MANAGED_KEY");
        private final String value;

        DbEncryptionMode(String value) {
            this.value = value;
        }

        public String getValue() {
            return value;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy