diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java index 24adf87f4a23..5b865241508f 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/BlobOperationRestProxy.java @@ -16,6 +16,7 @@ package com.microsoft.windowsazure.services.blob.implementation; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.util.HashMap; import java.util.Map; @@ -808,7 +809,8 @@ public void breakLease(String container, String blob, String leaseId) throws Ser @Override @Deprecated - public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) throws ServiceException { + public void breakLease(String container, String blob, String leaseId, BlobServiceOptions options) + throws ServiceException { breakLease(container, blob, options); } @@ -819,8 +821,8 @@ public BreakLeaseResult breakLease(String container, String blob) throws Service @Override public BreakLeaseResult breakLease(String container, String blob, BlobServiceOptions options) - throws ServiceException { - ClientResponse response = doLeaseOperation("break", container, blob, null, options, null); + throws ServiceException { + ClientResponse response = doLeaseOperation("break", container, blob, null, options, null); BreakLeaseResult result = new BreakLeaseResult(); result.setRemainingLeaseTimeInSeconds(Integer.parseInt(response.getHeaders().getFirst("x-ms-lease-time"))); @@ -836,7 +838,8 @@ private AcquireLeaseResult putLeaseImpl(String leaseAction, String container, St return result; } - private ClientResponse doLeaseOperation(String leaseAction, String container, String blob, String leaseId, BlobServiceOptions options, AccessCondition accessCondition) { + private ClientResponse doLeaseOperation(String leaseAction, String container, String blob, String leaseId, + BlobServiceOptions options, AccessCondition accessCondition) { String path = createPathFromContainer(container); WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "lease"); @@ -941,7 +944,12 @@ public void createBlobBlock(String container, String blob, String blockId, Input CreateBlobBlockOptions options) throws ServiceException { String path = createPathFromContainer(container); WebResource webResource = getResource(options).path(path).path(blob).queryParam("comp", "block"); - webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId))); + try { + webResource = addOptionalQueryParam(webResource, "blockid", new String(Base64.encode(blockId), "UTF-8")); + } + catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } Builder builder = webResource.header("x-ms-version", API_VERSION); builder = addOptionalHeader(builder, "x-ms-lease-id", options.getLeaseId()); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java index 71a68bd061cc..e40607c67522 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/blob/implementation/HmacSHA256Sign.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.blob.implementation; @@ -33,8 +33,8 @@ public String sign(String stringToSign) { Mac hmac = Mac.getInstance("hmacSHA256"); hmac.init(new SecretKeySpec(Base64.decode(accessKey), "hmacSHA256")); - byte[] digest = hmac.doFinal(stringToSign.getBytes("UTF8")); - return new String(Base64.encode(digest)); + byte[] digest = hmac.doFinal(stringToSign.getBytes("UTF-8")); + return new String(Base64.encode(digest), "UTF-8"); } catch (Exception e) { throw new IllegalArgumentException("accessKey", e); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java index 975bc675e4bb..f9aedb2faf94 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/core/utils/pipeline/Base64StringAdapter.java @@ -2,15 +2,15 @@ * Copyright Microsoft Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * http://www.apache.org/licenses/LICENSE-2.0 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package com.microsoft.windowsazure.services.core.utils.pipeline; @@ -25,7 +25,7 @@ public class Base64StringAdapter extends XmlAdapter { @Override public String marshal(String arg0) throws Exception { - return new String(Base64.encode(arg0)); + return new String(Base64.encode(arg0), "UTF-8"); } @Override diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java index a01aa2aed43b..eefbae626684 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/implementation/BrokerPropertiesMapper.java @@ -28,7 +28,7 @@ public class BrokerPropertiesMapper { public BrokerProperties fromString(String value) throws IllegalArgumentException { ObjectMapper mapper = new ObjectMapper(); try { - return mapper.readValue(value.getBytes(), BrokerProperties.class); + return mapper.readValue(value.getBytes("UTF-8"), BrokerProperties.class); } catch (JsonParseException e) { throw new IllegalArgumentException(e); diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java index a2518f45afd9..3c222a52e793 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/BrokeredMessage.java @@ -16,6 +16,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -70,7 +71,12 @@ public BrokeredMessage(byte[] body) { */ public BrokeredMessage(String body) { this(new BrokerProperties()); - this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes()); + try { + this.body = (body == null) ? null : new ByteArrayInputStream(body.getBytes("UTF-8")); + } + catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } } /** diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java index 485104a66a29..6be3e3c25264 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/Exports.java @@ -17,7 +17,7 @@ import com.microsoft.windowsazure.services.core.Builder; import com.microsoft.windowsazure.services.core.UserAgentFilter; import com.microsoft.windowsazure.services.table.implementation.AtomReaderWriter; -import com.microsoft.windowsazure.services.table.implementation.DefaultEdmValueConterter; +import com.microsoft.windowsazure.services.table.implementation.DefaultEdmValueConverter; import com.microsoft.windowsazure.services.table.implementation.DefaultXMLStreamFactory; import com.microsoft.windowsazure.services.table.implementation.HttpReaderWriter; import com.microsoft.windowsazure.services.table.implementation.MimeReaderWriter; @@ -39,7 +39,7 @@ public void register(Builder.Registry registry) { registry.add(AtomReaderWriter.class); registry.add(MimeReaderWriter.class); registry.add(HttpReaderWriter.class); - registry.add(EdmValueConverter.class, DefaultEdmValueConterter.class); + registry.add(EdmValueConverter.class, DefaultEdmValueConverter.class); registry.add(UserAgentFilter.class); } } diff --git a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConverter.java similarity index 95% rename from microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java rename to microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConverter.java index 8d1aff2334cb..cdf08312d8ae 100644 --- a/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConterter.java +++ b/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/table/implementation/DefaultEdmValueConverter.java @@ -25,12 +25,12 @@ import com.microsoft.windowsazure.services.table.models.EdmType; import com.sun.jersey.core.util.Base64; -public class DefaultEdmValueConterter implements EdmValueConverter { +public class DefaultEdmValueConverter implements EdmValueConverter { private final ISO8601DateConverter iso8601DateConverter; @Inject - public DefaultEdmValueConterter(ISO8601DateConverter iso8601DateConverter) { + public DefaultEdmValueConverter(ISO8601DateConverter iso8601DateConverter) { this.iso8601DateConverter = iso8601DateConverter; } diff --git a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java index 17578984f68c..1a2fd1ef0895 100644 --- a/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java +++ b/microsoft-azure-api/src/test/java/com/microsoft/windowsazure/services/table/implementation/AtomReaderWriterTests.java @@ -32,7 +32,7 @@ public class AtomReaderWriterTests extends IntegrationTestBase { public void parseTableEntriesWorks() throws Exception { // Arrange AtomReaderWriter atom = new AtomReaderWriter(new DefaultXMLStreamFactory(), new DefaultDateFactory(), - new ISO8601DateConverter(), new DefaultEdmValueConterter(new ISO8601DateConverter())); + new ISO8601DateConverter(), new DefaultEdmValueConverter(new ISO8601DateConverter())); String feed = "\r\n" + "\r\n" + " Tables\r\n"