adoroszlai commented on code in PR #6253:
URL: https://github.com/apache/ozone/pull/6253#discussion_r1500398052


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/OzoneSecurityUtil.java:
##########
@@ -141,4 +146,39 @@ public static List<X509Certificate> convertToX509(
     }
     return x509Certificates;
   }
+
+  public static void updateKerberosInfo(Class clz, String serverPrincipal) {
+    // new KerberosInfo
+    Annotation newValue = new KerberosInfo() {
+      @Override
+      public Class<? extends Annotation> annotationType() {
+        return KerberosInfo.class;
+      }
+      @Override
+      public String serverPrincipal() {
+        return serverPrincipal;
+      }
+      @Override
+      public String clientPrincipal() {
+        return null;
+      }
+    };
+
+    try {
+      Method method = clz.getClass().getDeclaredMethod("annotationData", null);
+      method.setAccessible(true);
+
+      Object annotationData = method.invoke(clz);
+      Field annotations = 
annotationData.getClass().getDeclaredField("annotations");
+      annotations.setAccessible(true);
+
+      Map<Class<? extends Annotation>, Annotation> map =
+          (Map<Class<? extends Annotation>, Annotation>) 
annotations.get(annotationData);
+      map.put(KerberosInfo.class, newValue);

Review Comment:
   @ChenSammi we can use reflection for this PR and create follow-up task to 
replace reflection with some better way to use specific principal



-- 
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.

To unsubscribe, e-mail: [email protected]

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