getticket content failed

更新时间:2023-01-03 06:36:31 阅读: 评论:0


2023年1月3日发(作者:虎门外语学校)

cas登陆页定义异常提⽰(中英⽂等

cas登陆页定义异常提⽰(中英⽂等):

两种异常的处理⽅式不同,1,是通过配置⽂件指定⽤哪个异常类和⽅法2,是通过继承AuthenticationViaFormAction类实现(见后

⽂)

不同异常的提⽰,区分中英⽂

1,定义好⾃定义异常

2,在执⾏异常的地⽅抛出

3,定义好捕捉异常的处理器

property属性⽂件:

tNotFoundException=户名或密码错误.

LoginException=户名或密码错误.

tNotFoundExceptionEn=Invalidcredentials.

LoginExceptionEn=Invalidcredentials.

1,定义好⾃定义异常

tor;

xception;

/**

*Signalsthaturauthenticationfailed.

*

*

ThixceptionisthrownbyLoginModulesifauthenticationfailed.

*Forexample,aLoginModulethrowsthixceptionif

*theurenteredanincorrectpassword.

*

*/

publicclassFailedLoginExceptionEnextendsLoginException{

privatestaticfinallongrialVersionUID=816286L;

/**

*l

*messageisaStringthatdescribesthisparticularexception.

*/

publicFailedLoginExceptionEn(){

super();

}

/**

*ConstructsaFailedLoginExceptionwiththespecifieddetail

*lmessageisaStringthatdescribesthisparticular

*exception.

*

*

*

*@parammsgthedetailmessage.

*/

publicFailedLoginExceptionEn(Stringmsg){

super(msg);

}

}

2,在执⾏异常的地⽅抛出(这⾥覆写后要修改配置⽂件引⽤此类的路径)

publicclassQueryDatabaAuthenticationHandler

extendsAbstractJdbcUrnamePasswordAuthenticationHandler

{

{

@NotNull

privateStringsql;

protectedfinalHandlerResultauthenticateUrnamePasswordInternal(UrnamePasswordCredentialcredential)

throwsGeneralSecurityException,PreventedException

{

RemembermeAndCaptchacuCredential=(RemembermeAndCaptcha)credential;

Stringurname=rname();

intwebflag=flag();

StringencryptedPassword=getPasswordEncoder().encode(sword());

try{

StringdbPassword=(String)getJdbcTemplate().queryForObject(,,newObject[]{urname});

if(!(encryptedPassword)){

if(webflag==0){///中英⽂

thrownewFailedLoginException("Passworddoesnotmatchvalueonrecord.");//哪种异常

}el{

thrownewFailedLoginExceptionEn("Passworddoesnotmatchvalueonrecord.");

}

}

}catch(IncorrectResultSizeDataAccessExceptione){

if(ualSize()==0){

thrownewAccountNotFoundException(urname+"notfoundwithSQLquery");

}

thrownewFailedLoginException("Multiplerecordsfoundfor"+urname);

}

catch(DataAccessExceptione){

thrownewPreventedException("SQLexceptionwhileexecutingqueryfor"+urname,e);

}

returncreateHandlerResult(credential,newSimplePrincipal(urname),null);

}

3,定义好捕捉异常的处理器

publicclassAuthenticationExceptionHandler

{

privatestaticfinalStringUNKNOWN="UNKNOWN";

privatestaticfinalStringDEFAULT_MESSAGE_BUNDLE_PREFIX="authenticationFailure.";

privatestaticfinalList>DEFAULT_ERROR_LIST=newArrayList();

privatefinalLoggerlogger=ger(getClass());

static{

DEFAULT_ERROR_();

DEFAULT_ERROR_();

DEFAULT_ERROR_();

DEFAULT_ERROR_();

DEFAULT_ERROR_();

DEFAULT_ERROR_();

DEFAULT_ERROR_();

DEFAULT_ERROR_();

DEFAULT_ERROR_();

}

//类中

要增加⽐对哪些异常(复写)

AuthenticationExceptionHandler这个源码⾥⾯根据异常类名拼接配置属性,并获取值

/>

被注⼊的这个到那个视图

这个视图有什么属性

本文发布于:2023-01-03 06:36:31,感谢您对本站的认可!

本文链接:http://www.wtabcd.cn/fanwen/fan/90/82755.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

下一篇:创美英语
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图