急!高分请教!spring security里如何将CAS的配置换成本地的啊!

J2EE 码拜 9年前 (2015-05-10) 941次浏览 0个评论
 

现因项目需要用spring security管理权限,想请教应如何配置,需要配置哪些信息啊?
权限管理的数据结构为,users(用户)、roles(角色\组)、resources(资源),角色和用户多对多、角色和资源多对多
以下代码是项目经理的初期配置(CAS的),如何改成本地的呢?
望高人指点一下啊!急!

	<beans:bean id="loggerListener"
		class="org.springframework.security.event.authentication.LoggerListener" />

	<http access-denied-page="/403.jsp"
		entry-point-ref="casProcessingFilterEntryPoint">
		<intercept-url pattern="/manage/system/**" access="ROLE_ADMIN" />
		<intercept-url pattern="/static/**" filters="none" />
		<intercept-url pattern="/template/**" filters="none" />
		<intercept-url pattern="/" filters="none" />
		<intercept-url pattern="/goManage.action?myUrl=login"
			filters="none" />
		<form-login login-page="/goManage.action?myUrl=login"
			authentication-failure-url="/goManage.action?myUrl=login&amp;error=true"
			default-target-url="/" />
		<logout logout-success-url="/goManage.action?myUrl=login" />
		<http-basic />
	</http>

	<authentication-manager alias="authenticationManager" />

	<authentication-provider user-service-ref="securityManager">
		<password-encoder hash="md5" />
	</authentication-provider>

	<beans:bean id="accessDecisionManager"
		class="org.springframework.security.vote.AffirmativeBased">
		<beans:property name="allowIfAllAbstainDecisions" value="false" />
		<beans:property name="decisionVoters">
			<beans:list>
				<beans:bean
					class="org.springframework.security.vote.RoleVoter" />
				<beans:bean
					class="org.springframework.security.vote.AuthenticatedVoter" />
			</beans:list>
		</beans:property>
	</beans:bean>

	<beans:bean id="resourceSecurityInterceptor"
		class="org.springframework.security.intercept.web.FilterSecurityInterceptor">
		<beans:property name="authenticationManager"
			ref="authenticationManager" />
		<beans:property name="accessDecisionManager"
			ref="accessDecisionManager" />
		<beans:property name="objectDefinitionSource"
			ref="secureResourceFilterInvocationDefinitionSource" />
		<beans:property name="observeOncePerRequest" value="false" />
		<custom-filter after="LAST" />
	</beans:bean>

	<beans:bean id="secureResourceFilterInvocationDefinitionSource"
		class="cn.crazyasp.common.rights.role.SecureResourceFilterInvocationDefinitionSource" />
	<beans:bean id="securityManager"
		class="cn.crazyasp.common.rights.role.SecurityManager">
		<beans:property name="option" ref="tableoption" />
	</beans:bean>

	<!-- cas information -->
	<beans:bean id="casProcessingFilter"
		class="org.springframework.security.ui.cas.CasProcessingFilter">
		<custom-filter after="CAS_PROCESSING_FILTER" />
		<beans:property name="authenticationManager"
			ref="authenticationManager" />
		<beans:property name="authenticationFailureUrl"
			value="/casfailed.jsp" />
		<beans:property name="defaultTargetUrl" value="/" />
	</beans:bean>

	<beans:bean id="casProcessingFilterEntryPoint"
		class="org.springframework.security.ui.cas.CasProcessingFilterEntryPoint">
		<beans:property name="loginUrl"
			value="http://sso.crazysns.cn/login" />
		<beans:property name="serviceProperties"
			ref="casServiceProperties" />
	</beans:bean>

	<beans:bean id="casServiceProperties"
		class="org.springframework.security.ui.cas.ServiceProperties">
		<beans:property name="service"
			value="http://localhost:8080/hr/j_spring_cas_security_check" />
		<beans:property name="sendRenew" value="false" />
	</beans:bean>

	<beans:bean id="casAuthenticationProvider"
		class="org.springframework.security.providers.cas.CasAuthenticationProvider">
		<custom-authentication-provider />
		<!-- user control with db -->
		<beans:property name="userDetailsService" ref="userControl" />
		<beans:property name="serviceProperties"
			ref="casServiceProperties" />
		<beans:property name="ticketValidator">
			<beans:bean
				class="org.jasig.cas.client.validation.Cas20ServiceTicketValidator">
				<beans:constructor-arg index="0"
					value="http://127.0.0.1:8080/hr" />
			</beans:bean>
		</beans:property>
		<beans:property name="key" value="crazysns" />
	</beans:bean>

userControl是相关DAO,http://127.0.0.1:8080/hr是项目的本地测试网址。

我的QQ:523975404
MSN:tianjin_123@hotmail.com
Email:tjnxymxx312@126.com
15分
应该需要改动loginUrl去本地的CAS地址。

<beans:bean id="casProcessingFilterEntryPoint"
        class="org.springframework.security.ui.cas.CasProcessingFilterEntryPoint">
        <beans:property name="loginUrl"
            value="http://sso.crazysns.cn/login" />
        <beans:property name="serviceProperties"
            ref="casServiceProperties" />
    </beans:bean>
20分
org.springframework.security.intercept.web.FilterSecurityInterceptor 更改这个的实现,不要使用CAS的登录过滤器和认证过滤器对你的请求进行过滤,而是使用你自己的过滤器,然后你自己的认证做在这个过滤器里面。
引用 3 楼 sgcl 的回复:

应该需要改动loginUrl去本地的CAS地址。

XML code

<beans:bean id=”casProcessingFilterEntryPoint”
        class=”org.springframework.security.ui.cas.CasProcessingFilterEntryPoint”>
        <beans:property na……

是改成本地的登陆地址、页面吗?

5分
这个真的好难 我们项目组也有做权限的 
20分
是本地建一个CAS,然后连到本地CAS登录界面。
20分
不确定楼主改成本地配置是什么意思,是换成本地的CAS还是在本地直接登录(不使用CAS).
如果是要使用本地CAS,那么需要先建立本地CAS服务器,然后修改CAS登录地址信息

<beans:bean id="casProcessingFilterEntryPoint"
        class="org.springframework.security.ui.cas.CasProcessingFilterEntryPoint">
        <beans:property name="loginUrl"
            value="http://sso.crazysns.cn/login" />
        <beans:property name="serviceProperties"
            ref="casServiceProperties" />
    </beans:bean>

如果不用CAS,去掉http中的

entry-point-ref="casProcessingFilterEntryPoint"

就可以了

引用楼主 mxx123 的回复:

现因项目需要用spring security管理权限,想请教应如何配置,需要配置哪些信息啊?
权限管理的数据结构为,users(用户)、roles(角色\组)、resources(资源),角色和用户多对多、角色和资源多对多
以下代码是项目经理的初期配置(CAS的),如何改成本地的呢?
望高人指点一下啊!急!

XML code

    <beans:bean id=”loggerL……

项目经理说要把cas的改成本地的,其它不用改,可我不知道如何改啊?

引用 8 楼 katasoft 的回复:

不确定楼主改成本地配置是什么意思,是换成本地的CAS还是在本地直接登录(不使用CAS).
如果是要使用本地CAS,那么需要先建立本地CAS服务器,然后修改CAS登录地址信息

XML code
<beans:bean id=”casProcessingFilterEntryPoint”
        class=”org.springframework.security.ui.cas.……

过滤器拦截器什么的,项目经理已经建好了。
另外,除了去掉

entry-point-ref="casProcessingFilterEntryPoint"

外,其他的还用改吗?

20分
引用 10 楼 mxx123 的回复:

过滤器拦截器什么的,项目经理已经建好了。
另外,除了去掉
XML code

entry-point-ref=”casProcessingFilterEntryPoint”

外,其他的还用改吗?

看起来不需要、、、

引用 11 楼 katasoft 的回复:

引用 10 楼 mxx123 的回复:
过滤器拦截器什么的,项目经理已经建好了。
另外,除了去掉
XML code

entry-point-ref=”casProcessingFilterEntryPoint”

外,其他的还用改吗?

看起来不需要、、、

这位大哥,能否留个QQ或MSN啊?

楼上各位高人,能否留个QQ或MSN,小弟想进一步请教下啊?可否?

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明急!高分请教!spring security里如何将CAS的配置换成本地的啊!
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!