List of usage examples for org.apache.shiro.config Ini addSection
public Section addSection(String sectionName)
From source file:annis.security.MultipleIniWebEnvironment.java
License:Apache License
@Override public void init() throws ShiroException { Ini ini = new Ini(); Preconditions.checkNotNull(getConfigLocations()); for (String p : getConfigLocations()) { Ini subIni = new Ini(ini); subIni.loadFromPath(p);/*www .j a v a 2s. c o m*/ // add all values from the sub file to the main configuration for (Section section : subIni.getSections()) { Section existing = ini.getSection(section.getName()); if (existing == null) { existing = ini.addSection(section.getName()); } existing.putAll(section); } } setIni(ini); configure(); }
From source file:at.pollux.thymeleaf.shiro.dialect.ShiroDialectTest.java
License:Apache License
private static void setupShiro() { Ini ini = new Ini(); Ini.Section usersSection = ini.addSection("users"); usersSection.put(USER1, PASS1 + ",rolea,roled"); usersSection.put(USER2, PASS2 + ",roleb,rolec"); usersSection.put(USER3, PASS3 + ",rolec,rolee"); Ini.Section rolesSection = ini.addSection("roles"); rolesSection.put("rolea", "*"); rolesSection.put("roleb", "permtype1:permaction1:perminst1"); rolesSection.put("rolec", "permtype1:permaction2:*"); rolesSection.put("roled", "permtype3:*"); Factory<SecurityManager> factory = new TestIniSecurityManagerFactory(ini); SecurityManager secMgr = factory.getInstance(); setSecurityManager(secMgr);/*ww w .ja v a 2 s . c om*/ }
From source file:com.stormpath.shiro.servlet.env.StormpathShiroIniEnvironment.java
License:Apache License
private Ini.Section getConfigSection(Ini ini) { Ini.Section configSection = ini.getSection(IniSecurityManagerFactory.MAIN_SECTION_NAME); if (CollectionUtils.isEmpty(configSection)) { configSection = ini.getSection(Ini.DEFAULT_SECTION_NAME); if (configSection == null) { configSection = ini.addSection(Ini.DEFAULT_SECTION_NAME); }//from ww w . j ava2 s .c o m } return configSection; }
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); }/*w w w. j ava 2s . 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:net.ili.base.services.authority.MyFilterChainDefinition.java
/** * * @return @throws Exception//ww w .jav a 2 s.com */ @Override public Ini.Section getObject() throws Exception { Ini defaultIni = new Ini(); Ini ini = new Ini(); //url if (StringUtils.isNotEmpty(filterChainDefinitions)) { defaultIni.load(filterChainDefinitions); } ini.addSection(Ini.DEFAULT_SECTION_NAME); Ini.Section section = ini.getSection(Ini.DEFAULT_SECTION_NAME); //?Resource List<Resource> list = dao.findAll(); for (Resource resource : list) { //?section if (StringUtils.isNotEmpty(resource.getUrl()) && StringUtils.isNotEmpty(resource.getPermission())) { section.put(resource.getUrl(), MessageFormat.format(PREMISSIONEXP, resource.getPermission())); } } return section; }
From source file:org.apache.activemq.shiro.env.IniEnvironmentTest.java
License:Apache License
@Test public void testIniInstanceConstructorArg() { Ini ini = new Ini(); ini.addSection("users").put("foo", "bar"); env = new IniEnvironment(ini); authenticate();/*from w w w.jav a 2 s . c o m*/ }
From source file:org.apache.activemq.shiro.env.IniEnvironmentTest.java
License:Apache License
@Test public void testSetIni() { Ini ini = new Ini(); ini.addSection("users").put("foo", "bar"); env = new IniEnvironment(); env.setIni(ini);/*from w ww. ja v a2s . com*/ env.init(); authenticate(); }
From source file:org.apache.aurora.scheduler.config.CommandLineTest.java
License:Apache License
@Test public void testParseAllOptions() { File tempFile;//from w w w. j a v a 2 s . c o m try { tempFile = File.createTempFile(getClass().getCanonicalName(), null); } catch (IOException e) { throw new RuntimeException(e); } tempFile.deleteOnExit(); CliOptions expected = new CliOptions(); expected.reconciliation.transientTaskStateTimeout = TEST_TIME; expected.reconciliation.initialTaskKillRetryInterval = TEST_TIME; expected.reconciliation.reconciliationInitialDelay = TEST_TIME; expected.reconciliation.reconciliationExplicitInterval = TEST_TIME; expected.reconciliation.reconciliationImplicitInterval = TEST_TIME; expected.reconciliation.reconciliationScheduleSpread = TEST_TIME; expected.reconciliation.reconciliationBatchSize = 42; expected.reconciliation.reconciliationBatchInterval = TEST_TIME; expected.offer.holdOffersForever = true; expected.offer.minOfferHoldTime = TEST_TIME; expected.offer.offerHoldJitterWindow = TEST_TIME; expected.offer.offerStaticBanCacheMaxSize = 42L; expected.offer.offerFilterDuration = TEST_TIME; expected.offer.unavailabilityThreshold = TEST_TIME; expected.offer.offerOrder = ImmutableList.of(OfferOrder.CPU, OfferOrder.DISK); expected.offer.offerSetModule = NoopModule.class; expected.executor.customExecutorConfig = tempFile; expected.executor.thermosExecutorPath = "testing"; expected.executor.thermosExecutorResources = ImmutableList.of("testing"); expected.executor.thermosExecutorFlags = "testing"; expected.executor.thermosHomeInSandbox = true; expected.executor.executorOverheadCpus = 42; expected.executor.executorOverheadRam = new DataAmount(42, Data.GB); expected.executor.globalContainerMounts = ImmutableList.of(new Volume("/container", "/host", Mode.RO)); expected.executor.populateDiscoveryInfo = true; expected.app.maxTasksPerJob = 42; expected.app.maxUpdateInstanceFailures = 42; expected.app.allowedContainerTypes = ImmutableList.of(Container._Fields.DOCKER); expected.app.enableDockerParameters = true; expected.app.defaultDockerParameters = ImmutableList.of(new DockerParameter("a", "testing")); expected.app.requireDockerUseExecutor = false; expected.app.enableMesosFetcher = true; expected.app.allowContainerVolumes = true; expected.app.allowedJobEnvironments = "^(foo|bar|zaa)$"; expected.main.clusterName = "testing"; expected.main.serversetPath = "testing"; expected.main.serversetEndpointName = "testing"; expected.main.statsUrlPrefix = "testing"; expected.main.allowGpuResource = true; expected.main.driverImpl = DriverKind.V0_DRIVER; expected.scheduling.maxScheduleAttemptsPerSec = 42; expected.scheduling.flappingThreshold = TEST_TIME; expected.scheduling.initialFlappingDelay = TEST_TIME; expected.scheduling.maxFlappingDelay = TEST_TIME; expected.scheduling.maxReschedulingDelay = new TimeAmount(42, Time.DAYS); expected.scheduling.firstScheduleDelay = TEST_TIME; expected.scheduling.initialSchedulePenalty = TEST_TIME; expected.scheduling.maxSchedulePenalty = TEST_TIME; expected.scheduling.reservationDuration = TEST_TIME; expected.scheduling.schedulingMaxBatchSize = 42; expected.scheduling.maxTasksPerScheduleAttempt = 42; expected.async.asyncWorkerThreads = 42; expected.zk.inProcess = true; expected.zk.zkEndpoints = ImmutableList.of(InetSocketAddress.createUnresolved("testing", 42)); expected.zk.chrootPath = "testing"; expected.zk.sessionTimeout = TEST_TIME; expected.zk.connectionTimeout = TEST_TIME; expected.zk.digestCredentials = "testing"; expected.updater.enableAffinity = true; expected.updater.affinityExpiration = TEST_TIME; expected.state.taskAssignerModules = ImmutableList.of(NoopModule.class); expected.snapshot.snapshotInterval = TEST_TIME; expected.logPersistence.maxLogEntrySize = TEST_DATA; expected.backup.backupInterval = TEST_TIME; expected.backup.maxSavedBackups = 42; expected.backup.backupDir = new File("testing"); expected.aop.methodInterceptorModules = ImmutableList.of(NoopModule.class); expected.pruning.historyPruneThreshold = TEST_TIME; expected.pruning.historyMaxPerJobThreshold = 42; expected.pruning.historyMinRetentionThreshold = TEST_TIME; expected.pruning.jobUpdateHistoryPerJobThreshold = 42; expected.pruning.jobUpdateHistoryPruningInterval = TEST_TIME; expected.pruning.jobUpdateHistoryPruningThreshold = TEST_TIME; expected.driver.mesosMasterAddress = "testing"; expected.driver.frameworkAuthenticationFile = new File("testing"); expected.driver.frameworkFailoverTimeout = TEST_TIME; expected.driver.frameworkAnnouncePrincipal = true; expected.driver.frameworkName = "testing"; expected.driver.executorUser = "testing"; expected.driver.receiveRevocableResources = true; expected.driver.mesosRole = "testing"; expected.driver.isPartitionAware = true; expected.jetty.hostnameOverride = "testing"; expected.jetty.httpPort = 42; expected.jetty.listenIp = "testing"; expected.httpSecurity.shiroRealmModule = ImmutableList.of(NoopModule.class); expected.httpSecurity.shiroAfterAuthFilter = AnonymousFilter.class; expected.httpSecurity.httpAuthenticationMechanism = HttpAuthenticationMechanism.NEGOTIATE; expected.kerberos.serverKeytab = new File("testing"); expected.kerberos.serverPrincipal = new KerberosPrincipal("HTTP/aurora.example.com@EXAMPLE.COM"); expected.kerberos.kerberosDebug = true; Ini testIni = new Ini(); Section users = testIni.addSection("users"); users.putAll(ImmutableMap.of("root", "secret, admin", "wfarner", "password, eng", "ksweeney", "12345")); users.put("root", "secret, admin"); Section roles = testIni.addSection("roles"); roles.putAll(ImmutableMap.of("admin", "*", "eng", "thrift.AuroraSchedulerManager:*")); expected.iniShiroRealm.shiroIniPath = testIni; expected.iniShiroRealm.shiroCredentialsMatcher = AllowAllCredentialsMatcher.class; expected.api.enableCorsFor = "testing"; expected.preemptor.enablePreemptor = false; expected.preemptor.preemptionDelay = TEST_TIME; expected.preemptor.preemptionSlotHoldTime = TEST_TIME; expected.preemptor.preemptionSlotSearchInitialDelay = TEST_TIME; expected.preemptor.preemptionSlotSearchInterval = TEST_TIME; expected.preemptor.reservationMaxBatchSize = 42; expected.preemptor.slotFinderModules = ImmutableList.of(NoopModule.class); expected.mesosLog.quorumSize = 42; expected.mesosLog.logPath = new File("testing"); expected.mesosLog.zkLogGroupPath = "testing"; expected.mesosLog.coordinatorElectionTimeout = TEST_TIME; expected.mesosLog.coordinatorElectionRetries = 42; expected.mesosLog.readTimeout = TEST_TIME; expected.mesosLog.writeTimeout = TEST_TIME; expected.sla.slaRefreshInterval = TEST_TIME; expected.sla.slaProdMetrics = ImmutableList.of(MetricCategory.JOB_UPTIMES); expected.sla.slaNonProdMetrics = ImmutableList.of(MetricCategory.JOB_UPTIMES); expected.webhook.webhookConfigFile = tempFile; expected.scheduler.maxRegistrationDelay = TEST_TIME; expected.scheduler.maxLeadingDuration = TEST_TIME; expected.scheduler.maxStatusUpdateBatchSize = 42; expected.scheduler.maxTaskEventBatchSize = 42; expected.tiers.tierConfigFile = tempFile; expected.asyncStats.taskStatInterval = TEST_TIME; expected.asyncStats.slotStatInterval = TEST_TIME; expected.stats.samplingInterval = TEST_TIME; expected.stats.retentionPeriod = TEST_TIME; expected.cron.cronSchedulerNumThreads = 42; expected.cron.cronTimezone = "testing"; expected.cron.cronStartInitialBackoff = TEST_TIME; expected.cron.cronStartMaxBackoff = TEST_TIME; expected.cron.cronMaxBatchSize = 42; expected.resourceSettings.enableRevocableCpus = false; expected.resourceSettings.enableRevocableRam = true; assertAllNonDefaultParameters(expected); CliOptions parsed = CommandLine.parseOptions("-transient_task_state_timeout=42days", "-initial_task_kill_retry_interval=42days", "-reconciliation_initial_delay=42days", "-reconciliation_explicit_interval=42days", "-reconciliation_implicit_interval=42days", "-reconciliation_schedule_spread=42days", "-reconciliation_explicit_batch_size=42", "-reconciliation_explicit_batch_interval=42days", "-hold_offers_forever=true", "-min_offer_hold_time=42days", "-offer_hold_jitter_window=42days", "-offer_filter_duration=42days", "-unavailability_threshold=42days", "-offer_order=CPU,DISK", "-offer_set_module=org.apache.aurora.scheduler.config.CommandLineTest$NoopModule", "-offer_static_ban_cache_max_size=42", "-custom_executor_config=" + tempFile.getAbsolutePath(), "-thermos_executor_path=testing", "-thermos_executor_resources=testing", "-thermos_executor_flags=testing", "-thermos_home_in_sandbox=true", "-thermos_executor_cpu=42", "-thermos_executor_ram=42GB", "-global_container_mounts=/host:/container:ro", "-populate_discovery_info=true", "-max_tasks_per_job=42", "-max_update_instance_failures=42", "-allowed_container_types=DOCKER", "-allow_docker_parameters=true", "-default_docker_parameters=a=testing", "-require_docker_use_executor=false", "-enable_mesos_fetcher=true", "-allow_container_volumes=true", "-allowed_job_environments=^(foo|bar|zaa)$", "-cluster_name=testing", "-serverset_path=testing", "-serverset_endpoint_name=testing", "-viz_job_url_prefix=testing", "-allow_gpu_resource=true", "-mesos_driver=V0_DRIVER", "-max_schedule_attempts_per_sec=42", "-flapping_task_threshold=42days", "-initial_flapping_task_delay=42days", "-max_flapping_task_delay=42days", "-max_reschedule_task_delay_on_startup=42days", "-first_schedule_delay=42days", "-initial_schedule_penalty=42days", "-max_schedule_penalty=42days", "-offer_reservation_duration=42days", "-scheduling_max_batch_size=42", "-max_tasks_per_schedule_attempt=42", "-async_worker_threads=42", "-zk_in_proc=true", "-zk_endpoints=testing:42", "-zk_chroot_path=testing", "-zk_session_timeout=42days", "-zk_connection_timeout=42days", "-zk_digest_credentials=testing", "-enable_update_affinity=true", "-update_affinity_reservation_hold_time=42days", "-task_assigner_modules=org.apache.aurora.scheduler.config.CommandLineTest$NoopModule", "-dlog_snapshot_interval=42days", "-dlog_max_entry_size=42GB", "-backup_interval=42days", "-max_saved_backups=42", "-backup_dir=testing", "-thrift_method_interceptor_modules=" + "org.apache.aurora.scheduler.config.CommandLineTest$NoopModule", "-history_prune_threshold=42days", "-history_max_per_job_threshold=42", "-history_min_retention_threshold=42days", "-job_update_history_per_job_threshold=42", "-job_update_history_pruning_interval=42days", "-job_update_history_pruning_threshold=42days", "-mesos_master_address=testing", "-framework_authentication_file=testing", "-framework_failover_timeout=42days", "-framework_announce_principal=true", "-framework_name=testing", "-executor_user=testing", "-receive_revocable_resources=true", "-mesos_role=testing", "-hostname=testing", "-http_port=42", "-ip=testing", "-shiro_realm_modules=org.apache.aurora.scheduler.config.CommandLineTest$NoopModule", "-shiro_after_auth_filter=org.apache.shiro.web.filter.authc.AnonymousFilter", "-http_authentication_mechanism=NEGOTIATE", "-kerberos_server_keytab=testing", "-kerberos_server_principal=HTTP/aurora.example.com@EXAMPLE.COM", "-kerberos_debug=true", "-shiro_ini_path=" + ShiroIniConverterTest.class.getResource(EXAMPLE_RESOURCE).toString(), "-shiro_credentials_matcher=" + "org.apache.shiro.authc.credential.AllowAllCredentialsMatcher", "-enable_cors_for=testing", "-enable_preemptor=false", "-preemption_delay=42days", "-preemption_slot_hold_time=42days", "-preemption_slot_search_initial_delay=42days", "-preemption_slot_search_interval=42days", "-preemption_reservation_max_batch_size=42", "-preemption_slot_finder_modules=" + "org.apache.aurora.scheduler.config.CommandLineTest$NoopModule", "-native_log_quorum_size=42", "-native_log_file_path=testing", "-native_log_zk_group_path=testing", "-native_log_election_timeout=42days", "-native_log_election_retries=42", "-native_log_read_timeout=42days", "-native_log_write_timeout=42days", "-sla_stat_refresh_interval=42days", "-sla_prod_metrics=JOB_UPTIMES", "-sla_non_prod_metrics=JOB_UPTIMES", "-webhook_config=" + tempFile.getAbsolutePath(), "-max_registration_delay=42days", "-max_leading_duration=42days", "-max_status_update_batch_size=42", "-max_task_event_batch_size=42", "-tier_config=" + tempFile.getAbsolutePath(), "-async_task_stat_update_interval=42days", "-async_slot_stat_update_interval=42days", "-stat_sampling_interval=42days", "-stat_retention_period=42days", "-cron_scheduler_num_threads=42", "-cron_timezone=testing", "-cron_start_initial_backoff=42days", "-cron_start_max_backoff=42days", "-cron_scheduling_max_batch_size=42", "-enable_revocable_cpus=false", "-enable_revocable_ram=true", "-partition_aware=true"); assertEqualOptions(expected, parsed); }
From source file:org.killbill.billing.entitlement.EntitlementTestSuiteWithEmbeddedDB.java
License:Apache License
protected void configureShiro() { final Ini config = new Ini(); config.addSection("users"); config.getSection("users").put("EntitlementUser", "password, entitlement"); config.addSection("roles"); config.getSection("roles").put("entitlement", Permission.ACCOUNT_CAN_CREATE.toString() + "," + Permission.ENTITLEMENT_CAN_CREATE.toString() + "," + Permission.ENTITLEMENT_CAN_CHANGE_PLAN.toString() + "," + Permission.ENTITLEMENT_CAN_PAUSE_RESUME.toString() + "," + Permission.ENTITLEMENT_CAN_TRANSFER.toString() + "," + Permission.ENTITLEMENT_CAN_CANCEL.toString()); // Reset the security manager ThreadContext.unbindSecurityManager(); final Factory<SecurityManager> factory = new IniSecurityManagerFactory(config); final SecurityManager securityManager = factory.getInstance(); SecurityUtils.setSecurityManager(securityManager); }
From source file:org.killbill.billing.util.UtilTestSuiteNoDB.java
License:Apache License
protected void configureShiro() { final Ini config = new Ini(); config.addSection("users"); config.getSection("users").put("pierre", "password, creditor"); config.getSection("users").put("stephane", "password, refunder"); config.addSection("roles"); config.getSection("roles").put("creditor", Permission.INVOICE_CAN_CREDIT.toString() + "," + Permission.INVOICE_CAN_ITEM_ADJUST.toString()); config.getSection("roles").put("refunder", Permission.PAYMENT_CAN_REFUND.toString()); // Reset the security manager ThreadContext.unbindSecurityManager(); final Factory<SecurityManager> factory = new IniSecurityManagerFactory(config); final SecurityManager securityManager = factory.getInstance(); SecurityUtils.setSecurityManager(securityManager); }