Java Code Examples for javax.security.auth.login.AppConfigurationEntry#getOptions()
The following examples show how to use
javax.security.auth.login.AppConfigurationEntry#getOptions() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigFile.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Retrieve an entry from the Configuration using an application name * as an index. * * @param applicationName the name used to index the Configuration. * @return an array of AppConfigurationEntries which correspond to * the stacked configuration of LoginModules for this * application, or null if this application has no configured * LoginModules. */ @Override public AppConfigurationEntry[] engineGetAppConfigurationEntry (String applicationName) { List<AppConfigurationEntry> list = null; synchronized (configuration) { list = configuration.get(applicationName); } if (list == null || list.size() == 0) { return null; } AppConfigurationEntry[] entries = new AppConfigurationEntry[list.size()]; Iterator<AppConfigurationEntry> iterator = list.iterator(); for (int i = 0; iterator.hasNext(); i++) { AppConfigurationEntry e = iterator.next(); entries[i] = new AppConfigurationEntry(e.getLoginModuleName(), e.getControlFlag(), e.getOptions()); } return entries; }
Example 2
Source File: ConfigFile.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Retrieve an entry from the Configuration using an application name * as an index. * * @param applicationName the name used to index the Configuration. * @return an array of AppConfigurationEntries which correspond to * the stacked configuration of LoginModules for this * application, or null if this application has no configured * LoginModules. */ @Override public AppConfigurationEntry[] engineGetAppConfigurationEntry (String applicationName) { List<AppConfigurationEntry> list = null; synchronized (configuration) { list = configuration.get(applicationName); } if (list == null || list.size() == 0) { return null; } AppConfigurationEntry[] entries = new AppConfigurationEntry[list.size()]; Iterator<AppConfigurationEntry> iterator = list.iterator(); for (int i = 0; iterator.hasNext(); i++) { AppConfigurationEntry e = iterator.next(); entries[i] = new AppConfigurationEntry(e.getLoginModuleName(), e.getControlFlag(), e.getOptions()); } return entries; }
Example 3
Source File: ConfigFile.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Retrieve an entry from the Configuration using an application name * as an index. * * @param applicationName the name used to index the Configuration. * @return an array of AppConfigurationEntries which correspond to * the stacked configuration of LoginModules for this * application, or null if this application has no configured * LoginModules. */ @Override public AppConfigurationEntry[] engineGetAppConfigurationEntry (String applicationName) { List<AppConfigurationEntry> list = null; synchronized (configuration) { list = configuration.get(applicationName); } if (list == null || list.size() == 0) { return null; } AppConfigurationEntry[] entries = new AppConfigurationEntry[list.size()]; Iterator<AppConfigurationEntry> iterator = list.iterator(); for (int i = 0; iterator.hasNext(); i++) { AppConfigurationEntry e = iterator.next(); entries[i] = new AppConfigurationEntry(e.getLoginModuleName(), e.getControlFlag(), e.getOptions()); } return entries; }
Example 4
Source File: SaslNettyServer.java From herddb with Apache License 2.0 | 6 votes |
public SaslServerCallbackHandler(Configuration configuration) throws IOException { AppConfigurationEntry[] configurationEntries = configuration.getAppConfigurationEntry(JASS_SERVER_SECTION); if (configurationEntries == null) { String errorMessage = "Could not find a '" + JASS_SERVER_SECTION + "' entry in this configuration: Server cannot start."; throw new IOException(errorMessage); } credentials.clear(); for (AppConfigurationEntry entry : configurationEntries) { Map<String, ?> options = entry.getOptions(); // Populate DIGEST-MD5 user -> password map with JAAS configuration entries from the "Server" section. // Usernames are distinguished from other options by prefixing the username with a "user_" prefix. for (Map.Entry<String, ?> pair : options.entrySet()) { String key = pair.getKey(); if (key.startsWith(USER_PREFIX)) { String userName = key.substring(USER_PREFIX.length()); credentials.put(userName, (String) pair.getValue()); } } } }
Example 5
Source File: ConfigFile.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Retrieve an entry from the Configuration using an application name * as an index. * * @param applicationName the name used to index the Configuration. * @return an array of AppConfigurationEntries which correspond to * the stacked configuration of LoginModules for this * application, or null if this application has no configured * LoginModules. */ @Override public AppConfigurationEntry[] engineGetAppConfigurationEntry (String applicationName) { List<AppConfigurationEntry> list = null; synchronized (configuration) { list = configuration.get(applicationName); } if (list == null || list.size() == 0) { return null; } AppConfigurationEntry[] entries = new AppConfigurationEntry[list.size()]; Iterator<AppConfigurationEntry> iterator = list.iterator(); for (int i = 0; iterator.hasNext(); i++) { AppConfigurationEntry e = iterator.next(); entries[i] = new AppConfigurationEntry(e.getLoginModuleName(), e.getControlFlag(), e.getOptions()); } return entries; }
Example 6
Source File: ConfigFile.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Retrieve an entry from the Configuration using an application name * as an index. * * @param applicationName the name used to index the Configuration. * @return an array of AppConfigurationEntries which correspond to * the stacked configuration of LoginModules for this * application, or null if this application has no configured * LoginModules. */ @Override public AppConfigurationEntry[] engineGetAppConfigurationEntry (String applicationName) { List<AppConfigurationEntry> list = null; synchronized (configuration) { list = configuration.get(applicationName); } if (list == null || list.size() == 0) { return null; } AppConfigurationEntry[] entries = new AppConfigurationEntry[list.size()]; Iterator<AppConfigurationEntry> iterator = list.iterator(); for (int i = 0; iterator.hasNext(); i++) { AppConfigurationEntry e = iterator.next(); entries[i] = new AppConfigurationEntry(e.getLoginModuleName(), e.getControlFlag(), e.getOptions()); } return entries; }
Example 7
Source File: ConfigFile.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Retrieve an entry from the Configuration using an application name * as an index. * * @param applicationName the name used to index the Configuration. * @return an array of AppConfigurationEntries which correspond to * the stacked configuration of LoginModules for this * application, or null if this application has no configured * LoginModules. */ @Override public AppConfigurationEntry[] engineGetAppConfigurationEntry (String applicationName) { List<AppConfigurationEntry> list = null; synchronized (configuration) { list = configuration.get(applicationName); } if (list == null || list.size() == 0) { return null; } AppConfigurationEntry[] entries = new AppConfigurationEntry[list.size()]; Iterator<AppConfigurationEntry> iterator = list.iterator(); for (int i = 0; iterator.hasNext(); i++) { AppConfigurationEntry e = iterator.next(); entries[i] = new AppConfigurationEntry(e.getLoginModuleName(), e.getControlFlag(), e.getOptions()); } return entries; }
Example 8
Source File: StormJaasCreator.java From streamline with Apache License 2.0 | 6 votes |
public StormJaasCreator() { try (InputStream configStream = getClass().getClassLoader().getResourceAsStream(STORM_JAAS_CONFIG_TEMPLATE)) { List<String> lines = IOUtils.readLines(configStream, Charset.forName("UTF-8")); stormJaasConfigTemplate = String.join("\n", lines); } catch (IOException | NullPointerException e) { throw new RuntimeException("Unable to read JAAS template file for Storm."); } Configuration configuration = Configuration.getConfiguration(); AppConfigurationEntry[] streamlineConfigurations = configuration.getAppConfigurationEntry(Constants.JAAS_STREAMLINE_APP_CONFIG_ENTRY_NAME); if (streamlineConfigurations == null || streamlineConfigurations.length == 0) { throw new RuntimeException("Streamline is not initialized with JAAS config. Unable to create JAAS for Storm."); } AppConfigurationEntry streamlineConf = streamlineConfigurations[0]; Map<String, ?> options = streamlineConf.getOptions(); keyTabPath = (String) options.get("keyTab"); streamlinePrincipal = (String) options.get("principal"); }
Example 9
Source File: ConfigFile.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Retrieve an entry from the Configuration using an application name * as an index. * * @param applicationName the name used to index the Configuration. * @return an array of AppConfigurationEntries which correspond to * the stacked configuration of LoginModules for this * application, or null if this application has no configured * LoginModules. */ @Override public AppConfigurationEntry[] engineGetAppConfigurationEntry (String applicationName) { List<AppConfigurationEntry> list = null; synchronized (configuration) { list = configuration.get(applicationName); } if (list == null || list.size() == 0) { return null; } AppConfigurationEntry[] entries = new AppConfigurationEntry[list.size()]; Iterator<AppConfigurationEntry> iterator = list.iterator(); for (int i = 0; iterator.hasNext(); i++) { AppConfigurationEntry e = iterator.next(); entries[i] = new AppConfigurationEntry(e.getLoginModuleName(), e.getControlFlag(), e.getOptions()); } return entries; }
Example 10
Source File: SaslNettyServer.java From blazingcache with Apache License 2.0 | 6 votes |
public SaslServerCallbackHandler(Configuration configuration) throws IOException { AppConfigurationEntry configurationEntries[] = configuration.getAppConfigurationEntry(SERVER_JAAS_SECTION); if (configurationEntries == null) { String errorMessage = "Could not find a '" + SERVER_JAAS_SECTION + "' entry in this configuration: Server cannot start."; throw new IOException(errorMessage); } credentials.clear(); for (AppConfigurationEntry entry : configurationEntries) { Map<String, ?> options = entry.getOptions(); // Populate DIGEST-MD5 user -> password map with JAAS configuration entries from the "Server" section. // Usernames are distinguished from other options by prefixing the username with a "user_" prefix. for (Map.Entry<String, ?> pair : options.entrySet()) { String key = pair.getKey(); if (key.startsWith(USER_PREFIX)) { String userName = key.substring(USER_PREFIX.length()); credentials.put(userName, (String) pair.getValue()); } } } }
Example 11
Source File: BaseAuthenticationInfo.java From lams with GNU General Public License v2.0 | 6 votes |
/** * <p> * Creates and returns a copy of the specified list of {@code AppConfigurationEntry} objects, adding the security * domain option when necessary. Execution of this method requires a {@code getLoginConfiguration} permission. * * </p> * * @param entries a {@code List} containing the {@code AppConfigurationEntry} objects to be copied. * @return an {@code AppConfigurationEntry} array containing the copied entries. */ protected AppConfigurationEntry[] copyAppConfigurationEntry(List<Object> entries) { SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(GET_CONFIG_ENTRY_PERM); AppConfigurationEntry[] copy = new AppConfigurationEntry[entries.size()]; for (int i = 0; i < copy.length; i++) { AppConfigurationEntry entry = (AppConfigurationEntry) entries.get(i); HashMap<String, Object> options = new HashMap<String, Object>(entry.getOptions()); if (!disableSecurityDomainInOptions()) { options.put(SecurityConstants.SECURITY_DOMAIN_OPTION, this.getName()); } copy[i] = new AppConfigurationEntry(entry.getLoginModuleName(), entry.getControlFlag(), options); } return copy; }
Example 12
Source File: AppPolicy.java From lams with GNU General Public License v2.0 | 6 votes |
public AppConfigurationEntry[] getAppConfigurationEntry() { AppConfigurationEntry[] appConfig = null; if( loginInfo != null ) appConfig = loginInfo.getAppConfigurationEntry(); if( appConfig == null && this != defaultAppPolicy ) appConfig = defaultAppPolicy.getAppConfigurationEntry(); AppConfigurationEntry[] copy = null; if( appConfig != null ) { copy = new AppConfigurationEntry[appConfig.length]; for(int c = 0; c < copy.length; c ++) { AppConfigurationEntry e0 = appConfig[c]; AppConfigurationEntry e1 = new AppConfigurationEntry( e0.getLoginModuleName(), e0.getControlFlag(), e0.getOptions() ); copy[c] = e1; } } return copy; }
Example 13
Source File: ConfigFile.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Retrieve an entry from the Configuration using an application name * as an index. * * @param applicationName the name used to index the Configuration. * @return an array of AppConfigurationEntries which correspond to * the stacked configuration of LoginModules for this * application, or null if this application has no configured * LoginModules. */ @Override public AppConfigurationEntry[] engineGetAppConfigurationEntry (String applicationName) { List<AppConfigurationEntry> list = null; synchronized (configuration) { list = configuration.get(applicationName); } if (list == null || list.size() == 0) { return null; } AppConfigurationEntry[] entries = new AppConfigurationEntry[list.size()]; Iterator<AppConfigurationEntry> iterator = list.iterator(); for (int i = 0; iterator.hasNext(); i++) { AppConfigurationEntry e = iterator.next(); entries[i] = new AppConfigurationEntry(e.getLoginModuleName(), e.getControlFlag(), e.getOptions()); } return entries; }
Example 14
Source File: ConfigFile.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Retrieve an entry from the Configuration using an application name * as an index. * * @param applicationName the name used to index the Configuration. * @return an array of AppConfigurationEntries which correspond to * the stacked configuration of LoginModules for this * application, or null if this application has no configured * LoginModules. */ @Override public AppConfigurationEntry[] engineGetAppConfigurationEntry (String applicationName) { List<AppConfigurationEntry> list = null; synchronized (configuration) { list = configuration.get(applicationName); } if (list == null || list.size() == 0) { return null; } AppConfigurationEntry[] entries = new AppConfigurationEntry[list.size()]; Iterator<AppConfigurationEntry> iterator = list.iterator(); for (int i = 0; iterator.hasNext(); i++) { AppConfigurationEntry e = iterator.next(); entries[i] = new AppConfigurationEntry(e.getLoginModuleName(), e.getControlFlag(), e.getOptions()); } return entries; }
Example 15
Source File: ConfigFile.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Retrieve an entry from the Configuration using an application name * as an index. * * @param applicationName the name used to index the Configuration. * @return an array of AppConfigurationEntries which correspond to * the stacked configuration of LoginModules for this * application, or null if this application has no configured * LoginModules. */ @Override public AppConfigurationEntry[] engineGetAppConfigurationEntry (String applicationName) { List<AppConfigurationEntry> list = null; synchronized (configuration) { list = configuration.get(applicationName); } if (list == null || list.size() == 0) { return null; } AppConfigurationEntry[] entries = new AppConfigurationEntry[list.size()]; Iterator<AppConfigurationEntry> iterator = list.iterator(); for (int i = 0; iterator.hasNext(); i++) { AppConfigurationEntry e = iterator.next(); entries[i] = new AppConfigurationEntry(e.getLoginModuleName(), e.getControlFlag(), e.getOptions()); } return entries; }
Example 16
Source File: RemoteConfigurationRegistryJAASConfigTest.java From knox with Apache License 2.0 | 5 votes |
private static void validateDigestContext(RemoteConfigurationRegistryJAASConfig config, String entryName, String loginModule, String principal, String password) throws Exception { AppConfigurationEntry[] myContextEntries = config.getAppConfigurationEntry(entryName); assertNotNull(myContextEntries); assertEquals(1, myContextEntries.length); AppConfigurationEntry entry = myContextEntries[0]; assertEquals(entry.getLoginModuleName(), loginModule); Map<String, ?> entryOpts = entry.getOptions(); assertEquals(principal, entryOpts.get("username")); assertEquals(password, entryOpts.get("password")); }
Example 17
Source File: AuthenticationInfo.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Write element content. The start element is already written. * * @param writer * @throws XMLStreamException */ public void writeContent(XMLStreamWriter writer) throws XMLStreamException { for (int i = 0; i < moduleEntries.size(); i++) { AppConfigurationEntry entry = (AppConfigurationEntry) moduleEntries.get(i); writer.writeStartElement(Element.LOGIN_MODULE.getLocalName()); String code = entry.getLoginModuleName(); if (AuthenticationConfigParser.loginModulesMap.containsValue(code)) { String value = null; Set<Entry<String, String>> entries = AuthenticationConfigParser.loginModulesMap.entrySet(); for (Entry<String, String> mapEntry : entries) { if (mapEntry.getValue().equals(code)) { value = mapEntry.getKey(); break; } } writer.writeAttribute(Attribute.CODE.getLocalName(), value); } else writer.writeAttribute(Attribute.CODE.getLocalName(), code); writer.writeAttribute(Attribute.FLAG.getLocalName(), valueOf(entry.getControlFlag())); Map<String, ?> options = entry.getOptions(); if (options != null && options.size() > 0) { for (Entry<String, ?> option : options.entrySet()) { writer.writeStartElement(Element.MODULE_OPTION.getLocalName()); writer.writeAttribute(Attribute.NAME.getLocalName(), option.getKey()); writer.writeAttribute(Attribute.VALUE.getLocalName(), option.getValue().toString()); writer.writeEndElement(); } } writer.writeEndElement(); } writer.writeEndElement(); }
Example 18
Source File: AuthenticationInfo.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public String toString() { StringBuffer buffer = new StringBuffer("AppConfigurationEntry[]:\n"); for (int i = 0; i < moduleEntries.size(); i++) { AppConfigurationEntry entry = (AppConfigurationEntry) moduleEntries.get(i); buffer.append("[" + i + "]"); buffer.append("\nLoginModule Class: " + entry.getLoginModuleName()); buffer.append("\nControlFlag: " + entry.getControlFlag()); buffer.append("\nOptions:\n"); Map<String, ?> options = entry.getOptions(); Iterator iter = options.entrySet().iterator(); while (iter.hasNext()) { Entry e = (Entry) iter.next(); String name = (String) e.getKey(); String value = e.getValue() == null ? "" : e.getValue().toString(); String nameToLower = name.toLowerCase(Locale.ENGLISH); if (nameToLower.equals("password") || nameToLower.equals("bindcredential") || nameToLower.equals(Context.SECURITY_CREDENTIALS)) value = "****"; buffer.append("name=" + name); buffer.append(", value=" + value); buffer.append("\n"); } } return buffer.toString(); }
Example 19
Source File: TestJaasConfiguration.java From big-c with Apache License 2.0 | 5 votes |
@Test public void test() throws Exception { String krb5LoginModuleName; if (System.getProperty("java.vendor").contains("IBM")) { krb5LoginModuleName = "com.ibm.security.auth.module.Krb5LoginModule"; } else { krb5LoginModuleName = "com.sun.security.auth.module.Krb5LoginModule"; } ZKSignerSecretProvider.JaasConfiguration jConf = new ZKSignerSecretProvider.JaasConfiguration("foo", "foo/localhost", "/some/location/foo.keytab"); AppConfigurationEntry[] entries = jConf.getAppConfigurationEntry("bar"); Assert.assertNull(entries); entries = jConf.getAppConfigurationEntry("foo"); Assert.assertEquals(1, entries.length); AppConfigurationEntry entry = entries[0]; Assert.assertEquals(AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, entry.getControlFlag()); Assert.assertEquals(krb5LoginModuleName, entry.getLoginModuleName()); Map<String, ?> options = entry.getOptions(); Assert.assertEquals("/some/location/foo.keytab", options.get("keyTab")); Assert.assertEquals("foo/localhost", options.get("principal")); Assert.assertEquals("true", options.get("useKeyTab")); Assert.assertEquals("true", options.get("storeKey")); Assert.assertEquals("false", options.get("useTicketCache")); Assert.assertEquals("true", options.get("refreshKrb5Config")); Assert.assertEquals(6, options.size()); }
Example 20
Source File: KerberosAuthorityTest.java From athenz with Apache License 2.0 | 4 votes |
@Test(groups="kerberos-tests") public void testLoginConfig() { KerberosAuthority.LoginConfig loginConfig = new KerberosAuthority.LoginConfig(null, null); assertFalse(loginConfig.isDebugEnabled()); System.setProperty(KRB_PROP_LOGIN_TKT_CACHE_NAME, "testCacheName"); AppConfigurationEntry[] conf = loginConfig.getAppConfigurationEntry(null); AppConfigurationEntry entry = conf[0]; java.util.Map<String, ?> options = entry.getOptions(); assertNull(options.get("principal")); assertEquals(options.get("useKeyTab"), "false"); assertEquals(options.get("useTicketCache"), "true"); assertEquals(options.get("renewTGT"), "true"); assertNull(options.get("debug")); assertEquals(options.get("ticketCache"), "testCacheName"); System.clearProperty(KRB_PROP_LOGIN_TKT_CACHE_NAME); // set properties and remake the login config System.setProperty(KerberosAuthority.KRB_PROP_LOGIN_RENEW_TGT, "false"); System.setProperty(KerberosAuthority.KRB_PROP_LOGIN_USE_TKT_CACHE, "false"); System.setProperty(KRB_PROP_LOGIN_TKT_CACHE_NAME, "/tmp/cache"); System.setProperty(KerberosAuthority.KRB_PROP_DEBUG, "TRUE"); String keyTabConfFile = "my.keytab"; String servicePrincipal = "juke"; loginConfig = new KerberosAuthority.LoginConfig(keyTabConfFile, servicePrincipal); assertTrue(loginConfig.isDebugEnabled()); conf = loginConfig.getAppConfigurationEntry(null); entry = conf[0]; options = entry.getOptions(); assertEquals(options.get("principal"), "juke"); assertEquals(options.get("useKeyTab"), "true"); assertEquals(options.get("useTicketCache"), "false"); assertEquals(options.get("renewTGT"), "false"); assertEquals(options.get("debug"), "true"); assertNull(options.get("ticketCache")); assertEquals(options.get("keyTab"), "my.keytab"); System.clearProperty(KerberosAuthority.KRB_PROP_LOGIN_RENEW_TGT); System.clearProperty(KerberosAuthority.KRB_PROP_LOGIN_USE_TKT_CACHE); System.clearProperty(KRB_PROP_LOGIN_TKT_CACHE_NAME); System.clearProperty(KerberosAuthority.KRB_PROP_DEBUG); }