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>