@Provides Ini loadShiroIni() { return Ini.fromResourcePath("classpath:shiro.ini"); } }
public IniSecurityManagerFactory(String iniResourcePath) { this(Ini.fromResourcePath(iniResourcePath)); }
protected Realm iniRealmFromLocation(String iniLocation) { Ini ini = Ini.fromResourcePath(iniLocation); return new IniRealm( ini ); } }
/** * 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); }
ini = Ini.fromResourcePath(resourcePath); if (!CollectionUtils.isEmpty(ini)) { setIni(ini);
public IniSecurityManagerFactory(String iniResourcePath) { this(Ini.fromResourcePath(iniResourcePath)); }
/** * 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); }
ini = Ini.fromResourcePath(resourcePath); if (!CollectionUtils.isEmpty(ini)) { setIni(ini);
@Override protected Ini getFrameworkIni() { return Ini.fromResourcePath("classpath:buji-pac4j-default.ini"); } }
public IniSecurityManagerFactory(String iniResourcePath) { this(Ini.fromResourcePath(iniResourcePath)); }
@Override protected Ini getFrameworkIni() { return Ini.fromResourcePath("classpath:com/stormpath/shiro/servlet/config/stormpath-shiro.ini"); }
public IniRealm(String resourcePath) { this(); Ini ini = Ini.fromResourcePath(resourcePath); this.resourcePath = resourcePath; processDefinitions(ini); }
protected Realm iniRealmFromLocation(String iniLocation) { Ini ini = Ini.fromResourcePath(iniLocation); return new IniRealm( ini ); } }
private static Ini fromConfig(AuthConfig cfg) { try { final String iniPath = cfg.properties(String.class); return Ini.fromResourcePath(iniPath); } catch (Exception e) { throw new IllegalStateException("Failed to create " + Ini.class.getSimpleName(), e); } } }
/** * <pre> * ldapRealm.resourcePath=classpath:webapp/myroles.ini * </pre> * <p/> * <p/> * where <tt>myroles.ini</tt> is in <tt>src/main/resources/webapp</tt>, and takes the form: * <p/> * <pre> * [roles] * user_role = *:ToDoItemsJdo:*:*,\ * *:ToDoItem:*:* * self-install_role = *:ToDoItemsFixturesService:install:* * admin_role = * * </pre> * <p/> * <p/> * This 'ini' file can then be referenced by other realms (if multiple realm are configured * with the Shiro security manager). * * @see #setResourcePath(String) */ public void setResourcePath(String resourcePath) { if (permissionToRoleMapper != null) { throw new IllegalStateException("Permissions already set, " + permissionToRoleMapper.getClass().getName()); } final Ini ini = Ini.fromResourcePath(resourcePath); this.permissionToRoleMapper = new PermissionToRoleMapperFromIni(ini); }
@Override public synchronized void start() throws Exception { 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().get(); this.dogma = dogma; state = State.STARTED; }
@Override protected void 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. String resourcePath = getResourcePath(); if (CollectionUtils.isEmpty(this.users) && CollectionUtils.isEmpty(this.roles)) { //no account data manually populated - try the resource path: if (StringUtils.hasText(resourcePath)) { log.debug("Resource path {} defined. Creating INI instance.", resourcePath); Ini ini = Ini.fromResourcePath(resourcePath); processDefinitions(ini); } else { throw new IllegalStateException("No resource path was specified. Cannot load account data."); } } else { if (StringUtils.hasText(resourcePath)) { log.warn("Users or Roles are already populated. Resource path property will be ignored."); } } }
@Override public void activateService() throws Exception { configuration.refresh(); ShiroIniConfiguration config = configuration.get(); String iniResourcePath = config.iniResourcePath().get() == null ? Shiro.DEFAULT_INI_RESOURCE_PATH : config.iniResourcePath().get(); setIni( Ini.fromResourcePath( iniResourcePath ) ); securityManager = getInstance(); if ( realmsRefs != null && realmsRefs.iterator().hasNext() ) { // Register Realms Services RealmSecurityManager realmSecurityManager = ( RealmSecurityManager ) securityManager; Collection<Realm> iniRealms = new ArrayList<>( realmSecurityManager.getRealms() ); for ( ServiceReference<Realm> realmRef : realmsRefs ) { iniRealms.add( realmRef.get() ); LOG.debug( "Realm Service '{}' registered!", realmRef.identity() ); } realmSecurityManager.setRealms( iniRealms ); } ThreadContext.bind( securityManager ); }
@Override public void activateService() throws Exception { configuration.refresh(); ShiroIniConfiguration config = configuration.get(); String iniResourcePath = config.iniResourcePath().get() == null ? Shiro.DEFAULT_INI_RESOURCE_PATH : config.iniResourcePath().get(); setIni( Ini.fromResourcePath( iniResourcePath ) ); securityManager = getInstance(); if ( realmsRefs != null && realmsRefs.iterator().hasNext() ) { // Register Realms Services RealmSecurityManager realmSecurityManager = ( RealmSecurityManager ) securityManager; Collection<Realm> iniRealms = new ArrayList<>( realmSecurityManager.getRealms() ); for ( ServiceReference<Realm> realmRef : realmsRefs ) { iniRealms.add( realmRef.get() ); LOG.debug( "Realm Service '{}' registered!", realmRef.identity() ); } realmSecurityManager.setRealms( iniRealms ); } ThreadContext.bind( securityManager ); }
@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()); }