스프링 프레임 워크 mvc 3 + 스프링 보안 3을 사용하고 있습니다. 스프링 보안에서 역할 계층 구조를 사용하고자합니다. http://static.springsource.org/spring-security/site/docs/3.1.x/reference/authz-arch.html에 따르면 난Java : 스프링 보안 3 역할 계층
<bean id="roleVoter" class="org.springframework.security.access.vote.RoleHierarchyVoter">
<constructor-arg ref="roleHierarchy" />
</bean>
<bean id="roleHierarchy"
class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl">
<property name="hierarchy">
ROLE_ADMIN > ROLE_STAFF
ROLE_STAFF > ROLE_USER
ROLE_USER > ROLE_GUEST
</property>
</bean>
그러나 내가 그것을 어디에 둬야 작성해야? 내 앱 security.xml에 넣어려고 :
<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">
<http>
<intercept-url pattern="/entryPost/**" access="ROLE_USER" requires-channel="https"/>
<intercept-url pattern="/entryDelete/**" access="ROLE_ADMIN" requires-channel="https"/>
<intercept-url pattern="/commentDelete/**" access="ROLE_ADMIN" requires-channel="https"/>
<intercept-url pattern="/login" access="ROLE_ANONYMOUS" requires-channel="https"/>
<form-login login-page="/login" default-target-url="/entryList/1" authentication-failure-url="/login?error=true" />
<logout logout-success-url="/login" />
<session-management>
<concurrency-control max-sessions="1" />
</session-management>
<access-denied-handler error-page="/accessDenied"/>
</http>
<authentication-manager>
<authentication-provider>
<jdbc-user-service data-source-ref="dataSource"
users-by-username-query="SELECT username,password,'true' as enabled FROM member WHERE username=?"
authorities-by-username-query="SELECT member.username,role FROM member,memberRole WHERE member.username=? AND member.id=memberRole.member_id"/>
</authentication-provider>
</authentication-manager>
<bean id="roleVoter" class="org.springframework.security.access.vote.RoleHierarchyVoter">
<constructor-arg ref="roleHierarchy" />
</bean>
<bean id="roleHierarchy" class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl">
<property name="hierarchy">
ROLE_ADMIN > ROLE_STAFF
ROLE_STAFF > ROLE_USER
ROLE_USER > ROLE_GUEST
</property>
</bean>
그러나 그것은 작동하지 않습니다 : HTTP 상태 404
I 앱-servlet.xml 파일에 넣어 경우 :
org.springfram :
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> <context:component-scan base-package="rus.web"/> <bean id="entryValidator" class="rus.domain.EntryValidator"/> <bean id="commentValidator" class="rus.domain.CommentValidator"/> <mvc:annotation-driven/> <mvc:resources mapping="/resources/**" location="/resources/"/> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="messages"/> </bean> <!--<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver"> <property name="defaultErrorView" value="error"/> </bean> --> <bean id="roleVoter" class="org.springframework.security.access.vote.RoleHierarchyVoter"> <constructor-arg ref="roleHierarchy" /> </bean> <bean id="roleHierarchy" class="org.springframework.security.access.hierarchicalroles.RoleHierarchyImpl"> <property name="hierarchy"> ROLE_ADMIN > ROLE_STAFF ROLE_STAFF > ROLE_USER ROLE_USER > ROLE_GUEST </property> </bean> </beans>
그것은 예외가 발생합니다 ework.beans.factory.xml.XmlBeanDefinitionStoreException : ServletContext 리소스 [/WEB-INF/rus-servlet.xml]의 XML 문서에서 35 번째 줄이 잘못되었습니다. 중첩 예외는 org.xml.sax.SAXParseException : cvc-complex-type.2.3 : 요소의 내용 유형이 요소 전용이기 때문에 'property'요소는 [children] 문자를 가질 수 없습니다.
org.xml.sax.SAXParseException : cvc-complex-type.2.3 : 요소의 콘텐츠 형식이 요소 전용이므로 요소 'property'에 문자 [children]을 포함 할 수 없습니다.
이 문제를 해결하려면 어떻게해야합니까?
나는 동일한 문제가있었습니다. 나는 여기에 지침을 따라 문제를 해결 : http://stackoverflow.com/questions/7809313/accessdeniedexception-if-using-rolehierarchyimpl –