adoroszlai commented on code in PR #6253:
URL: https://github.com/apache/ozone/pull/6253#discussion_r1500340680
##########
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:
Using reflection for accessing private members in JDK objects is likely to
break in some Java versions (see #6073 for an example).
Reflection is less brittle for types defined by Ozone (config objects) or by
users (policies and other pluggable implementations).
--
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]