shiro使用框架,自定义过滤器
1、shiro配置文件配置
<!-- Shiro Filter -->
<bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean">
<property name="securityManager" ref="securityManager" />
<property name="loginUrl" value="/login" />
<property name="successUrl" value="/" />
<property name="filterChainDefinitions">
<value>
/css/** = anon
/fonts/** = anon
/img/** = anon
/js/** = anon
/login = authc
/logout = logout
/** = myaAuth,authc
</value>
</property>
<!-- 自定义filter配置 -->
<property name="filters">
<map>
<entry key="myaAuth" value-ref="myaAuthFilter" />
</map>
</property>
</bean>
<bean id="myaAuthFilter" class="com.xxx.shiro.MyAuthFilter" />
2、自定义过滤器代码
package com.xxx.shiro;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.web.servlet.AdviceFilter;
public class MyAuthFilter extends AdviceFilter {
@Override
protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
if (isRule(request)) {//socket
} else {//不符合规则请求重定向为登录页面
httpServletResponse.sendRedirect("/login");
}
return super.preHandle(request, response);
}
private boolean isRule(ServletRequest request){
String header ="rule";//规则
if("rule".equalsIgnoreCase(header)){
return Boolean.TRUE;
}
return Boolean.FALSE;
}
}
}
shiro使用框架,自定义过滤器的更多相关文章
- flask框架下的jinja2模板引擎(2)(过滤器与自定义过滤器)
flask框架下的jinja2模块引擎(1):https://www.cnblogs.com/chichung/p/9774556.html 这篇论文主要用来记录下 jinja2 的过滤器. 什么是过 ...
- spring 集成shiro 之 自定义过滤器
在web.xml中加入 <!-- 过期时间配置 --> <session-config><session-timeout>3</session-timeout ...
- shiro 自定义过滤器,拦截过期session的请求,并且以ajax形式返回
自定义过滤器: public class CustomFormAuthenticationFilter extends FormAuthenticationFilter { @Override pro ...
- Web框架之Django_04 模板层了解(过滤器、标签、自定义过滤器、标签、inclusion_tag、模板的继承与导入)
摘要: 模版层(模板语法) 模板语法 过滤器 标签 自定义过滤器.标签 inclusion_tag 模板的继承 模板的导入 一.模板语法: 常用语法:{{ }} 变量相关{% %} ...
- DRF框架(九)——drf偏移分页组件、drf游标分页组件(了解)、自定义过滤器、过滤器插件django-filter
drf偏移分页组件 paginations.py from rest_framework.pagination import LimitOffsetPagination class MyLimitOf ...
- Shiro安全框架【快速入门】就这一篇!
Shiro 简介 照例又去官网扒了扒介绍: Apache Shiro™ is a powerful and easy-to-use Java security framework that perfo ...
- SpringBoot集成Shiro安全框架
跟着我的步骤:先运行起来再说 Spring集成Shiro的GitHub:https://github.com/yueshutong/shiro-imooc 一:导包 <!-- Shiro安全框架 ...
- 1、Shiro 安全框架与Spring 整合详解
Apache Shiro 是一个安全认证框架,和 Spring Security 相比,在于他使用了比较简洁易懂的认证和授权方式.其提供的 native-session(即把用户认证后的授权信息保存在 ...
- shiro登录实现自定义路径跳转
一.实现需求 登录框架采用shiro,需根据不同客户端类型实现相对应定义页面跳转. 二.登录页jsp表单 <div class="input-prepend" title=& ...
随机推荐
- Android中使用异步线程更新UI视图的几种方法
在Android中子线程是不能更新ui的. 所以我们要通过其他方式来动态改变ui视图, 1.runOnUiThreadactivity提供的一个轻量级更新ui的方法,在Fragment需要使用的时候要 ...
- 初始HTML
了解HTML 1.1 HTML的作用 HTML就是用来制作网页 1.2 什么是HTML HTML是英文HyperText Markup Language的首字母缩写,即超文本标 ...
- android(2)——Structure of an Android Application
1 structure of an android application An Android application is primarily made up of three pieces: t ...
- WCF已超过传入消息(65536)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性
<?xml version="1.0" encoding="utf-8"?> <configuration> <connectio ...
- python windows 远程执行bat
本机环境:Win 10,python3.6 远程机器: Win7.WinServer 因python在windows上执行需要用到 wmi 模块. wmi 模块下载地址:https://sourcef ...
- SSH服务登陆验证
ssh服务登陆验证有两种方式: 1.基于用户名和密码 2.基于密钥 基于用户名和密码验证过程: 1)客户端想ssh服务器发起请求,服务器会把自己的公钥发送给客户端, 2)客户端用服务器的公钥加密自己的 ...
- How to Remove A Service Entry From Win10 Service List
Warning Please do this operation CAREFULLY, otherwise you may get something wrong with your system. ...
- Chapter 1 Secondary Sorting:Introduction
开始学习<数据算法:Hadoop/Spark大数据处理技巧>第1-5章,假期有空就摘抄下来,毕竟不是纸质的可以写写画画,感觉这样效果好点,当然复杂的东西仍然跳过.写博客越发成了做笔记的感觉 ...
- [原]Ubuntu 下安装apache+PHP
1.安装apache2 sudo apt-get install apache2 运行如下命令重启:sudo /etc/init.d/apache2 restart 在浏览器里输入http://loc ...
- 021.9 IO流 流总结
###################################################################################IO流的规律总结:解决的问题,开发 ...