List of usage examples for org.apache.shiro.config Ini.Section containsKey
public boolean containsKey(Object key)
From source file:com.meltmedia.cadmium.servlets.shiro.WebEnvironment.java
License:Apache License
@Override protected FilterChainResolver createFilterChainResolver() { Ini.Section section = this.getIni().getSection(TRUSTED_SECTION_NAME); trustedHosts = new ArrayList<String>(); if (!CollectionUtils.isEmpty(section)) { logger.debug("Found " + TRUSTED_SECTION_NAME + " ini section in shiro.ini"); for (String key : section.keySet()) { logger.debug("Adding " + section.get(key) + " to list of trusted ip addresses."); trustedHosts.add(section.get(key).trim()); }//from w ww . j a v a 2s .c om } if (!CollectionUtils.isEmpty(trustedHosts)) { Ini.Section filterConfigs = getIni().getSection(IniFilterChainResolverFactory.FILTERS); if (CollectionUtils.isEmpty(filterConfigs)) { filterConfigs = getIni().addSection(IniFilterChainResolverFactory.FILTERS); } if (!filterConfigs.containsKey(DefaultFilter.authcBasic.name())) { filterConfigs.put(DefaultFilter.authcBasic.name(), "com.meltmedia.cadmium.servlets.shiro.TrustedBasicHttpAuthenticationFilter"); String trustedHostStr = ""; for (String host : trustedHosts) { if (trustedHostStr.length() > 0) { trustedHostStr += ","; } trustedHostStr += host; } filterConfigs.put(DefaultFilter.authcBasic.name() + ".trustedHosts", trustedHostStr); } } return super.createFilterChainResolver(); }
From source file:com.stormpath.shiro.servlet.env.StormpathShiroIniEnvironment.java
License:Apache License
private void addDefaultsToIni(Ini ini) { // TODO: this is not ideal, we need to make shiro a bit more flexible // and this is tightly coupled with the following method Ini.Section configSection = getConfigSection(ini); // lazy associate the client with the realm, so changes can be made if needed. if (!configSection.containsKey(DEFAULTS_STORMPATH_REALM_PROPERTY + ".client")) { configSection.put(DEFAULTS_STORMPATH_REALM_PROPERTY + ".client", "$" + DEFAULTS_STORMPATH_CLIENT_PROPERTY); }//from ww w.j a va 2s .com // global properties 'shiro.*' are not loaded from the defaults, we must set it in the ini. if (!configSection.containsKey("shiro.loginUrl")) { configSection.put("shiro.loginUrl", "/login"); } // protect the world if the URL section is missing Ini.Section urls = ini.getSection(IniFilterChainResolverFactory.URLS); Ini.Section filters = ini.getSection(IniFilterChainResolverFactory.FILTERS); // deprecated behavior if (CollectionUtils.isEmpty(urls) && CollectionUtils.isEmpty(filters)) { ini.setSectionProperty(IniFilterChainResolverFactory.URLS, "/**", DefaultFilter.authc.name()); } }
From source file:org.apache.geode.internal.security.shiro.SecurityManagerProvider.java
License:Apache License
public SecurityManagerProvider(String shiroConfig) { this.securityManager = null; IniSecurityManagerFactory factory = new IniSecurityManagerFactory("classpath:" + shiroConfig); // we will need to make sure that shiro uses a case sensitive permission resolver Ini.Section main = factory.getIni().addSection("main"); main.put("geodePermissionResolver", GeodePermissionResolver.class.getName()); if (!main.containsKey("iniRealm.permissionResolver")) { main.put("iniRealm.permissionResolver", "$geodePermissionResolver"); }//w ww . j a v a 2s.c o m shiroManager = factory.getInstance(); }
From source file:org.obiba.opal.core.upgrade.security.HashShiroIniPasswordUpgradeStepTest.java
License:Open Source License
@Test public void testExecute() throws Exception { String iniFileMd5 = new Md5Hash(iniFile).toHex(); upgradeStep.execute(null);//from ww w . j av a 2s.c om assertThat(iniBackup.exists()).isTrue(); assertThat(new Md5Hash(iniBackup).toHex()).isEqualTo(iniFileMd5); assertThat(destIniFile.exists()).isTrue(); assertThat(new Md5Hash(destIniFile).toHex()).isNotEqualTo(iniFileMd5); Ini ini = new Ini(); ini.loadFromPath(destIniFile.getAbsolutePath()); Ini.Section section = ini.getSection(IniRealm.USERS_SECTION_NAME); assertThat(section).isNotNull(); assertThat(section).hasSize(3); for (String username : usernamePassword.keySet()) { assertThat(section.containsKey(username)).isTrue(); String[] passwordAndRolesArray = StringUtils.split(section.get(username)); String encrypted = passwordAndRolesArray[0]; assertThat(passwordService.passwordsMatch(usernamePassword.get(username), encrypted)).isTrue(); } }