Skip to content

AccountStatusUserDetailsChecker implements MessageSourceAware #6151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -51,4 +54,13 @@ public void check(UserDetails user) {
"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);
}
}