2015-06-28 51 views
7

我有下面的代碼片段春季安全配置不受支持屬性

<http use-expressions="true" auto-config="false" 
     entry-point-ref="loginUrlAuthenticationEntryPoint" 
     access-decision-manager-ref="accessDecisionManager" disable-url-rewriting="false"> 
     <!--<custom-filter position="CONCURRENT_SESSION_FILTER" ref="concurrencyFilter" 
      /> --> 
     <custom-filter position="FORM_LOGIN_FILTER" 
      ref="usernamePasswordAuthenticationFilter" /> 
     <custom-filter position="LOGOUT_FILTER" ref="tapLockFilter" /> 

     <intercept-url pattern="/session/**" access="permitAll" /> 
     <intercept-url pattern="/deviceregistration/**" access="permitAll" /> 
     <intercept-url pattern="/session/lock" access="hasRole('ROLE_MEMBER')" /> 
     <intercept-url pattern="/app/resources/admin*" access="hasRole('ROLE_ADMIN')" /> 
     <intercept-url pattern="/app/SuperAppdashboard*" access="hasRole('ROLE_ADMIN')" /> 
     <intercept-url pattern="/app/*" access="hasRole('ROLE_MEMBER')" /> 


     <!--<session-management invalid-session-url="/tizelytics/session/invalidSession" 
      session-authentication-error-url="/tizelytics/session/accessDenied" session-authentication-strategy-ref="sas"> 
      </session-management> --> 

     <session-management invalid-session-url="/session/invalidSession" 
      session-authentication-error-url="/session/accessDenied" 
      session-fixation-protection="none"> 
      <concurrency-control max-sessions="1" 
       expired-url="/session/accessExpired" /> 
     </session-management> 
</http> 

當我在服務器上運行這個它拋出一個異常說

不支持的配置屬性:[permitAll,permitAll,hasRole('ROLE_ADMIN '),hasRole(' ROLE_ADMIN '),hasRole(' ROLE_MEMBER '),hasRole(' ROLE_MEMBER')]

這裏是我的訪問決策管理器bean機智欣相同的XML

<beans:bean id="accessDecisionManager" 
     class="org.springframework.security.access.vote.AffirmativeBased"> 
     <beans:constructor-arg> 
      <beans:list> 
       <beans:bean 
        class="org.springframework.security.access.vote.AuthenticatedVoter" /> 
       <beans:bean class="org.springframework.security.access.vote.RoleVoter" /> 
      </beans:list> 
     </beans:constructor-arg> 
</beans:bean> 

如果我刪除訪問決策管理器 - 裁判沒有拋出異常的應用程序正確啓動任何人都可以請指教?

+0

'AccessDecisionManager'是舊的基於字符串的訪問條件定義。你正在使用基於表達式的評估,所以你不需要它。 –

回答

14

由於您正在定義自己的accessDecisionManager,因此我沒有看到WebExpressionVoter作爲其列表中的一個bean。 WebExpressionVoter解析字符串像permitAll()hasRole()hasAuthority()等,所以,你的accessDecisionManager豆應該是:

<beans:bean id="accessDecisionManager" 
     class="org.springframework.security.access.vote.AffirmativeBased"> 
     <beans:constructor-arg> 
      <beans:list> 
       <beans:bean 
        class="org.springframework.security.access.vote.AuthenticatedVoter" /> 
       <beans:bean class="org.springframework.security.access.vote.RoleVoter" /> 
       <beans:bean class="org.springframework.security.web.access.expression.WebExpressionVoter" /> 
      </beans:list> 
     </beans:constructor-arg> 
</beans:bean>