org.nutz.integration.shiro.ShiroSessionProvider Maven / Gradle / Ivy
package org.nutz.integration.shiro;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.web.servlet.ShiroHttpServletRequest;
import org.nutz.mvc.SessionProvider;
/**
* 代理Nutz内部使用Session的调用为Shiro的Shiro的session
* @author wendal
*
*/
public class ShiroSessionProvider implements SessionProvider {
public HttpServletRequest filter(HttpServletRequest req, HttpServletResponse resp, ServletContext servletContext) {
if ("OPTIONS".equalsIgnoreCase(req.getMethod())) {
resp.addHeader("Access-Control-Allow-Origin", "*");
resp.addHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, Key");
}
if (req instanceof ShiroHttpServletRequest)
return req;
return new ShiroHttpServletRequest(req, servletContext, true);
}
public void notifyStop() {
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy