SpringSecurityAuthorizationPolicy 에서 인증 또는 인증이 실패하면 CamelAuthorizationException 이 발생합니다. 이는 Camel의 표준 예외 처리 방법(예: Exception Clause)을 사용하여 처리할 수 있습니다. CamelAuthorizationException 에는 예외를 throw한 정책의 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