mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-01 09:42:13 +00:00
Add default strategy constructor
Closes gh-11059
This commit is contained in:
parent
cad2972d0a
commit
61c0a25bcd
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2002-2021 the original author or authors.
|
* Copyright 2002-2022 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -62,6 +62,32 @@ public final class ListeningSecurityContextHolderStrategy implements SecurityCon
|
|||||||
|
|
||||||
private final SecurityContextHolderStrategy delegate;
|
private final SecurityContextHolderStrategy delegate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a {@link ListeningSecurityContextHolderStrategy} based on
|
||||||
|
* {@link ThreadLocalSecurityContextHolderStrategy}
|
||||||
|
* @param listeners the listeners that should be notified when the
|
||||||
|
* {@link SecurityContext} is {@link #setContext(SecurityContext) set} or
|
||||||
|
* {@link #clearContext() cleared}
|
||||||
|
*
|
||||||
|
* @since 5.7
|
||||||
|
*/
|
||||||
|
public ListeningSecurityContextHolderStrategy(Collection<SecurityContextChangedListener> listeners) {
|
||||||
|
this(new ThreadLocalSecurityContextHolderStrategy(), listeners);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct a {@link ListeningSecurityContextHolderStrategy} based on
|
||||||
|
* {@link ThreadLocalSecurityContextHolderStrategy}
|
||||||
|
* @param listeners the listeners that should be notified when the
|
||||||
|
* {@link SecurityContext} is {@link #setContext(SecurityContext) set} or
|
||||||
|
* {@link #clearContext() cleared}
|
||||||
|
*
|
||||||
|
* @since 5.7
|
||||||
|
*/
|
||||||
|
public ListeningSecurityContextHolderStrategy(SecurityContextChangedListener... listeners) {
|
||||||
|
this(new ThreadLocalSecurityContextHolderStrategy(), listeners);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct a {@link ListeningSecurityContextHolderStrategy}
|
* Construct a {@link ListeningSecurityContextHolderStrategy}
|
||||||
* @param listeners the listeners that should be notified when the
|
* @param listeners the listeners that should be notified when the
|
||||||
|
@ -55,8 +55,8 @@ public class ListeningSecurityContextHolderStrategyTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void constructorWhenNullDelegateThenIllegalArgument() {
|
public void constructorWhenNullDelegateThenIllegalArgument() {
|
||||||
assertThatExceptionOfType(IllegalArgumentException.class)
|
assertThatExceptionOfType(IllegalArgumentException.class).isThrownBy(
|
||||||
.isThrownBy(() -> new ListeningSecurityContextHolderStrategy(null, (event) -> {
|
() -> new ListeningSecurityContextHolderStrategy((SecurityContextHolderStrategy) null, (event) -> {
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user