323.4. 認証および認可エラーの処理
SpringSecurityAuthorizationPolicy で認証または認可が失敗した場合、CamelAuthorizationException が出力されます。これは、Exception Clause などの Camel の標準的な例外処理メソッドを使用して処理できます。CamelAuthorizationException には、例外を出力したポリシーの ID への参照が含まれているため、ポリシーと例外のタイプに基づいてエラーを処理できます。
<onException>
<exception>org.springframework.security.authentication.AccessDeniedException</exception>
<choice>
<when>
<simple>${exception.policyId} == 'user'</simple>
<transform>
<constant>You do not have ROLE_USER access!</constant>
</transform>
</when>
<when>
<simple>${exception.policyId} == 'admin'</simple>
<transform>
<constant>You do not have ROLE_ADMIN access!</constant>
</transform>
</when>
</choice>
</onException>