Alon Bar-Lev has uploaded a new change for review. Change subject: pki: cleanup: Found reliance on default encoding ......................................................................
pki: cleanup: Found reliance on default encoding Change-Id: I181c9b3e26c5b941fe368b3287a7486b6b8f91e1 Signed-off-by: Alon Bar-Lev <alo...@redhat.com> --- M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/crypt/EncryptionUtils.java M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/hostinstall/OpenSslCAWrapper.java 2 files changed, 6 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/88/13188/1 diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/crypt/EncryptionUtils.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/crypt/EncryptionUtils.java index b3b36f5..bd94324 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/crypt/EncryptionUtils.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/crypt/EncryptionUtils.java @@ -167,7 +167,7 @@ EncryptUtilParams params = new EncryptUtilParams(keyMaterial, algorithm); cipher = Cipher.getInstance(params.algorithm); cipher.init(Cipher.ENCRYPT_MODE, params.secretKey); - encoding = cipher.doFinal(secret.getBytes()); + encoding = cipher.doFinal(secret.getBytes("UTF-8")); } catch (Exception e) { log.error("Error in encrypting the secret", e); } @@ -200,10 +200,11 @@ Cipher cipher = Cipher.getInstance(params.algorithm); cipher.init(Cipher.DECRYPT_MODE, params.secretKey); decode = cipher.doFinal(encoding); + return decode != null ? new String(decode, "UTF-8") : null; } catch (Exception e) { log.error("Error in decrypting the secret", e); + return null; } - return decode != null ? new String(decode) : null; } /** @@ -216,7 +217,7 @@ private String algorithm = null; private SecretKeySpec secretKey = null; - public EncryptUtilParams(String keyMaterial, String algorithm) { + public EncryptUtilParams(String keyMaterial, String algorithm) throws UnsupportedEncodingException { if (algorithm == null || "".equals(algorithm)) { this.algorithm = "Blowfish"; } else { @@ -224,7 +225,7 @@ } if (keyMaterial == null || "".equals(keyMaterial)) { - secretKey = new SecretKeySpec("jaas is the way".getBytes(), this.algorithm); + secretKey = new SecretKeySpec("jaas is the way".getBytes("UTF-8"), this.algorithm); } else { secretKey = new SecretKeySpec(keyMaterial.getBytes(), this.algorithm); } diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/hostinstall/OpenSslCAWrapper.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/hostinstall/OpenSslCAWrapper.java index 10262c9..74eec2d 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/hostinstall/OpenSslCAWrapper.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/hostinstall/OpenSslCAWrapper.java @@ -139,7 +139,7 @@ try { log.debug("Running Sign Certificate request script"); Process process = getRuntime().exec(command_array); - stdOutput = new BufferedReader(new InputStreamReader(process.getInputStream())); + stdOutput = new BufferedReader(new InputStreamReader(process.getInputStream(), "UTF-8")); stdError = new BufferedReader(new InputStreamReader(process.getErrorStream())); int exitCode = 0; boolean completed = false; -- To view, visit http://gerrit.ovirt.org/13188 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I181c9b3e26c5b941fe368b3287a7486b6b8f91e1 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches