@Test(expected = IllegalArgumentException.class) public void testLoadForServerWithWrongListenerName() throws IOException { writeConfiguration("Server", "test.LoginModule required;"); JaasContext.load(JaasContext.Type.SERVER, new ListenerName("plaintext"), Collections.<String, Object>emptyMap()); }
public static JaasContext load(JaasContext.Type contextType, ListenerName listenerName, Map<String, ?> configs) { String listenerContextName; String globalContextName; switch (contextType) { case CLIENT: if (listenerName != null) throw new IllegalArgumentException("listenerName should be null for CLIENT"); globalContextName = GLOBAL_CONTEXT_NAME_CLIENT; listenerContextName = null; break; case SERVER: if (listenerName == null) throw new IllegalArgumentException("listenerName should not be null for SERVER"); globalContextName = GLOBAL_CONTEXT_NAME_SERVER; listenerContextName = listenerName.value().toLowerCase(Locale.ROOT) + "." + GLOBAL_CONTEXT_NAME_SERVER; break; default: throw new IllegalArgumentException("Unexpected context type " + contextType); } return load(contextType, listenerContextName, globalContextName, configs); }
JaasContext { public static JaasContext load(JaasContext.Type contextType, ListenerName listenerName, Map<String, ?> configs) { String listenerContextName; String globalContextName; switch (contextType) { case CLIENT: if (listenerName != null) throw new IllegalArgumentException("listenerName should be null for CLIENT"); globalContextName = GLOBAL_CONTEXT_NAME_CLIENT; listenerContextName = null; break; case SERVER: if (listenerName == null) throw new IllegalArgumentException("listenerName should not be null for SERVER"); globalContextName = GLOBAL_CONTEXT_NAME_SERVER; listenerContextName = listenerName.value().toLowerCase(Locale.ROOT) + "." + GLOBAL_CONTEXT_NAME_SERVER; break; default: throw new IllegalArgumentException("Unexpected context type " + contextType); } return load(contextType, listenerContextName, globalContextName, configs); } }
JaasContext { public static JaasContext load(JaasContext.Type contextType, ListenerName listenerName, Map<String, ?> configs) { String listenerContextName; String globalContextName; switch (contextType) { case CLIENT: if (listenerName != null) throw new IllegalArgumentException("listenerName should be null for CLIENT"); globalContextName = GLOBAL_CONTEXT_NAME_CLIENT; listenerContextName = null; break; case SERVER: if (listenerName == null) throw new IllegalArgumentException("listenerName should not be null for SERVER"); globalContextName = GLOBAL_CONTEXT_NAME_SERVER; listenerContextName = listenerName.value().toLowerCase(Locale.ROOT) + "." + GLOBAL_CONTEXT_NAME_SERVER; break; default: throw new IllegalArgumentException("Unexpected context type " + contextType); } return load(contextType, listenerContextName, globalContextName, configs); } JaasContext(String name, Type type, Configuration configuration); }
JaasContext { public static JaasContext load(JaasContext.Type contextType, ListenerName listenerName, Map<String, ?> configs) { String listenerContextName; String globalContextName; switch (contextType) { case CLIENT: if (listenerName != null) throw new IllegalArgumentException("listenerName should be null for CLIENT"); globalContextName = GLOBAL_CONTEXT_NAME_CLIENT; listenerContextName = null; break; case SERVER: if (listenerName == null) throw new IllegalArgumentException("listenerName should not be null for SERVER"); globalContextName = GLOBAL_CONTEXT_NAME_SERVER; listenerContextName = listenerName.value().toLowerCase(Locale.ROOT) + "." + GLOBAL_CONTEXT_NAME_SERVER; break; default: throw new IllegalArgumentException("Unexpected context type " + contextType); } return load(contextType, listenerContextName, globalContextName, configs); } JaasContext(String name, Type type, Configuration configuration); static JaasContext load(JaasContext.Type contextType, ListenerName listenerName,
                                   Map<String, ?> configs); String name(); Type type(); Configuration configuration(); List<AppConfigurationEntry> configurationEntries(); String configEntryOption(String key, String loginModuleName); }
JaasContext { public static JaasContext load(JaasContext.Type contextType, ListenerName listenerName, Map<String, ?> configs) { String listenerContextName; String globalContextName; switch (contextType) { case CLIENT: if (listenerName != null) throw new IllegalArgumentException("listenerName should be null for CLIENT"); globalContextName = GLOBAL_CONTEXT_NAME_CLIENT; listenerContextName = null; break; case SERVER: if (listenerName == null) throw new IllegalArgumentException("listenerName should not be null for SERVER"); globalContextName = GLOBAL_CONTEXT_NAME_SERVER; listenerContextName = listenerName.value().toLowerCase(Locale.ROOT) + "." + GLOBAL_CONTEXT_NAME_SERVER; break; default: throw new IllegalArgumentException("Unexpected context type " + contextType); } return load(contextType, listenerContextName, globalContextName, configs); } JaasContext(String name, Type type, Configuration configuration); static JaasContext load(JaasContext.Type contextType, ListenerName listenerName,
                                   Map<String, ?> configs); String name(); Type type(); Configuration configuration(); List<AppConfigurationEntry> configurationEntries(); String configEntryOption(String key, String loginModuleName);  }