【发布时间】:2011-09-18 21:29:37
【问题描述】:
这是对this question的跟进。
我有一个扩展 AbstractUserDetailsAuthenticationProvider 的自定义 AuthenticationProvider。在 AdditionalAuthenticationChecks 中,我正在做一些自定义身份验证工作,此过程的一部分是在登录屏幕上向用户显示一些消息。目前,为了测试,我创建了一个 UserNotActivatedException:
class UserNotActivatedException extends AuthenticationException {
public UserNotActivatedException(String message, Throwable t) {
super(message, t)
}
public UserNotActivatedException(String message) {
super(message)
}
public UserNotActivatedException(String message, Object extraInformation) {
super(message, extraInformation)
}
}
在额外的AuthenticationChecks 中,我只是立即将其扔给测试。现在,我需要知道我需要做什么才能让我自己的失败消息显示在登录屏幕上。在 spring-security-core 默认配置中,我们可以覆盖以下内容:
errors.login.disabled = "Sorry, your account is disabled."
errors.login.expired = "Sorry, your account has expired."
errors.login.passwordExpired = "Sorry, your password has expired."
errors.login.locked = "Sorry, your account is locked."
errors.login.fail = "Sorry, we were not able to find a user with that username and password."
但我不知道如何添加自己的附加消息。
【问题讨论】: