第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

spring security 如何捕捉AuthenticationProvider接口類中的異常

spring security 如何捕捉AuthenticationProvider接口類中的異常

暮色呼如 2018-08-14 16:10:44
spring boot 集成了spring security 在做驗證碼的時候用了AuthenticationProvider,在AuthenticationProvider實現(xiàn)中進行了驗證碼的校驗@Override public Authentication authenticate(Authentication authentication) throws AuthenticationException {     CaptchaWebAuthenticationDetails authenticationDetails= (CaptchaWebAuthenticationDetails) authentication.getDetails();     String inputCaptcha =   authenticationDetails.getInputCaptcha();     String sessionCaptcha   =authenticationDetails.getSessionCaptcha();     if (!inputCaptcha.equals(sessionCaptcha)){         throw new CaptchaException("erro");     }     return null; } 但是 throw new CaptchaException("erro");當(dāng)驗證碼錯誤的時候這個異常卻無法被全局異常處理捕捉到,瀏覽器直接拋出了Whitelabel Error Page,如何才能讓這個異常被全局異常處理捕捉到,求解?CaptchaException 繼承了RuntimeException 如果繼承AuthenticationException異常則無法捕捉,會繼續(xù)下面的賬號密碼驗證。
查看完整描述

1 回答

?
胡子哥哥

TA貢獻(xiàn)1825條經(jīng)驗 獲得超6個贊

ExceptionTranslationFilter應(yīng)該是會捕捉到AccessDeniedException和AuthenticationException的,說說我自己項目中如何使用spring security 做驗證碼校驗的,我們是自定義了一個類,它繼承UsernamePasswordAuthenticationFilter,然后重寫了attemptAuthentication這個方法,我們是在這里面做的驗證碼校驗的。


查看完整回答
反對 回復(fù) 2018-09-06
  • 1 回答
  • 0 關(guān)注
  • 2341 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號