SpringSecurityAuthorizationPolicy 에서 인증 또는 권한 부여에 실패하면 CamelAuthorizationException 이 발생합니다. 이는 예외와 같은 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>
<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>
Copy to ClipboardCopied!Toggle word wrapToggle overflow