Repository: cloudstack
Updated Branches:
  refs/heads/master aa265fe88 -> adcd34098


Fixed a few findbugs issues after the merge 0b83559

HttpUploadServerHandler.java:142, DM_BOXED_PRIMITIVE_FOR_PARSING
NfsSecondaryStorageResource.java:2630, DM_BOXED_PRIMITIVE_FOR_PARSING
NfsSecondaryStorageResource.java:2775, DM_DEFAULT_ENCODING
EncryptionUtil.java:59, DM_DEFAULT_ENCODING


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d39b9935
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d39b9935
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d39b9935

Branch: refs/heads/master
Commit: d39b99351236aeb23c8d63ef0c57d24f5f445ebf
Parents: dc3c43e
Author: Rajani Karuturi <rajanikarut...@gmail.com>
Authored: Thu Apr 30 12:00:42 2015 +0530
Committer: Rajani Karuturi <rajanikarut...@gmail.com>
Committed: Thu Apr 30 13:56:44 2015 +0530

----------------------------------------------------------------------
 .../storage/resource/HttpUploadServerHandler.java         |  2 +-
 .../storage/resource/NfsSecondaryStorageResource.java     |  9 +++++++--
 utils/src/com/cloud/utils/EncryptionUtil.java             | 10 ++++++----
 3 files changed, 14 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d39b9935/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/HttpUploadServerHandler.java
----------------------------------------------------------------------
diff --git 
a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/HttpUploadServerHandler.java
 
b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/HttpUploadServerHandler.java
index 05e5fe4..7a22b20 100644
--- 
a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/HttpUploadServerHandler.java
+++ 
b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/HttpUploadServerHandler.java
@@ -139,7 +139,7 @@ public class HttpUploadServerHandler extends 
SimpleChannelInboundHandler<HttpObj
                             hostname = entry.getValue();
                             break;
                         case HttpHeaders.Names.CONTENT_LENGTH:
-                            contentLength = Long.valueOf(entry.getValue());
+                            contentLength = Long.parseLong(entry.getValue());
                             break;
                     }
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d39b9935/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
----------------------------------------------------------------------
diff --git 
a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
 
b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
index 6565187..606cc10 100644
--- 
a/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
+++ 
b/services/secondary-storage/server/src/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java
@@ -32,6 +32,7 @@ import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
 import java.math.BigInteger;
 import java.net.InetAddress;
 import java.net.URI;
@@ -2627,7 +2628,7 @@ public class NfsSecondaryStorageResource extends 
ServerResourceBase implements S
                 }
                 throw new 
InvalidParameterValueException(errorMessage.toString());
             }
-            int maxSizeInGB = Integer.valueOf(cmd.getMaxUploadSize());
+            int maxSizeInGB = Integer.parseInt(cmd.getMaxUploadSize());
             int contentLengthInGB = getSizeInGB(contentLength);
             if (contentLengthInGB > maxSizeInGB) {
                 String errorMessage = "Maximum file upload size exceeded. 
Content Length received: " + contentLengthInGB + "GB. Maximum allowed size: " + 
maxSizeInGB + "GB.";
@@ -2772,7 +2773,11 @@ public class NfsSecondaryStorageResource extends 
ServerResourceBase implements S
         if (extension.equals("iso")) {
             templateName = uploadEntity.getUuid().trim().replace(" ", "_");
         } else {
-            templateName = 
java.util.UUID.nameUUIDFromBytes((uploadEntity.getFilename() + 
System.currentTimeMillis()).getBytes()).toString();
+            try {
+                templateName = 
UUID.nameUUIDFromBytes((uploadEntity.getFilename() + 
System.currentTimeMillis()).getBytes("UTF-8")).toString();
+            } catch (UnsupportedEncodingException e) {
+                templateName = uploadEntity.getUuid().trim().replace(" ", "_");
+            }
         }
 
         // run script to mv the temporary template file to the final template

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d39b9935/utils/src/com/cloud/utils/EncryptionUtil.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/EncryptionUtil.java 
b/utils/src/com/cloud/utils/EncryptionUtil.java
index 28d781f..e3ca4b0 100644
--- a/utils/src/com/cloud/utils/EncryptionUtil.java
+++ b/utils/src/com/cloud/utils/EncryptionUtil.java
@@ -18,6 +18,7 @@
  */
 package com.cloud.utils;
 
+import com.cloud.utils.exception.CloudRuntimeException;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Logger;
 import org.jasypt.encryption.pbe.PBEStringEncryptor;
@@ -25,6 +26,7 @@ import org.jasypt.encryption.pbe.StandardPBEStringEncryptor;
 
 import javax.crypto.Mac;
 import javax.crypto.spec.SecretKeySpec;
+import java.io.UnsupportedEncodingException;
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
 
@@ -56,14 +58,14 @@ public class EncryptionUtil {
     public static String generateSignature(String data, String key) {
         try {
             final Mac mac = Mac.getInstance("HmacSHA1");
-            final SecretKeySpec keySpec = new SecretKeySpec(key.getBytes(), 
"HmacSHA1");
+            final SecretKeySpec keySpec = new 
SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA1");
             mac.init(keySpec);
             mac.update(data.getBytes());
             final byte[] encryptedBytes = mac.doFinal();
             return Base64.encodeBase64String(encryptedBytes);
-        } catch (NoSuchAlgorithmException | InvalidKeyException e) {
-            s_logger.error("exception occurred which encoding the data.", e);
-            return null;
+        } catch (NoSuchAlgorithmException | InvalidKeyException | 
UnsupportedEncodingException e) {
+            s_logger.error("exception occurred which encoding the data." + 
e.getMessage());
+            throw new CloudRuntimeException("unable to generate signature", e);
         }
     }
 }

Reply via email to