- 浏览: 532628 次
- 性别:
- 来自: 天津
文章分类
- 全部博客 (230)
- java (87)
- c/c++/c# (39)
- ASP.net MVC (4)
- eclipse/visual studio (3)
- tomcat/weblogic/jetty (13)
- linux/unix/windows (20)
- html/javascript/jquery/kendo/bootstrap/layui/vue/react (31)
- hibernate/struts/spring/mybatis/springboot (21)
- lucene/solr/ELK (2)
- shiro (0)
- oracle/sqlserver/mysql/postgresql (23)
- shell/python/ruby (6)
- android (0)
- maven/ant (1)
- freemarker/thymeleaf/velocity (1)
- open source project (41)
- cache/memcached/redis (0)
- nosql/hadoop/hbase/mongodb (0)
- system architecture/dubbo/zookeeper (0)
- software testing (0)
- system optimization (0)
- system security (0)
- tcp/udp/http (2)
- roller/wordpress (2)
- 工具收藏 (8)
- 文摘 (4)
- 生活 (0)
最新评论
-
coconut_zhang:
这个demo 非常完整了,是指下面说的那个html 模版,模版 ...
flying sauser, thymeleaf实现PDF文件下载 -
a93456:
你好,你有完整的demo吗? String template这 ...
flying sauser, thymeleaf实现PDF文件下载 -
yujiaao:
fn 函数循环是没有必要的啊,可以改成
protecte ...
Java 笛卡尔积算法的简单实现 -
安静听歌:
设置了.setUseTemporaryFileDuringWr ...
使用jxl导出大数据量EXCEL时内存溢出的解决办法 -
q280499693:
写的很详细,但是我现在想知道他们是怎么定位log4j.prop ...
关于SLF4J结合Log4j使用时日志输出与指定的log4j.properties不同
最近查找了一些Spring security3的资料,感觉网上资料比较混乱,版本各异,对于初学者,摸不着头脑。其实找到门道,简单配置使用还是不难的。不过要想对框架运用自如,还是要阅读其的一些源码,其中lengyun,dead-knight对源码做了一些分析,是很不错的博文。自己e文又很烂,希望权威们能给出更完善和优秀的博文,也是我等的福音了。感谢以下几位网友,他们的博文还是很有帮助的:
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.xsd">
<global-method-security pre-post-annotations="enabled">
</global-method-security>
<!-- entry-point-ref 为用户第一次访问受保护的url时的处理程序. -->
<http use-expressions="true" entry-point-ref="authenticationEntryPoint">
<!-- 这里是拒绝用户访问的处理程序 -->
<access-denied-handler ref="accessDeniedHandler" />
<!-- 配置一些不需要认证过滤的地址 -->
<intercept-url pattern="/roots/login.jsp" filters="none" />
<intercept-url pattern="/css/**" filters="none" />
<intercept-url pattern="/common/**" filters="none" />
<intercept-url pattern="/images/**" filters="none" />
<intercept-url pattern="/scripts/**" filters="none" />
<intercept-url pattern="/DatePicker/**" filters="none" />
<intercept-url pattern="/fckeditor/**" filters="none" />
<!-- cooki认证的配置,具体 看rememberMeServices的配置. -->
<remember-me services-ref="rememberMeServices" />
<!--
增加一个filter,这点与Acegi是不一样的,不能修改默认的filter了,这个filter位于FILTER_SECURITY_INTERCEPTOR之前
-->
<custom-filter position="LOGOUT_FILTER" ref="logoutFilter"></custom-filter>
<custom-filter before="FILTER_SECURITY_INTERCEPTOR" ref="myFilter" />
<custom-filter position="FORM_LOGIN_FILTER" ref="myAuthFilter" />
<!-- 限制用户的最大登陆数,防止一个账号被多人使用 -->
<custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" />
<session-management
session-authentication-strategy-ref="sas" />
</http>
<!-- 认证管理器,实现用户认证的入口,主要实现UserDetailsService接口即可 如下,可以配置多个Provider-->
<authentication-manager alias="authenticationManager">
<authentication-provider ref="daoAuthenticationProvider">
<password-encoder hash="plaintext"></password-encoder>
</authentication-provider>
<authentication-provider ref="rememberMeAuthenticationProvider">
<password-encoder hash="plaintext"></password-encoder>
</authentication-provider>
</authentication-manager>
<beans:bean id="daoAuthenticationProvider"
class="org.springframework.security.authentication.dao.DaoAuthenticationProvider">
<beans:property name="userDetailsService" ref="myUserDetailService" />
</beans:bean>
<!--
一个自定义的filter,必须包含authenticationManager,accessDecisionManager,securityMetadataSource三个属性,
我们的所有控制将在这三个类中实现,解释详见具体配置
-->
<beans:bean id="myFilter" class="com.security.MyFilterSecurityInterceptor">
<beans:property name="authenticationManager" ref="authenticationManager" />
<beans:property name="accessDecisionManager" ref="myAccessDecisionManagerBean" />
<beans:property name="securityMetadataSource" ref="securityMetadataSource" />
</beans:bean>
<!--
下面的3个类,已做自动扫描 <beans:bean id="myUserDetailService"
class="com.security.MyUserDetailService" />
访问决策器,决定某个用户具有的角色,是否有足够的权限去访问某个资源 <beans:bean
id="myAccessDecisionManagerBean"
class="com.security.MyAccessDecisionManager"> </beans:bean>
资源源数据定义,即定义某一资源可以被哪些角色访问 <beans:bean id="securityMetadataSource"
class="com.security.MyInvocationSecurityMetadataSource" >
</beans:bean>
-->
<beans:bean id="logoutFilter"
class="org.springframework.security.web.authentication.logout.LogoutFilter">
<beans:constructor-arg value="/roots/login.jsp" />
<beans:constructor-arg>
<beans:list>
<beans:ref local="rememberMeServices" />
<beans:bean
class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler"></beans:bean>
</beans:list>
</beans:constructor-arg>
<beans:property name="filterProcessesUrl" value="/ss_Loginout"></beans:property>
</beans:bean>
<beans:bean id="concurrencyFilter"
class="org.springframework.security.web.session.ConcurrentSessionFilter">
<beans:property name="sessionRegistry" ref="sessionRegistry" />
<beans:property name="expiredUrl" value="/error/expired.jsp" />
</beans:bean>
<beans:bean id="sas"
class="org.springframework.security.web.authentication.session.ConcurrentSessionControlStrategy">
<beans:constructor-arg name="sessionRegistry"
ref="sessionRegistry" />
<beans:property name="maximumSessions" value="1" />
</beans:bean>
<beans:bean id="myAuthFilter"
class="com.security.fliter.MyUsernamePasswordAuthenticationFilter">
<beans:property name="sessionAuthenticationStrategy"
ref="sas" />
<beans:property name="authenticationManager" ref="authenticationManager" />
<beans:property name="rememberMeServices" ref="rememberMeServices"></beans:property>
<beans:property name="authenticationFailureHandler"
ref="failureHandler" />
<beans:property name="authenticationSuccessHandler"
ref="successHandler" />
<beans:property name="filterProcessesUrl" value="/ss_Login"></beans:property>
</beans:bean>
<beans:bean id="successHandler"
class="org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler">
<beans:property name="defaultTargetUrl" value="/roots/index.jsp" />
</beans:bean>
<beans:bean id="failureHandler"
class="org.springframework.security.web.authentication.SimpleUrlAuthenticationFailureHandler">
<beans:property name="defaultFailureUrl" value="/roots/login.jsp?error=true" />
</beans:bean>
<beans:bean id="sessionRegistry"
class="org.springframework.security.core.session.SessionRegistryImpl" />
<!--
remember me fliter 此fliter的配置没有使用留做参考 <beans:bean
id="rememberMeFilter"
class="org.springframework.security.web.authentication.rememberme.RememberMeAuthenticationFilter">
<beans:property name="rememberMeServices" ref="rememberMeServices" />
<beans:property name="authenticationManager"
ref="authenticationManager" /> </beans:bean>
-->
<beans:bean id="rememberMeServices"
class="org.springframework.security.web.authentication.rememberme.TokenBasedRememberMeServices">
<beans:property name="userDetailsService" ref="myUserDetailService" />
<beans:property name="key" value="springsecurityCookies1" />
<beans:property name="alwaysRemember" value="true"></beans:property>
<beans:property name="tokenValiditySeconds" value="86400"></beans:property>
<beans:property name="parameter" value="_spring_security_remember_me"></beans:property>
</beans:bean>
<beans:bean id="rememberMeAuthenticationProvider"
class="org.springframework.security.authentication.RememberMeAuthenticationProvider">
<beans:property name="key" value="springsecurityCookies1" />
</beans:bean>
<!--
此fliter的配置没有使用留做参考 <beans:bean id="exceptionTranslationFilter"
class="org.springframework.security.web.access.ExceptionTranslationFilter">
<beans:property name="authenticationEntryPoint"
ref="authenticationEntryPoint"/> <beans:property
name="accessDeniedHandler" ref="accessDeniedHandler"/> </beans:bean>
-->
<beans:bean id="authenticationEntryPoint"
class="org.springframework.security.web.authentication.LoginUrlAuthenticationEntryPoint">
<beans:property name="loginFormUrl" value="/roots/login.jsp" />
</beans:bean>
<beans:bean id="accessDeniedHandler"
class="org.springframework.security.web.access.AccessDeniedHandlerImpl">
<beans:property name="errorPage" value="/roots/login.jsp?error=ad" />
</beans:bean>
<!-- 下面配置,security对于方法的保护 -->
<beans:bean id="methodSecurityInterceptor"
class="org.springframework.security.access.intercept.aopalliance.MethodSecurityInterceptor">
<beans:property name="validateConfigAttributes">
<beans:value>false</beans:value>
</beans:property>
<beans:property name="authenticationManager">
<beans:ref bean="authenticationManager" />
</beans:property>
<beans:property name="accessDecisionManager">
<beans:ref bean="myAccessDecisionManagerBean" />
</beans:property>
<!-- 这里配置通过数据库配置来查找权限 myMethodSecurityMetadataSource 这个类继承AbstractMethodSecurityMetadataSource -->
<beans:property name="securityMetadataSource" ref="myMethodSecurityMetadataSource" />
<!--
说明:下面的模式是配置了ISome类的doSupervisor的方法只需要ROLE_SUPERVISOR 来访问 <value>
com.acegi.MethodInterceptionTest.method* = ROLE_ADMIN </value>
</property>
-->
</beans:bean>
<!--
在数据库里配置role and datebase... 下面的autoProxyCreator还是要配置切入点的.
myMethodSecurityMetadataSource 已经配置在自动扫描中.
-->
<beans:bean id="sprintsecurityAutoIntercept"
class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator"
scope="singleton">
<beans:property name="beanNames">
<!-- 在这里配置要切的类的名称, 可以为一个配置好的bean的id,多个id用逗号分隔 -->
<beans:value>*test</beans:value>
</beans:property>
<!-- 这里就写上切入点 -->
<beans:property name="interceptorNames">
<beans:list>
<beans:value>methodSecurityInterceptor</beans:value>
</beans:list>
</beans:property>
<!-- 这个,如果你的类被代理了,比如在spring中使用,一定要设置这个属性为true -->
<beans:property name="proxyTargetClass" value="true" />
</beans:bean>
<!--这里接收security日志的配置
<bean id="authenticationLoggerListener"
class="org.springframework.security.authentication.event.LoggerListener"/>
<bean id="authorizationLoggerListener"
class="org.springframework.security.access.event.LoggerListener"/>
-->
</beans:beans>
发表评论
-
easypoi 按照模板到出excel并合并单元格
2022-11-10 21:46 110这是entity类,注解的mergeVertical是纵向合 ... -
Spring Data JPA框架系列(三)-自定义Repository接口详解
2022-05-08 09:03 0前面讲了Spring Boot 整合Spring Boot ... -
Java时区处理之Date,Calendar,TimeZone,SimpleDateFormat
2017-03-31 14:59 1292一、概述 1、问题描述 使用Java处 ... -
logback的使用和logback.xml详解
2017-03-09 11:20 2138一、logback的介绍 Logback是由log4j ... -
jxls操作excel文件
2017-03-03 14:51 1019JXLS是基于Jakarta POI API的Excel报表 ... -
flying sauser, thymeleaf实现PDF文件下载
2016-06-17 14:58 5121thymeleaf 的资料比较少,资料大部分都是和spri ... -
thymeleaf与spring整合
2016-06-15 10:08 11921、使用的是Spring EL而不是Ognl。2、访问上下文 ... -
SpringMVC 400 Bad Request 问题
2016-06-15 09:11 1913在提交表单时,发生400错误,并未进入save方法。 ... -
eclipse插件Maven添加依赖查询无结果的解决方法(Select Dependency doesn't work)
2016-04-22 08:33 702在eclipse中用过maven的可能都遇到过这种情况,我 ... -
Java_Ant详解
2015-06-15 16:54 6911,什么是antant是构建工 ... -
httpClient通过代理(Http Proxy)进行请求
2014-09-16 14:18 1164httpClient通过代理(Http Proxy)进行请求 ... -
httpclient上传文件及传参数
2014-09-16 11:07 11524用到的包有commons-httpclient-3.0.1. ... -
Java文件下载的几种方式
2013-08-19 14:15 839public HttpServletResponse dow ... -
http上传文件深度解析-高性能http传输
2013-07-23 10:41 9727最近在做web服务器的时候将一些应用集成在了服务器里面,比 ... -
plupload实现多图片上传
2013-07-19 16:12 23205最近发现一个非常牛的上传组件(http://www.plu ... -
java servlet common-fileupload 实现的文件批量上传
2013-07-18 14:31 6370结合前辈们的代码, 写了个用servlet 和 common ... -
调用axis2 WebService三种方法
2013-06-28 13:41 1747第一:简单的使用axis2包自己实现调用 package ... -
java-jsch实现sftp文件操作
2013-06-26 13:55 3621(曾在天涯)的文章详细讲解了jsch中的函数以及用法 ht ... -
url encode的问题
2012-11-06 08:27 59141.urlencode和decode 字符的编码和解码在有中 ... -
Java集合运算(交集,并集,差集)
2012-11-02 14:59 12936在实现数据挖掘一些算法或者是利用空间向量模型来发现相似文档的时 ...
相关推荐
springsecurity使用配置详解,压缩包里包含主要的代码和详细的word文件说明。
Spring Security 配置实例XML文件
spring security3配置.pdf 参照网上的资料自己配了个,实现URL与权限关系动态在数据库里配置(即配置文件中不用配置URL权限控制信息),个人授权信息动态从数据库里取.
详细的spring security2.x配置
(4)项目除了security3的配置使用XML以外,其他基本使用注解配置完成 (5)项目采用的是5张数据表结构。前台及后台各采用了5张数据库表。当然你也可以进行修改后合并。 (6)数据库采用MYSQL 备份文件在src文件夹下...
spring mvc+spring security+自定义form表单+验证码+bootstrap
那么在Spring Security3的使用中,有4种方法: 一种是全部利用配置文件,将用户、权限、资源(url)硬编码在xml文件中,已经实现过,并经过验证; 二种是用户和权限用数据库存储,而资源(url)和权限的对应采用硬编码...
最近自学Spring Security,这里是我做的练习所产生的代码(SSM+Spring Security)包括一些注释等。
其实这些都不是问题,为了帮助学生理清思路把抽象的东西变的更加具体,我用Freemind 画了一幅Spring Security的一个整体概况图,从大的方向列出了配置一个Spring Security需要的一些东西,包括如何配置,配置文件中...
介绍了Spring Security 的配置方法及其使用技巧
spring security 结合cas 单点登录系统 cas客户端的配置文件
Spring Security3的使用方法有4种: 一种是全部利用配置文件,将用户、权限、资源(url)硬编码在xml文件中。 二种是用户和权限用数据库存储,而资源(url)和权限的对应采用硬编码配置。 三种是细分角色和权限,并将...
利用配置文件,将用户、权限、资源(url)硬编码在xml文件中。
本实例包含SpringSecurity3.0的基本配置,包含所需的Jar包和mysql数据库文件,直接导入myeclipes中并导入数据库即可运行,配置文件简单易懂,适合SpringSecurity初学者配置入门。数据库密码为md5加密后的字符串,可...
SpringBoot+SpringSecurity整合示例代码,实现了从数据库中获取信息进行登录认证和权限认证。 本项目为idea工程,请用idea2019导入(老版应该也可以)。 本项目用户信息所需sql文件,在工程的resources文件夹下,...
spring security配置项目下载,里面前台使用了easyui。 我的项目是用maven搭建的,如果你配置了maven,那么就会可以很轻松的运行起项目来了, 步骤: 1、在我的项目下找到database文件夹,把里面的union_ssh.sql文件...
主要功能如下: ===== 1、数据库 ====== Druid数据库连接池,监控数据库访问性能,详细统计SQL的执行性能,这对于...打war包:(dev、test、prod)指定配置文件 mvn clean package -Dmaven.test.skip=true -P test
NULL 博文链接:https://whp0731.iteye.com/blog/453796
3. Spring Security 4.2的新特性 27 3.1 Web改进 27 3.2配置改进 28 3.3杂项 28 4.样品和指南(从这里开始) 28 5. Java配置 29 5.1 Hello Web安全Java配置 29 5.1.1 AbstractSecurityWebApplicationInitializer 31 ...