本文整理汇总了Java中org.apache.commons.configuration2.PropertiesConfiguration.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java PropertiesConfiguration.getProperty方法的具体用法?Java PropertiesConfiguration.getProperty怎么用?Java PropertiesConfiguration.getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.configuration2.PropertiesConfiguration
的用法示例。
在下文中一共展示了PropertiesConfiguration.getProperty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkRole
import org.apache.commons.configuration2.PropertiesConfiguration; //导入方法依赖的package包/类
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);
System.out.println("users in role: " + r + " ; " + storedUsers);
List<String> userList = StringUtil.splitStringList(storedUsers, ",");
assertTrue(userList.contains(user));
}
}
示例2: checkPassword
import org.apache.commons.configuration2.PropertiesConfiguration; //导入方法依赖的package包/类
private boolean checkPassword(String user, String password, File userFile) throws Exception {
Configurations configs = new Configurations();
FileBasedConfigurationBuilder<PropertiesConfiguration> userBuilder = configs.propertiesBuilder(userFile);
PropertiesConfiguration userConfig = userBuilder.getConfiguration();
String storedPassword = (String) userConfig.getProperty(user);
HashProcessor processor = PasswordMaskingUtil.getHashProcessor(storedPassword);
return processor.compare(password.toCharArray(), storedPassword);
}
示例3: mergeExtraOptions
import org.apache.commons.configuration2.PropertiesConfiguration; //导入方法依赖的package包/类
private static void mergeExtraOptions(PropertiesConfiguration baseOptions, PropertiesConfiguration extraOptions) {
if (isNull(extraOptions) || extraOptions.size() == 0) {
return;
}
trace("loadOptions: have to merge extra Options");
Iterator<String> allKeys = extraOptions.getKeys();
while (allKeys.hasNext()) {
String key = allKeys.next();
if ("sxversion".equals(key)) {
baseOptions.setProperty("sxversion_saved", extraOptions.getProperty(key));
continue;
}
if ("sxbuild".equals(key)) {
baseOptions.setProperty("sxbuild_saved", extraOptions.getProperty(key));
continue;
}
Object value = baseOptions.getProperty(key);
if (isNull(value)) {
baseOptions.addProperty(key, extraOptions.getProperty(key));
trace("Option added: %s", key);
} else {
Object extraValue = extraOptions.getProperty(key);
if (!value.getClass().getName().equals(extraValue.getClass().getName()) ||
!value.toString().equals(extraValue.toString())) {
baseOptions.setProperty(key, extraValue);
trace("Option changed: %s = %s", key, extraValue);
}
}
}
}