Use SecurityContextHolderStrategy for NullSecurityContextRepository

Issue gh-11060
This commit is contained in:
Josh Cummings 2022-06-21 16:47:39 -06:00
parent 05b788d1ac
commit d18ff25b95
No known key found for this signature in database
GPG Key ID: A306A51F43B8E5A5
1 changed files with 3 additions and 1 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,6 +22,7 @@ import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.context.SecurityContextHolderStrategy;
import org.springframework.util.Assert;
/**
* @author Luke Taylor
@ -53,6 +54,7 @@ public final class NullSecurityContextRepository implements SecurityContextRepos
* @since 5.8
*/
public void setSecurityContextHolderStrategy(SecurityContextHolderStrategy strategy) {
Assert.notNull(this.securityContextHolderStrategy, "securityContextHolderStrategy cannot be null");
this.securityContextHolderStrategy = strategy;
}