org.apache.shiro.io.ResourceUtils Java Examples
The following examples show how to use
org.apache.shiro.io.ResourceUtils.
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: ShiroConfig.java From supplierShop with MIT License | 6 votes |
/** * 返回配置文件流 避免ehcache配置文件一直被占用,无法完全销毁项目重新部署 */ protected InputStream getCacheManagerConfigFileInputStream() { String configFile = "classpath:ehcache/ehcache-shiro.xml"; InputStream inputStream = null; try { inputStream = ResourceUtils.getInputStreamForPath(configFile); byte[] b = IOUtils.toByteArray(inputStream); InputStream in = new ByteArrayInputStream(b); return in; } catch (IOException e) { throw new ConfigurationException( "Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]", e); } finally { IOUtils.closeQuietly(inputStream); } }
Example #2
Source File: ShiroConfig.java From LuckyFrameWeb with GNU Affero General Public License v3.0 | 6 votes |
/** * 返回配置文件流 避免ehcache配置文件一直被占用,无法完全销毁项目重新部署 */ protected InputStream getCacheManagerConfigFileInputStream() { String configFile = "classpath:ehcache/ehcache-shiro.xml"; InputStream inputStream = null; try { inputStream = ResourceUtils.getInputStreamForPath(configFile); byte[] b = IOUtils.toByteArray(inputStream); return new ByteArrayInputStream(b); } catch (IOException e) { throw new ConfigurationException( "Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]", e); } finally { IOUtils.closeQuietly(inputStream); } }
Example #3
Source File: AuthConfig.java From v-mock with MIT License | 5 votes |
/** * 返回配置文件流 避免ehcache配置文件一直被占用,无法完全销毁项目重新部署 */ protected InputStream getCacheManagerConfigFileInputStream() { String configFile = "classpath:ehcache/ehcache-shiro.xml"; try { @Cleanup InputStream inputStream = ResourceUtils.getInputStreamForPath(configFile); byte[] readBytes = IoUtil.readBytes(inputStream); InputStream in = new ByteArrayInputStream(readBytes); return in; } catch (IOException e) { throw new ConfigurationException( "Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]", e); } }
Example #4
Source File: ShiroConfig.java From RuoYi with Apache License 2.0 | 5 votes |
/** * 返回配置文件流 避免ehcache配置文件一直被占用,无法完全销毁项目重新部署 */ private InputStream getCacheManagerConfigFileInputStream(){ String configFile = "classpath:ehcache/ehcache-shiro.xml"; try(InputStream inputStream = ResourceUtils.getInputStreamForPath(configFile)){ byte[] b = IOUtils.toByteArray(inputStream); return new ByteArrayInputStream(b); }catch (IOException e){ throw new ConfigurationException( "Unable to obtain input stream for cacheManagerConfigFile [" + configFile + "]", e); } }
Example #5
Source File: EhcacheShiroManager.java From ehcache-shiro with Apache License 2.0 | 5 votes |
private URL getResource() throws MalformedURLException { String cacheManagerConfigFile = getCacheManagerConfigFile(); String configFileWithoutPrefix = stripPrefix(cacheManagerConfigFile); if (cacheManagerConfigFile.startsWith(ResourceUtils.CLASSPATH_PREFIX)) { return ClassUtils.getResource(configFileWithoutPrefix); } String url = ResourceUtils.hasResourcePrefix(cacheManagerConfigFile) ? configFileWithoutPrefix : cacheManagerConfigFile; return new URL(url); }
Example #6
Source File: LoginResourceTest.java From cassandra-reaper with Apache License 2.0 | 5 votes |
@Test public void testShiroConfig() throws IOException { try (InputStream is = ResourceUtils.getInputStreamForPath("classpath:shiro.ini")) { Ini ini = new Ini(); ini.load(is); new WebIniSecurityManagerFactory(ini).getInstance(); } }
Example #7
Source File: LoginResourceTest.java From cassandra-reaper with Apache License 2.0 | 5 votes |
@Test public void testLogin() throws IOException { try (InputStream is = ResourceUtils.getInputStreamForPath("classpath:shiro.ini")) { Ini ini = new Ini(); ini.load(is); new WebIniSecurityManagerFactory(ini).getInstance().authenticate(new UsernamePasswordToken("admin", "admin")); } }
Example #8
Source File: LoginResourceLdapTest.java From cassandra-reaper with Apache License 2.0 | 5 votes |
@Test public void testLoginLdap() throws IOException { try (InputStream is = ResourceUtils.getInputStreamForPath("classpath:test-shiro-ldap.ini")) { Ini ini = new Ini(); ini.load(is); int port = embeddedLdapRule.embeddedServerPort(); ini.setSectionProperty("main", "ldapRealm.contextFactory.url", "ldap://localhost:" + port); new WebIniSecurityManagerFactory(ini).getInstance().authenticate(new UsernamePasswordToken("sclaus", "abcdefg")); } }
Example #9
Source File: ShiroIniConverterTest.java From attic-aurora with Apache License 2.0 | 4 votes |
@Test(expected = ParameterException.class) public void testDoParseNonexistent() { parser.convert(ResourceUtils.CLASSPATH_PREFIX + NONEXISTENT_RESOURCE); }