List of usage examples for org.apache.shiro.realm.text IniRealm IniRealm
public IniRealm(String resourcePath)
From source file:ApacheShiro.ShiroMVC.java
public void AgregarRol(String nombreRol, String Permisos) { roles.put(nombreRol, Permisos);/*from www . j av a 2 s .c om*/ defaultSecurityManager.setRealm(new IniRealm(ini)); SecurityUtils.setSecurityManager(defaultSecurityManager); }
From source file:ch.reboundsoft.shinobi.authstore.realm.IniRealmFactory.java
@Inject public IniRealmFactory(NinjaProperties ninjaProperties) { realm = new IniRealm("classpath:shiro.ini"); }
From source file:io.bootique.shiro.realm.IniRealmFactory.java
License:Apache License
@Override public Realm createRealm(Injector injector) { Ini ini = new Ini(); if (users != null && !users.isEmpty()) { ini.addSection("users").putAll(users); }/*from ww w.j a v a 2 s . c o m*/ if (roles != null && !roles.isEmpty()) { ini.addSection("roles").putAll(roles); } IniRealm realm = new IniRealm(ini); realm.setIni(ini); if (name != null) { realm.setName(name); } return realm; }
From source file:org.killbill.billing.util.glue.IniRealmProvider.java
License:Apache License
@Override public IniRealm get() { try {/*from w ww . j ava 2s .c o m*/ final Factory<SecurityManager> factory = new IniSecurityManagerFactory( securityConfig.getShiroResourcePath()); // TODO Pierre hack - lame cast here, but we need to have Shiro go through its reflection magic // to parse the [main] section of the ini file. Without duplicating code, this seems to be possible only // by going through IniSecurityManagerFactory. final DefaultSecurityManager securityManager = (DefaultSecurityManager) factory.getInstance(); final Collection<Realm> realms = securityManager.getRealms(); IniRealm iniRealm = null; if (realms == null || realms.isEmpty()) { iniRealm = new IniRealm(securityConfig.getShiroResourcePath()); } else { for (final Realm cur : realms) { if (cur instanceof IniRealm) { iniRealm = (IniRealm) cur; break; } } } if (iniRealm != null) { // See JavaDoc warning: https://shiro.apache.org/static/1.2.3/apidocs/org/apache/shiro/realm/AuthenticatingRealm.html iniRealm.setAuthenticationCachingEnabled(true); return iniRealm; } else { throw new ConfigurationException(); } } catch (final ConfigurationException e) { log.warn("Unable to configure RBAC", e); return new IniRealm(); } }
From source file:org.killbill.billing.util.glue.RealmsFromShiroIniProvider.java
License:Apache License
public static Collection<Realm> get(final ConfigSource configSource) { final SecurityConfig securityConfig = new ConfigurationObjectFactory(configSource) .build(SecurityConfig.class); Collection<Realm> realms = null; try {/* w w w. ja v a 2s .c om*/ final Factory<SecurityManager> factory = new IniSecurityManagerFactory( securityConfig.getShiroResourcePath()); // TODO Pierre hack - lame cast here, but we need to have Shiro go through its reflection magic // to parse the [main] section of the ini file. Without duplicating code, this seems to be possible only // by going through IniSecurityManagerFactory. final DefaultSecurityManager securityManager = (DefaultSecurityManager) factory.getInstance(); realms = securityManager.getRealms(); } catch (final ConfigurationException e) { log.warn("Unable to configure RBAC", e); } return realms != null ? realms : ImmutableSet.<Realm>of(new IniRealm(securityConfig.getShiroResourcePath())); // Mainly for testing }
From source file:org.lbogdanov.poker.web.AppInitializer.java
License:Apache License
/** * {@inheritDoc}//from w w w . j a v a 2 s.c o m */ @Override protected Injector getInjector() { SLF4JBridgeHandler.removeHandlersForRootLogger(); SLF4JBridgeHandler.install(); try { InputStream settings = Resources.newInputStreamSupplier(Resources.getResource("settings.properties")) .getInput(); Properties props = new Properties(); try { props.load(settings); } finally { settings.close(); } Settings.init(Maps.fromProperties(props)); } catch (IOException ioe) { throw Throwables.propagate(ioe); } final boolean isDevel = DEVELOPMENT_MODE.asBool().or(false); Module shiroModule = new ShiroWebModule(servletContext) { @Override @SuppressWarnings("unchecked") protected void configureShiroWeb() { bind(String.class).annotatedWith(Names.named(InjectableOAuthFilter.FAILURE_URL_PARAM)) .toInstance("/"); // TODO simple ini-based realm for development bindRealm().toInstance(new IniRealm(IniFactorySupport.loadDefaultClassPathIni())); bindRealm().to(InjectableOAuthRealm.class).in(Singleton.class); addFilterChain("/" + Constants.OAUTH_CLBK_FILTER_URL, Key.get(InjectableOAuthFilter.class)); addFilterChain("/" + Constants.OAUTH_FILTER_URL, config(CallbackUrlSetterFilter.class, Constants.OAUTH_CLBK_FILTER_URL), Key.get(InjectableOAuthUserFilter.class)); } @Provides @Singleton private OAuthProvider getOAuthProvider() { Google2Provider provider = new Google2Provider(); provider.setKey(GOOGLE_OAUTH_KEY.asString().get()); provider.setSecret(GOOGLE_OAUTH_SECRET.asString().get()); provider.setCallbackUrl("example.com"); // fake URL, will be replaced by CallbackUrlSetterFilter provider.setScope(Google2Scope.EMAIL_AND_PROFILE); return provider; } }; Module appModule = new ServletModule() { @Override protected void configureServlets() { ServerConfig dbConfig = new ServerConfig(); String jndiDataSource = DB_DATA_SOURCE.asString().orNull(); if (Strings.isNullOrEmpty(jndiDataSource)) { // use direct JDBC connection DataSourceConfig dsConfig = new DataSourceConfig(); dsConfig.setDriver(DB_DRIVER.asString().get()); dsConfig.setUrl(DB_URL.asString().get()); dsConfig.setUsername(DB_USER.asString().orNull()); dsConfig.setPassword(DB_PASSWORD.asString().orNull()); dbConfig.setDataSourceConfig(dsConfig); } else { dbConfig.setDataSourceJndiName(jndiDataSource); } dbConfig.setName("PlanningPoker"); dbConfig.setDefaultServer(true); dbConfig.addClass(Session.class); dbConfig.addClass(User.class); bind(EbeanServer.class).toInstance(EbeanServerFactory.create(dbConfig)); bind(SessionService.class).to(SessionServiceImpl.class); bind(UserService.class).to(UserServiceImpl.class); bind(WebApplication.class).to(PokerWebApplication.class); bind(MeteorServlet.class).in(Singleton.class); bind(ObjectMapper.class).toProvider(new Provider<ObjectMapper>() { @Override public ObjectMapper get() { SimpleModule module = new SimpleModule().addSerializer(UserSerializer.get()); return new ObjectMapper().registerModule(module); } }).in(Singleton.class); String wicketConfig = (isDevel ? RuntimeConfigurationType.DEVELOPMENT : RuntimeConfigurationType.DEPLOYMENT).toString(); ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); params.put(ApplicationConfig.FILTER_CLASS, WicketFilter.class.getName()) .put(ApplicationConfig.PROPERTY_SESSION_SUPPORT, Boolean.TRUE.toString()) .put(ApplicationConfig.BROADCAST_FILTER_CLASSES, TrackMessageSizeFilter.class.getName()) .put(ApplicationConfig.BROADCASTER_CACHE, UUIDBroadcasterCache.class.getName()) .put(ApplicationConfig.SHOW_SUPPORT_MESSAGE, Boolean.FALSE.toString()) .put(WicketFilter.FILTER_MAPPING_PARAM, "/*") .put(WebApplication.CONFIGURATION, wicketConfig) .put(WicketFilter.APP_FACT_PARAM, GuiceWebApplicationFactory.class.getName()) .put("injectorContextAttribute", Injector.class.getName()).build(); serve("/*").with(MeteorServlet.class, params.build()); } }; Stage stage = isDevel ? Stage.DEVELOPMENT : Stage.PRODUCTION; return Guice.createInjector(stage, ShiroWebModule.guiceFilterModule(), shiroModule, appModule); }
From source file:org.obiba.mica.security.SecurityManagerFactory.java
License:Open Source License
private Realm micaIniRealm() { IniRealm iniRealm = new IniRealm("classpath:shiro.ini"); iniRealm.setName(INI_REALM);// w w w.j a v a 2 s . c om iniRealm.setRolePermissionResolver(rolePermissionResolver); iniRealm.setPermissionResolver(permissionResolver); iniRealm.setCredentialsMatcher(new PasswordMatcher()); return iniRealm; }