ChenSammi commented on code in PR #6253:
URL: https://github.com/apache/ozone/pull/6253#discussion_r1500223091
##########
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:
@adoroszlai , thanks for the review.
Use different interface is another approach to solve this problem. I
considered it as one of the choices at the beginning.
Any specific reason that reflection is not favored? As far as I can see,
it's used in many places of Ozone now.
--
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]