]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12841 Support AES 256 Settings Encryption
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 11 Aug 2020 20:08:01 +0000 (15:08 -0500)
committersonartech <sonartech@sonarsource.com>
Fri, 14 Aug 2020 20:16:19 +0000 (20:16 +0000)
server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/EncryptActionTest.java
server/sonar-webserver-webapi/src/test/java/org/sonar/server/setting/ws/GenerateSecretKeyActionTest.java
sonar-plugin-api-impl/src/main/java/org/sonar/api/config/internal/AesCipher.java

index 8991237379af52abec75e48ca416c6678bda1c1b..89194a4895eca93d528d7103acfc91b6aca3f9f6 100644 (file)
@@ -20,6 +20,7 @@
 package org.sonar.server.setting.ws;
 
 import java.io.File;
+import java.nio.charset.StandardCharsets;
 import javax.annotation.Nullable;
 import org.apache.commons.io.FileUtils;
 import org.junit.Before;
@@ -59,7 +60,7 @@ public class EncryptActionTest {
     logInAsSystemAdministrator();
 
     File secretKeyFile = folder.newFile();
-    FileUtils.writeStringToFile(secretKeyFile, "fCVFf/JHRi8Qwu5KLNva7g==");
+    FileUtils.writeStringToFile(secretKeyFile, "fCVFf/JHRi8Qwu5KLNva7g==", StandardCharsets.UTF_8);
 
     encryption.setPathToSecretKey(secretKeyFile.getAbsolutePath());
   }
index 480161997849cc5e8639aac70a7925196c2c2af5..ffa3862a6fb71270918e3de80da5be4715342d98 100644 (file)
@@ -21,6 +21,7 @@ package org.sonar.server.setting.ws;
 
 import java.io.File;
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import org.apache.commons.io.FileUtils;
 import org.junit.Rule;
 import org.junit.Test;
@@ -55,7 +56,7 @@ public class GenerateSecretKeyActionTest {
 
     String secretKey = result.getSecretKey();
     File file = temporaryFolder.newFile();
-    FileUtils.writeStringToFile(file, secretKey);
+    FileUtils.writeStringToFile(file, secretKey, StandardCharsets.UTF_8);
     encryption.setPathToSecretKey(file.getAbsolutePath());
     String encryptedValue = encryption.encrypt("my value");
     String decryptedValue = encryption.decrypt(encryptedValue);
index e6b14f3d9dbc3f1be98448652953622916af11c4..b67640a1e5f6f651e1b1a611998fb37c5052617d 100644 (file)
@@ -36,11 +36,7 @@ import org.sonar.api.CoreProperties;
 import static java.nio.charset.StandardCharsets.UTF_8;
 
 final class AesCipher implements Cipher {
-
-  // Can't be increased because of Java 6 policy files :
-  // https://confluence.terena.org/display/~visser/No+256+bit+ciphers+for+Java+apps
-  // http://java.sun.com/javase/6/webnotes/install/jre/README
-  static final int KEY_SIZE_IN_BITS = 128;
+  static final int KEY_SIZE_IN_BITS = 256;
 
   private static final String CRYPTO_KEY = "AES";