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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

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

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

暮色呼如 2018-08-14 16:10:44
spring boot 集成了spring security 在做驗(yàn)證碼的時(shí)候用了AuthenticationProvider,在AuthenticationProvider實(shí)現(xiàn)中進(jìn)行了驗(yàn)證碼的校驗(yà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)驗(yàn)證碼錯(cuò)誤的時(shí)候這個(gè)異常卻無(wú)法被全局異常處理捕捉到,瀏覽器直接拋出了Whitelabel Error Page,如何才能讓這個(gè)異常被全局異常處理捕捉到,求解?CaptchaException 繼承了RuntimeException 如果繼承AuthenticationException異常則無(wú)法捕捉,會(huì)繼續(xù)下面的賬號(hào)密碼驗(yàn)證。
查看完整描述

1 回答

?
胡子哥哥

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

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


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

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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