Spring セキュリティを使用する場合、実行中のプロファイルごとにメソッドに対して異なる許容ロールを定義したいと思います。私が抱えている問題は、protect-pointcut 定義がコンテキスト プレースホルダーを受け入れないように見えることです (access="${secured.role} を使用している場合は変換されません)。各 Bean プロファイル内にセキュリティ要素を配置すると、STS は次のようになります。複数の global-security-method 要素が存在することを示す警告. 私はこれがなぜそうであるかを理解しています, 両方がこれをロードした2つのプロファイルを実行した場合、両方がロードされます. 1つのプロファイルのみを実行した場合 (これは私の意図です)正しいものがロードされます。
ここに私の定義があります:
<beans profile="security-ad">
<security:global-method-security>
<security:protect-pointcut access="ROLE_THAT_ROLE" expression="execution(* com.test.service.TestServiceImpl.testSecuredMethod(..))"/>
</security:global-method-security>
</beans>
<beans profile="security-tam">
<security:global-method-security>
<security:protect-pointcut access="ROLE_THIS_ROLE" expression="execution(* com.test.service.TestServiceImpl.testSecuredMethod(..))"/>
</security:global-method-security>
</beans>
<beans profile="security-embedded">
<security:global-method-security>
<security:protect-pointcut access="ROLE_ADMIN" expression="execution(* com.test.service.TestServiceImpl.testSecuredMethod(..))"/>
</security:global-method-security>
</beans>
STSを満足させながら、セキュリティ定義内でプロファイルベースの役割を達成する方法はありますか? これは実行されますが、プロジェクトにエラーがあるだけで、私には受け入れられません...