Alissa Bonas has posted comments on this change.

Change subject: pki: cleanup: Found reliance on default encoding
......................................................................


Patch Set 1: (3 inline comments)

....................................................
File 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/crypt/EncryptionUtils.java
Line 166:         try {
Line 167:             EncryptUtilParams params = new 
EncryptUtilParams(keyMaterial, algorithm);
Line 168:             cipher = Cipher.getInstance(params.algorithm);
Line 169:             cipher.init(Cipher.ENCRYPT_MODE, params.secretKey);
Line 170:             encoding = cipher.doFinal(secret.getBytes("UTF-8"));
Consider using CharEncoding.UTF_8 constant instead of hardcoded string (from 
org.apache.commons.lang)

Or use Charset.forName("UTF-8") from jdk
Line 171:         } catch (Exception e) {
Line 172:             log.error("Error in encrypting the secret", e);
Line 173:         }
Line 174: 


Line 216:     private static class EncryptUtilParams {
Line 217:         private String algorithm = null;
Line 218:         private SecretKeySpec secretKey = null;
Line 219: 
Line 220:         public EncryptUtilParams(String keyMaterial, String 
algorithm) throws UnsupportedEncodingException {
In order to avoid UnsupportedEncodingException (to redundant its declaration at 
all), you can use Charset.forName("UTF-8"), and then pass to getBytes below the 
Charset object instead of string with charset name.
Line 221:             if (algorithm == null || "".equals(algorithm)) {
Line 222:                 this.algorithm = "Blowfish";
Line 223:             } else {
Line 224:                 this.algorithm = algorithm;


....................................................
File 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/hostinstall/OpenSslCAWrapper.java
Line 138:         BufferedReader stdError = null;
Line 139:         try {
Line 140:             log.debug("Running Sign Certificate request script");
Line 141:             Process process = getRuntime().exec(command_array);
Line 142:             stdOutput = new BufferedReader(new 
InputStreamReader(process.getInputStream(), "UTF-8"));
Same comment regarding usage of Charset object like in other class.
Line 143:             stdError = new BufferedReader(new 
InputStreamReader(process.getErrorStream()));
Line 144:             int exitCode = 0;
Line 145:             boolean completed = false;
Line 146:             for (int x = 0; x < signatureTimeout; x++) {


--
To view, visit http://gerrit.ovirt.org/13188
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I181c9b3e26c5b941fe368b3287a7486b6b8f91e1
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <[email protected]>
Gerrit-Reviewer: Alissa Bonas <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Yair Zaslavsky <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to