Quellcode durchsuchen

HADOOP-6596. Add a version field to the AbstractDelegationTokenIdentifier's
serialized value. (omalley)


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@916390 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley vor 15 Jahren
Ursprung
Commit
37214591e9

+ 3 - 0
CHANGES.txt

@@ -164,6 +164,9 @@ Trunk (unreleased changes)
     HADOOP-6579. Provide a mechanism for encoding/decoding Tokens from
     a url-safe string and change the commons-code library to 1.4. (omalley)
 
+    HADOOP-6596. Add a version field to the AbstractDelegationTokenIdentifier's
+    serialized value. (omalley)
+
   OPTIMIZATIONS
 
     HADOOP-6467. Improve the performance on HarFileSystem.listStatus(..).

+ 7 - 0
src/java/org/apache/hadoop/security/token/delegation/AbstractDelegationTokenIdentifier.java

@@ -34,6 +34,7 @@ import org.apache.hadoop.security.token.TokenIdentifier;
 @InterfaceAudience.LimitedPrivate({HDFS, MAPREDUCE})
 public abstract class AbstractDelegationTokenIdentifier 
 extends TokenIdentifier {
+  private static final byte VERSION = 0;
 
   private Text owner;
   private Text renewer;
@@ -145,6 +146,11 @@ extends TokenIdentifier {
   }
   
   public void readFields(DataInput in) throws IOException {
+    byte version = in.readByte();
+    if (version != VERSION) {
+	throw new IOException("Unknown version of delegation token " + 
+                              version);
+    }
     owner.readFields(in);
     renewer.readFields(in);
     realUser.readFields(in);
@@ -155,6 +161,7 @@ extends TokenIdentifier {
   }
 
   public void write(DataOutput out) throws IOException {
+    out.writeByte(VERSION);
     owner.write(out);
     renewer.write(out);
     realUser.write(out);