InMemoryJAASConfiguration extends Configuration { @Override public AppConfigurationEntry[] getAppConfigurationEntry(String name) { if (LOG.isDebugEnabled()) { LOG.debug("==> InMemoryJAASConfiguration.getAppConfigurationEntry({})", name); } AppConfigurationEntry[] ret = null; List<AppConfigurationEntry> retList = null; String redirectedName = getConfigSectionRedirect(name); if (redirectedName != null) { retList = applicationConfigEntryMap.get(redirectedName); if (LOG.isDebugEnabled()) { LOG.debug("Redirected jaasConfigSection ({} -> {}): ", name, redirectedName, retList); } } if (retList == null || retList.size() == 0) { retList = applicationConfigEntryMap.get(name); } if (retList == null || retList.size() == 0) { if (parent != null) { ret = parent.getAppConfigurationEntry(name); } } else { int sz = retList.size(); ret = new AppConfigurationEntry[sz]; ret = retList.toArray(ret); } if (LOG.isDebugEnabled()) { LOG.debug("<== InMemoryJAASConfiguration.getAppConfigurationEntry({}): {}", name, ArrayUtils.toString(ret)); } return ret; } private  InMemoryJAASConfiguration(Properties prop); static void init(String propFile); static void init(org.apache.commons.configuration.Configuration atlasConfiguration); static void init(Properties properties); @Override AppConfigurationEntry[] getAppConfigurationEntry(String name); static void setConfigSectionRedirect(String name, String redirectTo);  }
@Test(enabled=false) public void testGetAppConfigurationEntryStringForKafkaClient() { AppConfigurationEntry[] entries = Configuration.getConfiguration().getAppConfigurationEntry("KafkaClient"); Assert.assertNotNull(entries); Assert.assertEquals(1, entries.length); String principal = (String) entries[0].getOptions().get("principal"); Assert.assertNotNull(principal); String[] components = principal.split("[/@]"); Assert.assertEquals(3, components.length); Assert.assertEquals(false, StringUtils.equalsIgnoreCase(components[1], "_HOST")); }
@Test(enabled=false) public void testGetAppConfigurationEntryStringForMyClient() { AppConfigurationEntry[] entries = Configuration.getConfiguration().getAppConfigurationEntry("myClient"); Assert.assertNotNull(entries); Assert.assertEquals(2, entries.length); String principal = (String) entries[0].getOptions().get("principal"); Assert.assertNotNull(principal); String[] components = principal.split("[/@]"); Assert.assertEquals(3, components.length); Assert.assertEquals(true, StringUtils.equalsIgnoreCase(components[1], "abcd")); principal = (String) entries[1].getOptions().get("principal"); Assert.assertNotNull(principal); components = principal.split("[/@]"); Assert.assertEquals(2, components.length); }
@Test(enabled=false) public void testGetAppConfigurationEntryStringForUnknownClient() { AppConfigurationEntry[] entries = Configuration.getConfiguration().getAppConfigurationEntry("UnknownClient"); Assert.assertNull(entries); }