Github user StephanEwen commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3057#discussion_r95007014
  
    --- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/security/SecurityUtils.java
 ---
    @@ -71,163 +64,93 @@
         */
        public static void install(SecurityConfiguration config) throws 
Exception {
     
    -           if (!config.securityIsEnabled()) {
    -                   // do not perform any initialization if no Kerberos 
crendetails are provided
    -                   return;
    -           }
    -
    -           // establish the JAAS config
    -           JaasConfiguration jaasConfig = new 
JaasConfiguration(config.keytab, config.principal);
    -           
javax.security.auth.login.Configuration.setConfiguration(jaasConfig);
    -
    -           populateSystemSecurityProperties(config.flinkConf);
    -
    -           // establish the UGI login user
    -           UserGroupInformation.setConfiguration(config.hadoopConf);
    -
    -           // only configure Hadoop security if we have security enabled
    -           if (UserGroupInformation.isSecurityEnabled()) {
    -
    -                   final UserGroupInformation loginUser;
    -
    -                   if (config.keytab != null && 
!StringUtils.isBlank(config.principal)) {
    -                           String keytabPath = (new 
File(config.keytab)).getAbsolutePath();
    -
    -                           
UserGroupInformation.loginUserFromKeytab(config.principal, keytabPath);
    -
    -                           loginUser = UserGroupInformation.getLoginUser();
    -
    -                           // supplement with any available tokens
    -                           String fileLocation = 
System.getenv(UserGroupInformation.HADOOP_TOKEN_FILE_LOCATION);
    -                           if (fileLocation != null) {
    -                           /*
    -                            * Use reflection API since the API semantics 
are not available in Hadoop1 profile. Below APIs are
    -                            * used in the context of reading the stored 
tokens from UGI.
    -                            * Credentials cred = 
Credentials.readTokenStorageFile(new File(fileLocation), config.hadoopConf);
    -                            * loginUser.addCredentials(cred);
    -                           */
    -                                   try {
    -                                           Method 
readTokenStorageFileMethod = Credentials.class.getMethod("readTokenStorageFile",
    -                                                   File.class, 
org.apache.hadoop.conf.Configuration.class);
    -                                           Credentials cred = 
(Credentials) readTokenStorageFileMethod.invoke(null, new File(fileLocation),
    -                                                   config.hadoopConf);
    -                                           Method addCredentialsMethod = 
UserGroupInformation.class.getMethod("addCredentials",
    -                                                   Credentials.class);
    -                                           
addCredentialsMethod.invoke(loginUser, cred);
    -                                   } catch (NoSuchMethodException e) {
    -                                           LOG.warn("Could not find method 
implementations in the shaded jar. Exception: {}", e);
    -                                   }
    -                           }
    -                   } else {
    -                           // login with current user credentials (e.g. 
ticket cache)
    -                           try {
    -                                   //Use reflection API to get the login 
user object
    -                                   
//UserGroupInformation.loginUserFromSubject(null);
    -                                   Method loginUserFromSubjectMethod = 
UserGroupInformation.class.getMethod("loginUserFromSubject", Subject.class);
    -                                   Subject subject = null;
    -                                   loginUserFromSubjectMethod.invoke(null, 
subject);
    -                           } catch (NoSuchMethodException e) {
    -                                   LOG.warn("Could not find method 
implementations in the shaded jar. Exception: {}", e);
    -                           }
    -
    -                           // note that the stored tokens are read 
automatically
    -                           loginUser = UserGroupInformation.getLoginUser();
    +           // install the security modules
    +           List<SecurityModule> modules = new ArrayList();
    --- End diff --
    
    Can you use `new ArrayList<>()` here? In general, it would be nice to make 
a pass over the code with warnings according to generics and serializability 
enabled. I get a lot of warnings printed when compiling this. Minimizing these 
kinds of warnings helps to spot the warnings that inform about actual subtle 
bugs.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to