diff --git a/hadoop-common-project/hadoop-auth-examples/src/main/java/org/apache/hadoop/security/authentication/examples/WhoClient.java b/hadoop-common-project/hadoop-auth-examples/src/main/java/org/apache/hadoop/security/authentication/examples/WhoClient.java index 2299ae1fd80..f5cff2b529a 100644 --- a/hadoop-common-project/hadoop-auth-examples/src/main/java/org/apache/hadoop/security/authentication/examples/WhoClient.java +++ b/hadoop-common-project/hadoop-auth-examples/src/main/java/org/apache/hadoop/security/authentication/examples/WhoClient.java @@ -19,6 +19,7 @@ import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; +import java.nio.charset.Charset; /** * Example that uses AuthenticatedURL. @@ -39,7 +40,9 @@ public class WhoClient { System.out.println("Status code: " + conn.getResponseCode() + " " + conn.getResponseMessage()); System.out.println(); if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { - BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream())); + BufferedReader reader = new BufferedReader( + new InputStreamReader( + conn.getInputStream(), Charset.forName("UTF-8"))); String line = reader.readLine(); while (line != null) { System.out.println(line); diff --git a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/RandomSignerSecretProvider.java b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/RandomSignerSecretProvider.java index 29e5661cb0b..41059a7e009 100644 --- a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/RandomSignerSecretProvider.java +++ b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/RandomSignerSecretProvider.java @@ -14,6 +14,8 @@ package org.apache.hadoop.security.authentication.util; import com.google.common.annotations.VisibleForTesting; + +import java.nio.charset.Charset; import java.util.Random; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; @@ -46,6 +48,6 @@ public class RandomSignerSecretProvider extends RolloverSignerSecretProvider { @Override protected byte[] generateNewSecret() { - return Long.toString(rand.nextLong()).getBytes(); + return Long.toString(rand.nextLong()).getBytes(Charset.forName("UTF-8")); } } diff --git a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/Signer.java b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/Signer.java index f639503bd6f..aa63e403c63 100644 --- a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/Signer.java +++ b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/Signer.java @@ -15,6 +15,7 @@ package org.apache.hadoop.security.authentication.util; import org.apache.commons.codec.binary.Base64; +import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -86,7 +87,7 @@ public class Signer { protected String computeSignature(byte[] secret, String str) { try { MessageDigest md = MessageDigest.getInstance("SHA"); - md.update(str.getBytes()); + md.update(str.getBytes(Charset.forName("UTF-8"))); md.update(secret); byte[] digest = md.digest(); return new Base64(0).encodeToString(digest); diff --git a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/StringSignerSecretProvider.java b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/StringSignerSecretProvider.java index 7aaccd2914c..57ddd372fe4 100644 --- a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/StringSignerSecretProvider.java +++ b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/StringSignerSecretProvider.java @@ -13,6 +13,7 @@ */ package org.apache.hadoop.security.authentication.util; +import java.nio.charset.Charset; import java.util.Properties; import javax.servlet.ServletContext; import org.apache.hadoop.classification.InterfaceAudience; @@ -36,7 +37,7 @@ public class StringSignerSecretProvider extends SignerSecretProvider { long tokenValidity) throws Exception { String signatureSecret = config.getProperty( AuthenticationFilter.SIGNATURE_SECRET, null); - secret = signatureSecret.getBytes(); + secret = signatureSecret.getBytes(Charset.forName("UTF-8")); secrets = new byte[][]{secret}; } diff --git a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/ZKSignerSecretProvider.java b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/ZKSignerSecretProvider.java index f8db2ee743c..11bfccd05c6 100644 --- a/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/ZKSignerSecretProvider.java +++ b/hadoop-common-project/hadoop-auth/src/main/java/org/apache/hadoop/security/authentication/util/ZKSignerSecretProvider.java @@ -15,6 +15,7 @@ package org.apache.hadoop.security.authentication.util; import com.google.common.annotations.VisibleForTesting; import java.nio.ByteBuffer; +import java.nio.charset.Charset; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -369,7 +370,7 @@ public class ZKSignerSecretProvider extends RolloverSignerSecretProvider { } private byte[] generateRandomSecret() { - return Long.toString(rand.nextLong()).getBytes(); + return Long.toString(rand.nextLong()).getBytes(Charset.forName("UTF-8")); } /** diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 35b280710f7..2d4a1d3cdcc 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -182,6 +182,8 @@ Release 2.7.0 - UNRELEASED HADOOP-11273. TestMiniKdc failure: login options not compatible with IBM JDK. (Gao Zhong Liang via wheat9) + HADOOP-11379. Fix new findbugs warnings in hadoop-auth*. (Li Lu via wheat9) + Release 2.6.0 - 2014-11-18 INCOMPATIBLE CHANGES