2012-03-19 7 views
0

ここに問題の説明があります。私はGWTでWebアプリケーションを開発しています。私は、次のコードを使用して、認証機能のgwtにバネセキュリティを正常に統合しました。今私はWebアプリケーションで春の "メソッドセキュリティ"を使いたいと思っています。だから、僕は上記mentionnedアプリケーションコンテキストファイルに<global-method-security secured-annotations="enabled"/>を追加Springセキュリティメソッドの承認が機能しない

  • 、それはhttp://static.springsource.org/spring-security/site/docs/3.1.x/reference/ns-config.htmlに言ってやりました。

    <http> 
        <http-basic/> 
    
        <intercept-url pattern="/**" access=""/> 
    
        <form-login /> 
        <logout /> 
    </http> 
    
        <authentication-manager> 
        <authentication-provider> 
         <user-service> 
         <user name="jimis" password="jimispassword" authorities="ROLE_USER,ROLE_ADMIN" /> 
         <user name="bob" password="bobspassword" authorities="ROLE_ADMIN" /> 
         </user-service> 
        </authentication-provider> 
        </authentication-manager> 
    
        **<global-method-security secured-annotations="enabled"/>** 
    
  • 、アクセス

をcontroleする私はその後、私はのようにweb.xmlのアプリケーション・コンテキストの宣言を追加する機能の上に注釈@Secured(「ROLE_ADMIN」)を追加すること次

<?xml version="1.0" encoding="UTF-8"?> 
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
       http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
     version="2.5" 
     xmlns="http://java.sun.com/xml/ns/javaee"> 

<!-- Default page to serve --> 

    <welcome-file-list> 
    <welcome-file>App.html</welcome-file> 
    </welcome-file-list> 
    <session-config> 
    <session-timeout>10</session-timeout> <!-- in minutes --> 
    </session-config> 
<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value> 
     /WEB-INF/applicationContext-security.xml 
    </param-value> 
    </context-param> 

    <filter> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> 
    </filter> 

    <filter-mapping> 
    <filter-name>springSecurityFilterChain</filter-name> 
    <url-pattern>/*</url-pattern> 
    </filter-mapping> 

    <listener> 
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
    </listener> 
<servlet> 
    <servlet-name>appService</servlet-name> 
    <servlet-class>com.google.gwt.app.example.server.AppServiceImpl</servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>appService</servlet-name> 
    <url-pattern>/app/appService.rpc</url-pattern> 
    </servlet-mapping> 

</web-app> 

私はgwt-servletをSpringディスパッチャーサーブレットではなく宣言しました。

しかし、この設定は機能しないようです。実際、どのような役割であれ、機能にアクセスする権限を持つことができます。 非常に奇妙です。 あなたの答えを期待してください!

答えて

2

両方の属性を含む単一のglobal-method-security要素を使用します。

メソッドセキュリティとWebコントローラの使用に関する問題については、relevant section of the Spring Security FAQも読んでください(これについては、ここで説明する同じ問題があります)。

報告するログメッセージはエラーではなく、式内でhasPermission()を使用している場合を除き、重要ではありません。

+0

ありがとう、最初の解説のために、私は<! - lhuang

+0

をやったことがあります。 <! - lhuang

+0

申し訳ありませんが、あなたの答えを投票する権利はありませんでしたが、それは本当に役に立ちます – lhuang

関連する問題