List of usage examples for org.apache.shiro.util LifecycleUtils init
public static void init(Collection c) throws ShiroException
From source file:com.leshazlewood.samples.shiro.cassandra.InitializingIniWebEnvironment.java
License:Apache License
@Override public void init() { super.init(); LifecycleUtils.init(this.objects.values()); }
From source file:org.apache.activemq.shiro.env.IniEnvironment.java
License:Apache License
@Override public void init() throws ShiroException { //this.environment and this.securityManager are null. Try Ini config: Ini ini = this.ini; if (ini != null) { apply(ini);//w ww .jav a2 s . co m } if (this.objects.isEmpty() && this.iniConfig != null) { ini = new Ini(); ini.load(this.iniConfig); apply(ini); } if (this.objects.isEmpty() && this.iniResourePath != null) { ini = new Ini(); ini.loadFromPath(this.iniResourePath); apply(ini); } if (this.objects.isEmpty()) { if (ResourceUtils.resourceExists("classpath:shiro.ini")) { ini = new Ini(); ini.loadFromPath("classpath:shiro.ini"); apply(ini); } } if (this.objects.isEmpty()) { String msg = "Configuration error. All heuristics for acquiring Shiro INI config " + "have been exhausted. Ensure you configure one of the following properties: " + "1) ini 2) iniConfig 3) iniResourcePath and the Ini sections are not empty."; throw new ConfigurationException(msg); } LifecycleUtils.init(this.objects.values()); }
From source file:org.panifex.security.shiro.env.ModularEnvironmentLoader.java
License:Open Source License
/** * Registers the ModularWebEnvironment to the specified servlet context. * * @param sc current servlet context/*from w w w . ja v a2 s . co m*/ * @throws IllegalStateException * if an existing WebEnvironment has already been initialized and associated with * the specified {@code ServletContext} or if ModularWebEnvironment is not * prepared to be associated */ @Override protected WebEnvironment createEnvironment(ServletContext sc) { if (environment == null) { String errMsg = "ModularWebEnvironment must be initialized before setting it " + "to servlet context"; log.error(errMsg); throw new IllegalStateException(errMsg); } environment.setServletContext(sc); customizeEnvironment(environment); LifecycleUtils.init(environment); return environment; }
From source file:org.panifex.security.shiro.env.ModularEnvironmentLoaderTest.java
License:Open Source License
@Test public void testInitEnvironmentWithPreparedModularWebEnvironment() { // mocks/*from ww w.j a v a 2 s .c om*/ ModularWebEnvironment webEnvironment = createMock(ModularWebEnvironment.class); // servlet context must not return an environment attribute because it contains // an already registered Shiro's environment expect(servletContextMock.getAttribute(EnvironmentLoader.ENVIRONMENT_ATTRIBUTE_KEY)).andReturn(null); servletContextMock.log(anyObject(String.class)); // expect binding servlet context to modular web environment webEnvironment.setServletContext(servletContextMock); // expect lifecycle init LifecycleUtils.init(webEnvironment); // expect setting modular web environment to servlet context servletContextMock.setAttribute(EnvironmentLoader.ENVIRONMENT_ATTRIBUTE_KEY, webEnvironment); // prepare modular environment loader to test ModularEnvironmentLoader loader = new ModularEnvironmentLoader(); loader.setEnvironment(webEnvironment); replayAll(); loader.initEnvironment(servletContextMock); verifyAll(); }