public void doEncryption(boolean encrypt) {
    AmbariManagementController ambariManagementController = injector.getInstance(AmbariManagementController.class);
    Encryptor<Config> configEncryptor = injector.getInstance(ConfigPropertiesEncryptor.class);
    Clusters clusters = ambariManagementController.getClusters();
    if (clusters != null) {
      Map<String, Cluster> clusterMap = clusters.getClusters();
      if (clusterMap != null && !clusterMap.isEmpty()) {
        for (final Cluster cluster : clusterMap.values()) {
          Collection<Config> configs = cluster.getAllConfigs();
          for (Config config : configs) {
            if (encrypt) {
              configEncryptor.encryptSensitiveData(config);
            } else {
              configEncryptor.decryptSensitiveData(config);
            }
            config.save();
          }
        }
      }
    }
  }
@param encrypt selects mode: true=encrypt, false=decrypt
ambari-server/src/main/java/org/apache/ambari/server/security/encryption/SensitiveDataEncryption.java