Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
Currently HadoopAuthCookieStore isKnoxCookie checks the configured principal over and over again from krb5 login config file on each cookie. This is unnecessary and can be improved.
Specifically the following section doesn't need to read the krb5 login config each time. We can do this once in the constructor. We should not expect krb5 config to change from underneath us.
if (principal != null) { String krb5Config = config.getKerberosLoginConfig(); if (krb5Config != null && !krb5Config.isEmpty()) { Properties p = new Properties(); try (InputStream in = Files.newInputStream(Paths.get(krb5Config))){ p.load(in); String configuredPrincipal = p.getProperty("principal"); // Strip off enclosing quotes, if present if (configuredPrincipal.startsWith("\"")) { configuredPrincipal = configuredPrincipal.substring(1, configuredPrincipal.length() - 1); } // Check if they're the same principal result = principal.equals(configuredPrincipal); } catch (IOException e) { LOG.errorReadingKerberosLoginConfig(krb5Config, e); } } }