Package org.apache.shiro.config

Examples of org.apache.shiro.config.Ini


     
     
      /*
       * Main ini section
       */
      Ini ini = new Ini();
      Section main = ini.addSection("main");
     

      /*
       * Get the login url
       * TODO: Should we also allow a configuration with a standard 403 response?
       */
      String loginUrl = (String) securityConfig.get("loginUrl");
      main.put("authc.loginUrl", loginUrl == null ? "/login/" : loginUrl);
     
      /*
       * Set up our realm, right now only LDAP
       * This also sets up an authorization cache
       * TODO: Add ability to have other and more advanced realms
       */
      Map<String,String> ldapConfig = (Map<String, String>) securityConfig.get("ldap");
      if (ldapConfig != null) {
        main.put("ldapRealm", "com.adaptrex.core.security.realm.BasicLdapRealm");
        main.put("ldapRealm.searchBase", ldapConfig.get("searchBase"));
        main.put("ldapRealm.userDnTemplate", ldapConfig.get("userDnTemplate"));
        main.put("ldapRealm.contextFactory.url", ldapConfig.get("url"));
        main.put("ldapRealm.authorizationCacheName", "com.adaptrex.cache.authorizationCache");
        main.put("ldapRealm.authenticationCacheName", "com.adaptrex.cache.authenticationCache");
      }
     
      // Adaptrex Shiro Cache Manager
      main.put("cacheManager", "com.adaptrex.core.security.shiro.AdaptrexShiroCacheManager");
      main.put("cacheManager.cacheManagerConfigFile", "classpath:adaptrex-ehcache.xml");
      main.put("securityManager.cacheManager", "$cacheManager");

      // Need to use native session for single sign on
      main.put("sessionManager", "org.apache.shiro.web.session.mgt.DefaultWebSessionManager");
      main.put("sessionManager.globalSessionTimeout", timeout);
      main.put("securityManager.sessionManager", "$sessionManager");

      // DAO for cached sessions
      main.put("sessionDAO", "org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO");
      main.put("sessionDAO.activeSessionsCacheName", "com.adaptrex.cache.ActiveSession." + ssoName);
      main.put("securityManager.sessionManager.sessionDAO", "$sessionDAO");
     
      // cookie for single sign on
      main.put("cookie", "org.apache.shiro.web.servlet.SimpleCookie");
      main.put("cookie.name", "session." + ssoName);
      main.put("cookie.path", "/");
      main.put("securityManager.sessionManager.sessionIdCookie", "$cookie");
     
     
      /*
       * URLs ini section
       */
      Section urls = ini.addSection("urls");
     
      /*
       * Add standard urls
       * TODO: login should be customized based on the config for this webapp
       */
 
View Full Code Here


     
     
      /*
       * Main ini section
       */
      Ini ini = new Ini();
      Section main = ini.addSection("main");
     

      /*
       * Get the login url
       * TODO: Should we also allow a configuration with a standard 403 response?
       */
      String loginUrl = (String) securityConfig.get("loginUrl");
      main.put("authc.loginUrl", loginUrl == null ? "/login/" : loginUrl);
     
      /*
       * Set up our realm, right now only LDAP
       * This also sets up an authorization cache
       * TODO: Add ability to have other and more advanced realms
       */
      Map<String,String> ldapConfig = (Map<String, String>) securityConfig.get("ldap");
      if (ldapConfig != null) {
        main.put("ldapRealm", "com.adaptrex.core.security.realm.BasicLdapRealm");
        main.put("ldapRealm.searchBase", ldapConfig.get("searchBase"));
        main.put("ldapRealm.userDnTemplate", ldapConfig.get("userDnTemplate"));
        main.put("ldapRealm.contextFactory.url", ldapConfig.get("url"));
        main.put("ldapRealm.authorizationCacheName", "com.adaptrex.cache.authorizationCache");
        main.put("ldapRealm.authenticationCacheName", "com.adaptrex.cache.authenticationCache");
      }
     
      // Adaptrex Shiro Cache Manager
      main.put("cacheManager", "com.adaptrex.core.security.shiro.AdaptrexShiroCacheManager");
      main.put("cacheManager.cacheManagerConfigFile", "classpath:adaptrex-ehcache.xml");
      main.put("securityManager.cacheManager", "$cacheManager");

      // Need to use native session for single sign on
      main.put("sessionManager", "org.apache.shiro.web.session.mgt.DefaultWebSessionManager");
      main.put("sessionManager.globalSessionTimeout", timeout);
      main.put("securityManager.sessionManager", "$sessionManager");

      // DAO for cached sessions
      main.put("sessionDAO", "org.apache.shiro.session.mgt.eis.EnterpriseCacheSessionDAO");
      main.put("sessionDAO.activeSessionsCacheName", "com.adaptrex.cache.ActiveSession." + ssoName);
      main.put("securityManager.sessionManager.sessionDAO", "$sessionDAO");
     
      // cookie for single sign on
      main.put("cookie", "org.apache.shiro.web.servlet.SimpleCookie");
      main.put("cookie.name", "session." + ssoName);
      main.put("cookie.path", "/");
      main.put("securityManager.sessionManager.sessionIdCookie", "$cookie");
     
     
      /*
       * URLs ini section
       */
      Section urls = ini.addSection("urls");
     
      /*
       * Add standard urls
       * TODO: login should be customized based on the config for this webapp
       */
 
View Full Code Here

        this.ini = ini;
        init();
    }

    public IniEnvironment(String iniConfig) {
        Ini ini = new Ini();
        ini.load(iniConfig);
        this.ini = ini;
        init();
    }
View Full Code Here

    }

    @Override
    public void init() throws ShiroException {
        //this.environment and this.securityManager are null.  Try Ini config:
        Ini ini = this.ini;
        if (ini != null) {
            apply(ini);
        }

        if (this.objects.isEmpty() && this.iniConfig != null) {
            ini = new Ini();
            ini.load(this.iniConfig);
            apply(ini);
        }

        if (this.objects.isEmpty() && this.iniResourePath != null) {
            ini = new Ini();
            ini.loadFromPath(this.iniResourePath);
            apply(ini);
        }

        if (this.objects.isEmpty()) {
            if (ResourceUtils.resourceExists("classpath:shiro.ini")) {
                ini = new Ini();
                ini.loadFromPath("classpath:shiro.ini");
                apply(ini);
            }
        }

        if (this.objects.isEmpty()) {
View Full Code Here

TOP

Related Classes of org.apache.shiro.config.Ini

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.