From 6f5fa1b610c4b1b9d58a9bdb0f0f4a3c9ffef383 Mon Sep 17 00:00:00 2001 From: Wessel Nieboer Date: Tue, 4 Dec 2018 08:45:26 +0100 Subject: [PATCH] Make AccountStatusUserDetailsChecker implement MessageSourceAware Fixes: gh-3980 --- .../AccountStatusUserDetailsChecker.java | 16 ++++++++++++++-- .../security/messages_nl.properties | 0 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 core/src/main/resources/org/springframework/security/messages_nl.properties diff --git a/core/src/main/java/org/springframework/security/authentication/AccountStatusUserDetailsChecker.java b/core/src/main/java/org/springframework/security/authentication/AccountStatusUserDetailsChecker.java index d816fd893d..89512454bb 100644 --- a/core/src/main/java/org/springframework/security/authentication/AccountStatusUserDetailsChecker.java +++ b/core/src/main/java/org/springframework/security/authentication/AccountStatusUserDetailsChecker.java @@ -15,17 +15,20 @@ */ package org.springframework.security.authentication; +import org.springframework.context.MessageSource; +import org.springframework.context.MessageSourceAware; import org.springframework.security.core.SpringSecurityMessageSource; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsChecker; import org.springframework.context.support.MessageSourceAccessor; +import org.springframework.util.Assert; /** * @author Luke Taylor */ -public class AccountStatusUserDetailsChecker implements UserDetailsChecker { +public class AccountStatusUserDetailsChecker implements UserDetailsChecker, MessageSourceAware { - protected final MessageSourceAccessor messages = SpringSecurityMessageSource + protected MessageSourceAccessor messages = SpringSecurityMessageSource .getAccessor(); public void check(UserDetails user) { @@ -51,4 +54,13 @@ public class AccountStatusUserDetailsChecker implements UserDetailsChecker { "User credentials have expired")); } } + + /** + * @since 5.2 + */ + @Override + public void setMessageSource(MessageSource messageSource) { + Assert.notNull(messageSource, "messageSource cannot be null"); + this.messages = new MessageSourceAccessor(messageSource); + } } diff --git a/core/src/main/resources/org/springframework/security/messages_nl.properties b/core/src/main/resources/org/springframework/security/messages_nl.properties new file mode 100644 index 0000000000..e69de29bb2