Java Code Examples for javax.security.auth.login.Configuration#getConfiguration()
The following examples show how to use
javax.security.auth.login.Configuration#getConfiguration() .
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: 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 2
Source File: ZkClient.java From DDMQ with Apache License 2.0 | 5 votes |
private boolean isZkSaslEnabled() { boolean isSecurityEnabled = false; boolean zkSaslEnabled = Boolean.parseBoolean(System.getProperty(ZK_SASL_CLIENT, "true")); String zkLoginContextName = System.getProperty(ZK_LOGIN_CONTEXT_NAME_KEY, "Client"); if (!zkSaslEnabled) { LOG.warn("Client SASL has been explicitly disabled with " + ZK_SASL_CLIENT); return false; } String loginConfigFile = System.getProperty(JAVA_LOGIN_CONFIG_PARAM); if (loginConfigFile != null && loginConfigFile.length() > 0) { LOG.info("JAAS File name: " + loginConfigFile); File configFile = new File(loginConfigFile); if (!configFile.canRead()) { throw new IllegalArgumentException("File " + loginConfigFile + "cannot be read."); } try { Configuration loginConf = Configuration.getConfiguration(); isSecurityEnabled = loginConf.getAppConfigurationEntry(zkLoginContextName) != null; } catch (Exception e) { throw new ZkException(e); } } return isSecurityEnabled; }
Example 3
Source File: CoreUtils.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** * Returns installed login configuration. * * @return Configuration */ public static Configuration getLoginConfiguration() { Configuration configuration = null; try { configuration = Configuration.getConfiguration(); } catch (SecurityException e) { LOGGER.debug("Unable to load default login configuration", e); } return configuration; }
Example 4
Source File: RemoteConfigurationRegistryJAASConfig.java From knox with Apache License 2.0 | 5 votes |
private RemoteConfigurationRegistryJAASConfig(List<RemoteConfigurationRegistryConfig> configs, AliasService aliasService) { try { delegate = Configuration.getConfiguration(); } catch(Exception e) { //populate the original error with a meaningful message; logging will happen later in the call hierarchy final String message = String.format(Locale.ROOT, "%s: %s", JAAS_CONFIG_ERRROR_PREFIX, System.getProperty(GatewayConfig.KRB5_LOGIN_CONFIG, "Undefined")); throw new ConfigurationException(message, e); } validateKeytabFile(); this.aliasService = aliasService; // Populate context entries for (RemoteConfigurationRegistryConfig config : configs) { if (config.isSecureRegistry()) { contextEntries.put(config.getName(), createEntries(config)); } } // If there is at least one context entry, then set this as the client configuration if (!contextEntries.isEmpty()) { // TODO: PJZ: ZooKeeper 3.6.0 will have per-client JAAS Configuration support; Upgrade ASAP!! // For now, set this as the static JAAS configuration Configuration.setConfiguration(this); } }
Example 5
Source File: SdcKrb5HttpClientConfigurer.java From datacollector with Apache License 2.0 | 5 votes |
public ZKJaasConfiguration() { try { this.baseConfig = Configuration.getConfiguration(); } catch (SecurityException var2) { this.baseConfig = null; } this.zkClientLoginContext = System.getProperty("zookeeper.sasl.clientconfig", "Client"); logger.debug("ZK client login context is: " + this.zkClientLoginContext); }
Example 6
Source File: FusionKrb5HttpClientConfigurer.java From storm-solr with Apache License 2.0 | 5 votes |
public FusionJaasConfiguration(String fusionPrincipal) { this.fusionPrincipal = fusionPrincipal; try { this.baseConfig = Configuration.getConfiguration(); } catch (SecurityException var2) { this.baseConfig = null; } if (this.baseConfig != null) { String clientAppName = System.getProperty(LOGIN_APP_NAME, "Client"); this.globalAppConfigurationEntry = this.baseConfig.getAppConfigurationEntry(clientAppName); } }
Example 7
Source File: ZKConnectionImpl.java From zkclient with Apache License 2.0 | 5 votes |
private boolean isZkSaslEnabled() { boolean isSecurityEnabled = false; boolean zkSaslEnabled = Boolean.parseBoolean(System.getProperty(ZK_SASL_CLIENT, "true")); String zkLoginContextName = System.getProperty(ZK_LOGIN_CONTEXT_NAME_KEY, "Client"); if (!zkSaslEnabled) { LOG.warn("Client SASL has been explicitly disabled with " + ZK_SASL_CLIENT); return false; } String loginConfigFile = System.getProperty(JAVA_LOGIN_CONFIG_PARAM); if (loginConfigFile != null && loginConfigFile.length() > 0) { LOG.info("JAAS File name: " + loginConfigFile); File configFile = new File(loginConfigFile); if (!configFile.canRead()) { throw new IllegalArgumentException("File " + loginConfigFile + "cannot be read."); } try { Configuration loginConf = Configuration.getConfiguration(); isSecurityEnabled = loginConf.getAppConfigurationEntry(zkLoginContextName) != null; } catch (Exception e) { throw new ZKException(e); } } return isSecurityEnabled; }
Example 8
Source File: KerberosTestServices.java From lucene-solr with Apache License 2.0 | 5 votes |
public KerberosTestServices build() throws Exception { final Configuration oldConfig = clientPrincipal != null ? Configuration.getConfiguration() : null; JaasConfiguration jaasConfiguration = null; if (clientPrincipal != null) { jaasConfiguration = (appName == null) ? new JaasConfiguration(clientPrincipal, clientKeytab, serverPrincipal, serverKeytab) : new JaasConfiguration(clientPrincipal, clientKeytab, appName); } return new KerberosTestServices(kdcWorkDir, jaasConfiguration, oldConfig, savedLocale); }
Example 9
Source File: SecurityFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Will release anything that was done during {@link #prepare()} step */ public static void release() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission(SecurityFactory.class.getName() + ".release")); } Configuration config = Configuration.getConfiguration(); if(config == standaloneConfiguration) { Configuration.setConfiguration(parentConfiguration); //Set back the previously valid configuration } }
Example 10
Source File: SecurityFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Prepare for security operations. One of the operations * that is undertaken is to establish the JAAS {@code Configuration} * that uses our xml based configuration. * @see #release() to release the configuration */ public static void prepare() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission(SecurityFactory.class.getName() + ".prepare")); } if(Configuration.getConfiguration() instanceof ApplicationPolicyRegistration == false) { standaloneConfiguration.setParentConfig(parentConfiguration); Configuration.setConfiguration(standaloneConfiguration); } }
Example 11
Source File: DefaultLoginConfig.java From lams with GNU General Public License v2.0 | 5 votes |
/** Return the Configuration instance managed by this mbean. This simply obtains the default Configuration by calling Configuration.getConfiguration. Note that this means this mbean must be the first pushed onto the config stack if it is used. @see javax.security.auth.login.Configuration */ public Configuration getConfiguration(Configuration currentConfig) { if( theConfig == null ) { theConfig = Configuration.getConfiguration(); } return theConfig; }
Example 12
Source File: StaxBasedConfigParser.java From lams with GNU General Public License v2.0 | 5 votes |
public void parse2(InputStream configStream) throws XMLStreamException { Configuration config = Configuration.getConfiguration(); if (!(config instanceof ApplicationPolicyRegistration)) { throw PicketBoxMessages.MESSAGES.invalidType(ApplicationPolicyRegistration.class.getName()); } ApplicationPolicyRegistration appPolicyRegistration = (ApplicationPolicyRegistration) config; XMLStreamReader reader = getXMLStreamReader(configStream); while (reader.hasNext() && reader.nextTag() != END_ELEMENT) { final Element element = Element.forName(reader.getLocalName()); if (element.equals(Element.POLICY)) { ApplicationPolicyParser appPolicyParser = new ApplicationPolicyParser(); List<ApplicationPolicy> appPolicies = appPolicyParser.parse(reader); for(ApplicationPolicy appPolicy: appPolicies) { appPolicyRegistration.addApplicationPolicy(appPolicy.getName(), appPolicy); } } else throw StaxParserUtil.unexpectedElement(reader); if (reader.isEndElement()) break; } }
Example 13
Source File: ZkClient.java From DDMQ with Apache License 2.0 | 5 votes |
private boolean isZkSaslEnabled() { boolean isSecurityEnabled = false; boolean zkSaslEnabled = Boolean.parseBoolean(System.getProperty(ZK_SASL_CLIENT, "true")); String zkLoginContextName = System.getProperty(ZK_LOGIN_CONTEXT_NAME_KEY, "Client"); if (!zkSaslEnabled) { LOG.warn("Client SASL has been explicitly disabled with " + ZK_SASL_CLIENT); return false; } String loginConfigFile = System.getProperty(JAVA_LOGIN_CONFIG_PARAM); if (loginConfigFile != null && loginConfigFile.length() > 0) { LOG.info("JAAS File name: " + loginConfigFile); File configFile = new File(loginConfigFile); if (!configFile.canRead()) { throw new IllegalArgumentException("File " + loginConfigFile + "cannot be read."); } try { Configuration loginConf = Configuration.getConfiguration(); isSecurityEnabled = loginConf.getAppConfigurationEntry(zkLoginContextName) != null; } catch (Exception e) { throw new ZkException(e); } } return isSecurityEnabled; }
Example 14
Source File: InMemoryJAASConfiguration.java From incubator-atlas with Apache License 2.0 | 4 votes |
private InMemoryJAASConfiguration(Properties prop) { parent = Configuration.getConfiguration(); initialize(prop); }
Example 15
Source File: PropertiesLoginModuleConfigurator.java From activemq-artemis with Apache License 2.0 | 4 votes |
public PropertiesLoginModuleConfigurator(String entryName, String brokerEtc) throws Exception { if (entryName == null || entryName.length() == 0) { entryName = "activemq"; } Configuration securityConfig = Configuration.getConfiguration(); AppConfigurationEntry[] entries = securityConfig.getAppConfigurationEntry(entryName); if (entries == null || entries.length == 0) { throw ActiveMQMessageBundle.BUNDLE.failedToLoadSecurityConfig(); } int entriesInspected = 0; for (AppConfigurationEntry entry : entries) { entriesInspected++; if (entry.getLoginModuleName().equals(PropertiesLoginModule.class.getName())) { String userFileName = (String) entry.getOptions().get(USER_FILE_PROP_NAME); String roleFileName = (String) entry.getOptions().get(ROLE_FILE_PROP_NAME); File etcDir = new File(brokerEtc); File userFile = new File(etcDir, userFileName); File roleFile = new File(etcDir, roleFileName); if (!userFile.exists()) { throw ActiveMQMessageBundle.BUNDLE.failedToLoadUserFile(brokerEtc + userFileName); } if (!roleFile.exists()) { throw ActiveMQMessageBundle.BUNDLE.failedToLoadRoleFile(brokerEtc + roleFileName); } Configurations configs = new Configurations(); userBuilder = configs.propertiesBuilder(userFile); roleBuilder = configs.propertiesBuilder(roleFile); userConfig = userBuilder.getConfiguration(); roleConfig = roleBuilder.getConfiguration(); String roleHeader = roleConfig.getLayout().getHeaderComment(); String userHeader = userConfig.getLayout().getHeaderComment(); if (userHeader == null) { if (userConfig.isEmpty()) { //clean and reset header userConfig.clear(); userConfig.setHeader(LICENSE_HEADER); } } if (roleHeader == null) { if (roleConfig.isEmpty()) { //clean and reset header roleConfig.clear(); roleConfig.setHeader(LICENSE_HEADER); } } return; } } if (entriesInspected == entries.length) { throw ActiveMQMessageBundle.BUNDLE.failedToFindLoginModuleEntry(entryName); } }
Example 16
Source File: InMemoryJAASConfiguration.java From ranger with Apache License 2.0 | 4 votes |
private InMemoryJAASConfiguration(Properties prop) { parent = Configuration.getConfiguration(); initialize(prop); }
Example 17
Source File: InMemoryJAASConfiguration.java From atlas with Apache License 2.0 | 4 votes |
private InMemoryJAASConfiguration(Properties prop) { parent = Configuration.getConfiguration(); initialize(prop); }
Example 18
Source File: SecurityActions.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private static Configuration internalGetGlobalJaasConfiguration() throws SecurityException { return Configuration.getConfiguration(); }