2012-06-27 8 views
7

助けてください。spring-security.xmlファイルからSpring Securityを無効にする

xmlファイルの変数によってアプリケーションでスプリングセキュリティを無効または有効にする必要があります。

私の春-の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.1.xsd"> 

<http auto-config="true"> 
    <intercept-url pattern="/*" access="ROLE_ADMIN" /> 
    <logout logout-success-url="/mainpage" /> 
      <login login-success-url="/mainpage" /> 
</http> 

<authentication-manager> 
    <authentication-provider> 
     <user-service> 
      <user name="hey" password="there" authorities="ROLE_ADMIN" /> 
     </user-service> 
    </authentication-provider> 
</authentication-manager> 

は、これはどのように施行しすることができますか?おかげさまで

答えて

11

セキュリティ

要求パターンなしにこの属性を設定することにより、空のフィルタ・チェーンにマッピングすることができます。セキュリティは適用されず、Spring Securityの機能は利用できません。

http://static.springsource.org/spring-security/site/docs/3.1.x/reference/appendix-namespace.html#nsa-http-security

そう:

<http auto-config="true" security="none"> 

といつものように "なし" パラメータはspringEL式(とにかくよくサブセット)であることができます。この

希望は、あなたが探していたものです

EDIT。FOR

が、それは新しい機能がありますことを言及するのを忘れては春のセキュリティ3.1

http://static.springsource.org/spring-security/site/docs/3.1.x/reference/new-3.1.html#new-3.1-highlevel

EDIT2ですよりダイナミックなソリューションはBeanプロファイルを使用します。 http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/new-in-3.1.html#d0e1293http://blog.springsource.com/2011/02/11/spring-framework-3-1-m1-released/

+0

お返事ありがとうございます!しかし、まだ問題があります。 security = "none"を追加すると例外が表示されます:org.springframework.beans.factory.parsing.BeanDefinitionParsingException:設定上の問題:を使用して保護されていないパターンを定義している場合は、子要素を含めることはできません。それを行うために他の方法はありますか? – me1111

+0

@ me1111:回答を更新しました –

+0

ありがとうございました!リサーチ – me1111

関連する問題