package Ġcom . example . real world . handler Ċ Ċ import Ġcom . example . real world . dto . ErrorResponse Ċ import Ġcom . fasterxml . jackson . databind . ObjectMapper Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . http . MediaType Ċ import Ġorg . springframework . security . core . Authentication Exception Ċ import Ġorg . springframework . security . web . Authentication EntryPoint Ċ import Ġjavax . servlet . http . HttpServletRequest Ċ import Ġjavax . servlet . http . HttpServletResponse Ċ Ċ class ĠAuthentication EntryPoint Handler Ġ: ĠAuthentication EntryPoint Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġcomm ence ( ĊĠĠĠĠĠĠĠ Ġrequest : ĠHttpServletRequest , ĊĠĠĠĠĠĠĠ Ġresponse : ĠHttpServletResponse , ĊĠĠĠĠĠĠĠ Ġauth Exception : ĠAuthentication Exception ĊĠĠĠ Ġ) Ġ{ ĊĠĠĠĠĠĠĠ Ġresponse . contentType Ġ= ĠMediaType . APPLICATION _ JSON _ VALUE ĊĠĠĠĠĠĠĠ Ġresponse . status Ġ= ĠHttpStatus . FOR BID DEN . value () ĊĊĠĠĠĠĠĠĠ Ġval Ġresponse Body Ġ= ĠObjectMapper (). writeValue AsString ( ErrorResponse . of (" Access Ġdenied ! ")) ĊĠĠĠĠĠĠĠ Ġresponse . writer . write ( response Body !! ) ĊĠĠĠ Ġ} Ċ } Ċ