本文整理汇总了Java中org.apache.shiro.config.Ini.fromResourcePath方法的典型用法代码示例。如果您正苦于以下问题:Java Ini.fromResourcePath方法的具体用法?Java Ini.fromResourcePath怎么用?Java Ini.fromResourcePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.shiro.config.Ini
的用法示例。
在下文中一共展示了Ini.fromResourcePath方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doParse
import org.apache.shiro.config.Ini; //导入方法依赖的package包/类
@Override
public Ini doParse(String raw) throws IllegalArgumentException {
Ini ini;
try {
ini = Ini.fromResourcePath(raw);
} catch (ConfigurationException e) {
throw new ShiroConfigurationException(e);
}
Set<String> presentSections = ImmutableSortedSet.copyOf(ini.getSectionNames());
if (presentSections.isEmpty()) {
throw new MissingSectionsException();
}
Set<String> extraSections = Sets.difference(presentSections, ALLOWED_SECTION_NAMES);
if (!extraSections.isEmpty()) {
throw new ExtraSectionsException(extraSections);
}
return ini;
}
示例2: setup
import org.apache.shiro.config.Ini; //导入方法依赖的package包/类
@Override
protected void setup() {
String configFile = getSettings().getString("shiro.configurationFile", "classpath:conf/shiro.ini");
Ini ini = Ini.fromResourcePath(configFile);
IniWebEnvironment webEnvironment = new IniWebEnvironment();
webEnvironment.setIni(ini);
webEnvironment.setServletContext(getServletContext());
webEnvironment.init();
bind(WebEnvironment.class).toInstance(webEnvironment);
bind(SecurityManager.class).toInstance(webEnvironment.getSecurityManager());
bind(WebSecurityManager.class).toInstance(webEnvironment.getWebSecurityManager());
String basePath = Strings.nullToEmpty(getSettings().getString(RestServlet.SETTING_URL, null)).trim();
filter(basePath + "/*").through(ShiroFilter.class);
install(new AopModule());
}
示例3: start
import org.apache.shiro.config.Ini; //导入方法依赖的package包/类
@Override
public synchronized void start() throws IOException {
switch (state) {
case NONE:
throw new IllegalStateException("not initialized");
case STARTED:
throw new IllegalStateException("started already");
case DESTROYED:
throw new IllegalStateException("can't start after destruction");
default:
break;
}
final File configFile = findConfigFile(this.configFile, DEFAULT_CONFIG_FILE);
final File securityConfigFile = findConfigFile(this.securityConfigFile, DEFAULT_SECURITY_CONFIG_FILE);
final Ini securityConfig =
securityConfigFile != null ? Ini.fromResourcePath(securityConfigFile.getPath()) : null;
final CentralDogma dogma;
if (configFile == null) {
dogma = new CentralDogmaBuilder(DEFAULT_DATA_DIR).build();
} else {
dogma = CentralDogma.forConfig(configFile, securityConfig);
}
dogma.start();
this.dogma = dogma;
state = State.STARTED;
}
示例4: loadShiroIni
import org.apache.shiro.config.Ini; //导入方法依赖的package包/类
@Provides
@Singleton
Ini loadShiroIni() {
logger.entry();
Ini result = Ini.fromResourcePath("classpath:shiro.ini");
logger.exit(result);
return result;
}
示例5: onInit
import org.apache.shiro.config.Ini; //导入方法依赖的package包/类
@Override
protected void onInit() {
super.onInit();
// This is an in-memory realm only - no need for an additional cache when we're already
// as memory-efficient as we can be.
Ini ini = getIni();
String resourcePath = getResourcePath();
if (!CollectionUtils.isEmpty(this.users) || !CollectionUtils.isEmpty(this.roles)) {
if (!CollectionUtils.isEmpty(ini)) {
log.warn("Users or Roles are already populated. Configured Ini instance will be ignored.");
}
if (StringUtils.hasText(resourcePath)) {
log.warn("Users or Roles are already populated. resourcePath '{}' will be ignored.", resourcePath);
}
log.debug("Instance is already populated with users or roles. No additional user/role population " +
"will be performed.");
return;
}
if (CollectionUtils.isEmpty(ini)) {
log.debug("No INI instance configuration present. Checking resourcePath...");
if (StringUtils.hasText(resourcePath)) {
log.debug("Resource path {} defined. Creating INI instance.", resourcePath);
ini = Ini.fromResourcePath(resourcePath);
if (!CollectionUtils.isEmpty(ini)) {
setIni(ini);
}
}
}
if (CollectionUtils.isEmpty(ini)) {
String msg = "Ini instance and/or resourcePath resulted in null or empty Ini configuration. Cannot " +
"load account data.";
throw new IllegalStateException(msg);
}
processDefinitions(ini);
}
示例6: loadDefaultShiroIni
import org.apache.shiro.config.Ini; //导入方法依赖的package包/类
Ini loadDefaultShiroIni() {
logger.entry();
Ini result = Ini.fromResourcePath(DEFAULT_SHIRO_INI_REALM_RESOURCE);
logger.exit(result);
return result;
}
示例7: loadShiroIni
import org.apache.shiro.config.Ini; //导入方法依赖的package包/类
@Provides
@Singleton
Ini loadShiroIni() {
Ini result = Ini.fromResourcePath("classpath:shiro.ini");
return result;
}
示例8: IniRealm
import org.apache.shiro.config.Ini; //导入方法依赖的package包/类
/**
* This constructor will immediately process the definitions in the {@code Ini} resolved from the specified
* {@code resourcePath}. If you need to perform additional configuration before processing (e.g. setting a
* permissionResolver, etc), do not call this constructor. Instead, do the following:
* <ol>
* <li>Call the default no-arg constructor</li>
* <li>Set the Ini instance you wish to use via {@code #setIni}</li>
* <li>Set any other configuration properties</li>
* <li>Call {@link #init()}</li>
* </ol>
*
* @param resourcePath the resource path of the Ini config which will be inspected to create accounts, groups and
* permissions for this realm.
*/
public IniRealm(String resourcePath) {
this();
Ini ini = Ini.fromResourcePath(resourcePath);
this.ini = ini;
this.resourcePath = resourcePath;
processDefinitions(ini);
}