2011-07-11 5 views
4

私のGWTアプリケーションでメソッドレベルのセキュリティを使用したいと思います。私は実際の例であるhereを見つけたので、Spring Security 3.1を使用しようとしていますが、form-loginは使用しません。読んだ後this answer最初のメソッドの呼び出しが成功したSecurityContextを取得したが、その後、次の呼び出しの前に、それをクリアします:。Springメソッドレベルセキュリティは2番目の呼び出しで失敗します

[org.springframework.security.web.context.HttpSessionSecurityContextRepository] - Obtained a valid SecurityContext from SPRING_SECURITY_CONTEXT: '[email protected]e9f089: Authentication: [email protected]e9f089' 
... 
[org.springframework.security.access.intercept.aspectj.AspectJMethodSecurityInterceptor] - Authorization successful 
... 
[org.springframework.security.web.context.SecurityContextPersistenceFilter] - SecurityContextHolder now cleared, as request processing completed 
... 
[org.springframework.security.web.context.HttpSessionSecurityContextRepository] - SecurityContext is empty or contents are anonymous - context will not be stored in HttpSession. 
[org.springframework.security.web.context.SecurityContextPersistenceFilter] - SecurityContextHolder now cleared, as request processing completed 
... 
[org.springframework.security.web.context.HttpSessionSecurityContextRepository] - HttpSession returned null object for SPRING_SECURITY_CONTEXT 

は、2番目の呼び出しは、ストレート最初だけで、ユーザがログインした後の後に起こる

がそれです私は他の答えに続き、<http pattern="/MyAppName/**" security="none" />を削除し、<intercept-url pattern="/MyAppName/**" access="permitAll()" />を追加したので、

次のように私のフィルタは、次のとおりです。

<http pattern="/favicon.ico" security="none" /> 

<http access-decision-manager-ref="accessDecisionManager" use-expressions="true" auto-config="false" entry-point-ref="LoginUrlAuthenticationEntryPoint"> 
    <form-login login-page="/Login.html" always-use-default-target="true" default-target-url="/Main.html?gwt.codesvr=127.0.0.1:9997" /> 
    <intercept-url pattern="/Login.html" access="permitAll()" /> 
    <intercept-url pattern="/Login2.html" access="permitAll()" /> 
    <intercept-url pattern="/MyAppName/**" access="permitAll()" /> 
    <intercept-url pattern="/**" access="isAuthenticated()" /> 
    <logout delete-cookies="JSESSIONID" logout-success-url="/Login.html" /> 
    <remember-me token-validity-seconds="86400" key="key" user-service-ref="userDetailsService" /> 
</http> 

私はグローバルメソッドのセキュリティのためにAspectJを使用して得られたが、私はその作業を取得することができれば、それを使用することはありません例を次に示します。

<global-method-security secured-annotations="enabled" pre-post-annotations="enabled" mode="aspectj" proxy-target-class="true" > 
    <expression-handler ref="expressionHandler"/> 
</global-method-security> 

これを読んでいただきありがとうございました

詳細が必要な場合はお知らせください。

+2

私はあなたが何かを管理しやすい方法に調整する必要があると思っています。多くの人がその問題を理解しようとするために、すべてのテキストを読み書きしています。 –

+0

ご意見ありがとうございます。私は3つの成功したコールのうち2つのログを削除しようとしました。 – WhiteKnight

答えて

0

この問題は解決されました。

解決策の最後の部分は、SecurityContextHolderをグローバルにする要求を削除することでした。

同じ問題が発生した場合は、thisポストが役立ちます。

+1

どのように問題を実際に解決しましたか?私は同じ問題を抱えています。私はリンクを通過したが、それは役に立たなかった。 – Tiny

+0

@Tiny 2つの要素の認証を取得しようとしている間、私はSecurityContextHolderをグローバルに設定していましたので、問題を解決して問題を解決しましたが、また、それがなぜ私が経験した問題を引き起こしたのか、ルークからは聞かなかった。 – WhiteKnight