svn merge -c 1210320 from trunk for HADOOP-7876.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23-PB@1230385 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2012-01-12 03:15:30 +00:00
parent cf3948994b
commit 1b98413d81
2 changed files with 15 additions and 3 deletions

View File

@ -29,6 +29,9 @@ Release 0.23-PB - Unreleased
HADOOP-7862 Move the support for multiple protocols to lower layer so HADOOP-7862 Move the support for multiple protocols to lower layer so
that Writable, PB and Avro can all use it (Sanjay) 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)
BUG FIXES BUG FIXES
HADOOP-7833. Fix findbugs warnings in protobuf generated code. HADOOP-7833. Fix findbugs warnings in protobuf generated code.

View File

@ -42,15 +42,20 @@ public class DelegationKey implements Writable {
@Nullable @Nullable
private byte[] keyBytes = null; private byte[] keyBytes = null;
/** Default constructore required for Writable */
public DelegationKey() { public DelegationKey() {
this(0, 0L, null); this(0, 0L, (SecretKey)null);
} }
public DelegationKey(int keyId, long expiryDate, SecretKey key) { 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.keyId = keyId;
this.expiryDate = expiryDate; this.expiryDate = expiryDate;
if (key!=null) { if (encodedKey != null) {
this.keyBytes = key.getEncoded(); this.keyBytes = encodedKey;
} }
} }
@ -70,6 +75,10 @@ public class DelegationKey implements Writable {
return key; return key;
} }
} }
public byte[] getEncodedKey() {
return keyBytes;
}
public void setExpiryDate(long expiryDate) { public void setExpiryDate(long expiryDate) {
this.expiryDate = expiryDate; this.expiryDate = expiryDate;