Example usage for org.apache.shiro.web.util WebUtils getWebEnvironment

List of usage examples for org.apache.shiro.web.util WebUtils getWebEnvironment

Introduction

In this page you can find the example usage for org.apache.shiro.web.util WebUtils getWebEnvironment.

Prototype

public static WebEnvironment getWebEnvironment(ServletContext sc) 

Source Link

Document

Find the Shiro WebEnvironment for this web application, which is typically loaded via org.apache.shiro.web.env.EnvironmentLoaderListener .

Usage

From source file:com.thesett.util.security.web.ShiroDBRealmSetupListener.java

License:Apache License

/**
 * Obtains the Shiro RealmSecurityManager for this Servlet container.
 *
 * @param  sce A context event notifying what this Servlet container is.
 *
 * @return The Shiro RealmSecurityManager for this Servlet container.
 *//*w  ww. j a v a 2 s.  co m*/
protected RealmSecurityManager getRealmSecurityManager(ServletContextEvent sce) {
    LOG.fine("protected RealmSecurityManager getRealmSecurityManager(ServletContextEvent sce): called");

    WebEnvironment we = WebUtils.getWebEnvironment(sce.getServletContext());

    return (RealmSecurityManager) we.getSecurityManager();
}

From source file:org.seaborne.auth.shiro.DigestHttpAuthenticationFilterIniPassword.java

License:Apache License

private Section usersSection(ServletContext servletContext) {
    if (!initialized) {
        synchronized (this) {
            try {
                if (initialized)
                    return usersSection;
                initialized = true;/*from ww w.java 2s.c  o  m*/
                IniWebEnvironment env = (IniWebEnvironment) WebUtils.getWebEnvironment(servletContext);
                usersSection = env.getIni().getSection("users");
            } catch (Exception ex) {
                LoggerFactory.getLogger(getClass()).error("Failed to find the shiro.ini [users] section");
            }
        }
    }
    return usersSection;
}