List of usage examples for org.apache.shiro.realm.text IniRealm getIni
public Ini getIni()
From source file:io.bootique.shiro.realm.IniRealmFactoryTest.java
License:Apache License
@Test public void testCreateRealm() { IniRealmFactory factory = new IniRealmFactory(); factory.setName("xyz"); factory.setRoles(Collections.singletonMap("r1", "p1, p2")); factory.setUsers(Collections.singletonMap("u1", "up, r1")); IniRealm realm = (IniRealm) factory.createRealm(mock(Injector.class)); assertEquals("xyz", realm.getName()); assertNull(realm.getResourcePath()); Ini ini = realm.getIni(); assertNotNull(realm.getIni());/* ww w. java2s . c o m*/ assertNotNull(ini.getSection("users")); assertNotNull(ini.getSection("roles")); }
From source file:org.apache.activemq.shiro.ShiroPluginTest.java
License:Apache License
public void testNoEnvironmentOrSecurityManager() throws Exception { //should build IniEnvironment from shiro.ini in the classpath at the least: ShiroPlugin plugin = new ShiroPlugin(); plugin.installPlugin(new MutableBrokerFilter(null)); Ini ini = Ini.fromResourcePath("classpath:shiro.ini"); IniRealm realm = (IniRealm) ((DefaultSecurityManager) plugin.getEnvironment().getSecurityManager()) .getRealms().iterator().next(); assertEquals(ini, realm.getIni()); }
From source file:org.apache.activemq.shiro.ShiroPluginTest.java
License:Apache License
public void testSetIni() throws Exception { ShiroPlugin plugin = new ShiroPlugin(); Ini ini = Ini.fromResourcePath("classpath:minimal.shiro.ini"); plugin.setIni(ini);//from w ww .ja va2s . c o m plugin.installPlugin(new MutableBrokerFilter(null)); IniRealm realm = (IniRealm) ((DefaultSecurityManager) plugin.getEnvironment().getSecurityManager()) .getRealms().iterator().next(); assertSame(ini, realm.getIni()); }
From source file:org.apache.activemq.shiro.ShiroPluginTest.java
License:Apache License
public void testSetIniString() throws Exception { ShiroPlugin plugin = new ShiroPlugin(); plugin.setIniConfig("[users]\n" + "system = manager, system\n" + "[roles]\n" + "system = *"); plugin.installPlugin(new MutableBrokerFilter(null)); IniRealm realm = (IniRealm) ((DefaultSecurityManager) plugin.getEnvironment().getSecurityManager()) .getRealms().iterator().next(); Ini ini = realm.getIni(); assertEquals(1, ini.getSection("users").size()); assertEquals("manager, system", ini.getSection("users").get("system")); assertEquals(1, ini.getSection("roles").size()); assertEquals("*", ini.getSection("roles").get("system")); }
From source file:org.apache.activemq.shiro.ShiroPluginTest.java
License:Apache License
public void testSetIniResourcePath() throws Exception { ShiroPlugin plugin = new ShiroPlugin(); String path = "classpath:minimal.shiro.ini"; plugin.setIniResourcePath(path);// w w w . j av a 2s. c o m plugin.installPlugin(new MutableBrokerFilter(null)); Ini ini = Ini.fromResourcePath(path); IniRealm realm = (IniRealm) ((DefaultSecurityManager) plugin.getEnvironment().getSecurityManager()) .getRealms().iterator().next(); assertEquals(ini, realm.getIni()); }
From source file:org.apache.zeppelin.rest.GetUserList.java
License:Apache License
/** * function to extract users from shiro.ini *///from w w w . j a v a2 s .com public List<String> getUserList(IniRealm r) { List<String> userList = new ArrayList<>(); Map getIniUser = r.getIni().get("users"); if (getIniUser != null) { Iterator it = getIniUser.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); userList.add(pair.getKey().toString().trim()); } } return userList; }
From source file:org.apache.zeppelin.rest.GetUserList.java
License:Apache License
/*** * Get user roles from shiro.ini//from w w w . j av a 2 s. co m * @param r * @return */ public List<String> getRolesList(IniRealm r) { List<String> roleList = new ArrayList<>(); Map getIniRoles = r.getIni().get("roles"); if (getIniRoles != null) { Iterator it = getIniRoles.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); roleList.add(pair.getKey().toString().trim()); } } return roleList; }
From source file:org.apache.zeppelin.service.ShiroAuthenticationService.java
License:Apache License
/** Function to extract users from shiro.ini. */ private List<String> getUserList(IniRealm r) { List<String> userList = new ArrayList<>(); Map getIniUser = r.getIni().get("users"); if (getIniUser != null) { Iterator it = getIniUser.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); userList.add(pair.getKey().toString().trim()); }//w w w. ja va2 s . c om } return userList; }
From source file:org.apache.zeppelin.service.ShiroAuthenticationService.java
License:Apache License
/** * * Get user roles from shiro.ini.// w ww .ja v a 2 s.c o m * * @param r * @return */ private List<String> getRolesList(IniRealm r) { List<String> roleList = new ArrayList<>(); Map getIniRoles = r.getIni().get("roles"); if (getIniRoles != null) { Iterator it = getIniRoles.entrySet().iterator(); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); roleList.add(pair.getKey().toString().trim()); } } return roleList; }