You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2019/03/13 22:54:53 UTC

[GitHub] [hadoop] ajayydv commented on a change in pull request #601: HDDS-1119. DN get OM certificate from SCM CA for block token validat…

ajayydv commented on a change in pull request #601: HDDS-1119. DN get OM certificate from SCM CA for block token validat…
URL: https://github.com/apache/hadoop/pull/601#discussion_r265363618
 
 

 ##########
 File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/security/token/BlockTokenVerifier.java
 ##########
 @@ -78,29 +79,36 @@ public UserGroupInformation verify(String user, String tokenStr)
         throw new BlockTokenException("Failed to decode token : " + tokenStr);
       }
 
-      // TODO: revisit this when caClient is ready, skip signature check now.
-      /**
-       * the final code should like
-       * if (caClient == null) {
-       *   throw new SCMSecurityException("Certificate client not available to
-       *       validate token");
-       * }
-       */
-      if (caClient != null) {
-        X509Certificate singerCert = caClient.queryCertificate(
-            "certId=" + tokenId.getOmCertSerialId());
-        if (singerCert == null) {
-          throw new BlockTokenException("Can't find signer certificate " +
-              "(OmCertSerialId: " + tokenId.getOmCertSerialId() +
-              ") of the block token for user: " + tokenId.getUser());
-        }
-        Boolean validToken = caClient.verifySignature(tokenId.getBytes(),
-            token.getPassword(), singerCert);
-        if (!validToken) {
-          throw new BlockTokenException("Invalid block token for user: " +
-              tokenId.getUser());
-        }
+      if (caClient == null) {
+        throw new SCMSecurityException("Certificate client not available " +
+            "to validate token");
       }
+
+      X509Certificate singerCert;
+      try {
+        singerCert =
+            caClient.getCertificateFromLocal(tokenId.getOmCertSerialId());
 
 Review comment:
   initially i was inclined to do that but than i decided otherwise in favor of APIs with singular responsibility. With this clients can decide what action to take.  Also it gives more flexibility to client, for example if connection to scm fails to due to timeout client may decide to retry it, with abstract api call that becomes more hidden and complex. 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org