package Ġcom . ar man . spring security rest . api . config . rest Ċ Ċ import Ġcom . ar man . spring security rest . api . service . Login Attempt Service Ċ import Ġorg . springframework . beans . factory . annotation . Autowired Ċ import Ġorg . springframework . http . HttpStatus Ċ import Ġorg . springframework . security . core . Authentication Exception Ċ import Ġorg . springframework . security . web . authentication . Simple Url Authentication Failure Handler Ċ import Ġorg . springframework . stereotype . Component Ċ import Ġjavax . security . auth . login . Login Exception Ċ import Ġjavax . servlet . http . HttpServletRequest Ċ import Ġjavax . servlet . http . HttpServletResponse Ċ Ċ @ Component Ċ class ĠRest Authentication Failure Handler Ġ: ĠSimple Url Authentication Failure Handler () Ġ{ ĊĊĠĠĠ Ġ@ Autowired ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġlogin Attempt Service : ĠLogin Attempt Service ĊĊĠĠĠ Ġ@ Throws ( Login Exception :: class ) ĊĠĠĠ Ġoverride Ġfun Ġon Authentication Failure ( request : ĠHttpServletRequest ?, Ġresponse : ĠHttpServletResponse ?, Ġexception : ĠAuthentication Exception ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġrequest ?. let Ġ{ Ġlogin Attempt Service . login Failed ( it ) Ġ} ĊĠĠĠĠĠĠĠ Ġresponse ?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġit . status Ġ= ĠHttpStatus . UN AUTHORIZ ED . value () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ }