Advanced Encryption Problems when running the command provided in the KB

XMLWordPrintable

    • Type: Bug
    • Resolution: Not a bug
    • Priority: Highest
    • None
    • Affects Version/s: 7.0.0, 8.0.0
    • Component/s: Environment - Other
    • 1
    • Severity 3 - Minor

      Issue summary

      Users are experiencing exception errors in the Advanced Encryption command provided in the KB - Advanced encryption.

      Environment

      • Bitbucket 7.x and 8.x

      Steps to Reproduce

      • Follow the steps in the KB:
        Create the JSON file:
        • example:
      {"plaintext password":"Password123","algorithm":"AES","algorithmKey":"AES"} 
      • run the command:
      java -cp "./*" com.atlassian.db.config.password.tools.CipherTool -c com.atlassian.db.config.password.ciphers.algorithm.AlgorithmCipher 

      Expected Results

      If successful, the encryption tool would have generated three files and printed the output JSON object that would be used later in the bitbucket.properties file.

      Actual Results

      2023-07-19 16:48:58,969 main DEBUG [db.config.password.DefaultCipherProvider] Initiate cipher provider class: com.atlassian.db.config.password.ciphers.algorithm.AlgorithmCipher
      2023-07-19 16:48:59,771 main DEBUG [password.ciphers.algorithm.AlgorithmCipher] Initiate AlgorithmCipher
      2023-07-19 16:48:59,804 main DEBUG [password.ciphers.algorithm.AlgorithmCipher] Encrypting data...
      Exception in thread "main" com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
      at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:226)
      at com.google.gson.Gson.fromJson(Gson.java:927)
      at com.google.gson.Gson.fromJson(Gson.java:892)
      at com.google.gson.Gson.fromJson(Gson.java:841)
      at com.google.gson.Gson.fromJson(Gson.java:813)
      at com.atlassian.db.config.password.ciphers.algorithm.AlgorithmCipher.encrypt(AlgorithmCipher.java:118)
      at com.atlassian.db.config.password.tools.CipherTool.lambda$getOutputData$1(CipherTool.java:55)
      at java.util.Optional.map(Optional.java:215)
      at com.atlassian.db.config.password.tools.CipherTool.getOutputData(CipherTool.java:55)
      at com.atlassian.db.config.password.tools.CipherTool.main(CipherTool.java:36)
      Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
      at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)
      at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215)
      ... 9 more

      Workaround

      Run the command passing the JSON as an argument.

      Example:

      java -cp "./*" com.atlassian.db.config.password.tools.CipherTool -c com.atlassian.db.config.password.ciphers.algorithm.AlgorithmCipher -s -p "{"plainTextPassword":"Password123","algorithm":"AES","algorithmKey":"AES"}" 

            Assignee:
            Josh Aguilar
            Reporter:
            Luiz Elias (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: