diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index e314849d0c..10f5f7e21f 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -66,8 +66,11 @@ Trunk (unreleased changes) HADOOP-7590. Mavenize streaming and MR examples. (tucu) - HADOOP-7862 Move the support for multiple protocols to lower layer so that Writable, - PB and Avro can all use it (Sanjay) + HADOOP-7862. Move the support for multiple protocols to lower layer so + that Writable, PB and Avro can all use it (Sanjay) + + HADOOP-7876. Provided access to encoded key in DelegationKey for + use in protobuf based RPCs. (suresh) BUGS diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/DelegationKey.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/DelegationKey.java index 28d82537fb..7cea67923e 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/DelegationKey.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/token/delegation/DelegationKey.java @@ -42,15 +42,20 @@ public class DelegationKey implements Writable { @Nullable private byte[] keyBytes = null; + /** Default constructore required for Writable */ public DelegationKey() { - this(0, 0L, null); + this(0, 0L, (SecretKey)null); } public DelegationKey(int keyId, long expiryDate, SecretKey key) { + this(keyId, expiryDate, key != null ? key.getEncoded() : null); + } + + public DelegationKey(int keyId, long expiryDate, byte[] encodedKey) { this.keyId = keyId; this.expiryDate = expiryDate; - if (key!=null) { - this.keyBytes = key.getEncoded(); + if (encodedKey != null) { + this.keyBytes = encodedKey; } } @@ -70,6 +75,10 @@ public SecretKey getKey() { return key; } } + + public byte[] getEncodedKey() { + return keyBytes; + } public void setExpiryDate(long expiryDate) { this.expiryDate = expiryDate;