Java Code Examples for org.apache.commons.configuration2.builder.fluent.Configurations#propertiesBuilder()
The following examples show how to use
org.apache.commons.configuration2.builder.fluent.Configurations#propertiesBuilder() .
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: ArtemisTest.java From activemq-artemis with Apache License 2.0 | 5 votes |
private void checkRole(String user, File roleFile, String... roles) throws Exception { Configurations configs = new Configurations(); FileBasedConfigurationBuilder<PropertiesConfiguration> roleBuilder = configs.propertiesBuilder(roleFile); PropertiesConfiguration roleConfig = roleBuilder.getConfiguration(); for (String r : roles) { String storedUsers = (String) roleConfig.getProperty(r); log.debug("users in role: " + r + " ; " + storedUsers); List<String> userList = StringUtil.splitStringList(storedUsers, ","); assertTrue(userList.contains(user)); } }
Example 2
Source File: ArtemisTest.java From activemq-artemis with Apache License 2.0 | 4 votes |
private String getStoredPassword(String user, File userFile) throws Exception { Configurations configs = new Configurations(); FileBasedConfigurationBuilder<PropertiesConfiguration> userBuilder = configs.propertiesBuilder(userFile); PropertiesConfiguration userConfig = userBuilder.getConfiguration(); return (String) userConfig.getProperty(user); }
Example 3
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); } }