Security5国际化
默认提示信息是英文,如登录失败时返回的是Bad Credentials。提示很不友好,需要自定义本地化的提示信息。网上搜索,很多人跟踪源码后,还是要配置xml,重写MessageSource等。
仔细想了一下,国际化应该是针对整个项目的,应该不只是Security,应该可以通用配置。于是就在配置文件配置了自定义的路径 :
spring:
messages:
basename: i18n/messages_zh_CN
encoding: UTF-8
然后在resources目录下,把messages_zh_CN.properties拷到对应位置。然后Security果然也返回对应的中文提示了。
Security5.2的中文提示已经非常友好了,我直接拷过来用的。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | AbstractAccessDecisionManager.accessDenied=不允许访问 AbstractLdapAuthenticationProvider.emptyPassword=用户名或密码错误 AbstractSecurityInterceptor.authenticationNotFound=未在SecurityContext中查找到认证对象 AbstractUserDetailsAuthenticationProvider.badCredentials=用户名或密码错误 AbstractUserDetailsAuthenticationProvider.credentialsExpired=用户凭证已过期 AbstractUserDetailsAuthenticationProvider.disabled=用户已失效 AbstractUserDetailsAuthenticationProvider.expired=用户帐号已过期 AbstractUserDetailsAuthenticationProvider.locked=用户帐号已被锁定 AbstractUserDetailsAuthenticationProvider.onlySupports=仅仅支持UsernamePasswordAuthenticationToken AccountStatusUserDetailsChecker.credentialsExpired=用户凭证已过期 AccountStatusUserDetailsChecker.disabled=用户已失效 AccountStatusUserDetailsChecker.expired=用户帐号已过期 AccountStatusUserDetailsChecker.locked=用户帐号已被锁定 AclEntryAfterInvocationProvider.noPermission=给定的Authentication对象({ 0 })根本无权操控领域对象({ 1 }) AnonymousAuthenticationProvider.incorrectKey=展示的AnonymousAuthenticationToken不含有预期的key BindAuthenticator.badCredentials=用户名或密码错误 BindAuthenticator.emptyPassword=用户名或密码错误 CasAuthenticationProvider.incorrectKey=展示的CasAuthenticationToken不含有预期的key CasAuthenticationProvider.noServiceTicket=未能够正确提供待验证的CAS服务票根 ConcurrentSessionControlAuthenticationStrategy.exceededAllowed=已经超过了当前主体({ 0 })被允许的最大会话数量 DigestAuthenticationFilter.incorrectRealm=响应结果中的Realm名字({ 0 })同系统指定的Realm名字({ 1 })不吻合 DigestAuthenticationFilter.incorrectResponse=错误的响应结果 DigestAuthenticationFilter.missingAuth=遗漏了针对 'auth' QOP的、必须给定的摘要取值; 接收到的头信息为{ 0 } DigestAuthenticationFilter.missingMandatory=遗漏了必须给定的摘要取值; 接收到的头信息为{ 0 } DigestAuthenticationFilter.nonceCompromised=Nonce令牌已经存在问题了,{ 0 } DigestAuthenticationFilter.nonceEncoding=Nonce未经过Base64编码; 相应的nonce取值为 { 0 } DigestAuthenticationFilter.nonceExpired=Nonce已经过期/超时 DigestAuthenticationFilter.nonceNotNumeric=Nonce令牌的第 1 部分应该是数字,但结果却是{ 0 } DigestAuthenticationFilter.nonceNotTwoTokens=Nonce应该由两部分取值构成,但结果却是{ 0 } DigestAuthenticationFilter.usernameNotFound=用户名{ 0 }未找到 JdbcDaoImpl.noAuthority=没有为用户{ 0 }指定角色 JdbcDaoImpl.notFound=未找到用户{ 0 } LdapAuthenticationProvider.badCredentials=用户名或密码错误 LdapAuthenticationProvider.credentialsExpired=用户凭证已过期 LdapAuthenticationProvider.disabled=用户已失效 LdapAuthenticationProvider.expired=用户帐号已过期 LdapAuthenticationProvider.locked=用户帐号已被锁定 LdapAuthenticationProvider.emptyUsername=用户名不允许为空 LdapAuthenticationProvider.onlySupports=仅仅支持UsernamePasswordAuthenticationToken PasswordComparisonAuthenticator.badCredentials=用户名或密码错误 #PersistentTokenBasedRememberMeServices.cookieStolen=Invalid remember-me token (Series/token) mismatch. Implies previous cookie theft attack. ProviderManager.providerNotFound=未查找到针对{ 0 }的AuthenticationProvider RememberMeAuthenticationProvider.incorrectKey=展示RememberMeAuthenticationToken不含有预期的key RunAsImplAuthenticationProvider.incorrectKey=展示的RunAsUserToken不含有预期的key SubjectDnX509PrincipalExtractor.noMatching=未在subjectDN\: { 0 }中找到匹配的模式 SwitchUserFilter.noCurrentUser=不存在当前用户 SwitchUserFilter.noOriginalAuthentication=不能够查找到原先的已认证对象 |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· [AI/GPT/综述] AI Agent的设计模式综述