xiaoyuyao commented on a change in pull request #1182:
URL: https://github.com/apache/hadoop-ozone/pull/1182#discussion_r454474255



##########
File path: 
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/security/OzoneTokenIdentifier.java
##########
@@ -77,6 +81,57 @@ public Text getKind() {
     return KIND_NAME;
   }
 
+  /** Instead of relying on proto serialization, this
+   *  provides  explicit serialization for OzoneTokenIdentifier.
+   * @return byte[]
+   */
+  public byte[] toUniqueSerializedKey() {
+    DataOutputBuffer buf = new DataOutputBuffer();
+    try {
+      super.write(buf);
+      WritableUtils.writeVInt(buf, getTokenType().getNumber());
+      // Set s3 specific fields.
+      if (getTokenType().equals(S3AUTHINFO)) {
+        WritableUtils.writeString(buf, getAwsAccessId());
+        WritableUtils.writeString(buf, getSignature());
+        WritableUtils.writeString(buf, getStrToSign());
+      } else {
+        WritableUtils.writeString(buf, getOmCertSerialId());
+        if (getOmServiceId() != null) {

Review comment:
       Thanks @prashantpogde  for the update. LGTM overall. Only one question: 
the null check on line100 should be removed. WritableUtils.writeString will 
write len=-1 for null and the WritableUtils.readString will populate null back 
during de-serialization. This way, we will have matched deserialization code on 
the code in line129-130. 
   
   +1 after that being fixed. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to