Skip to content

Commit c7673e8

Browse files
franticticktickjzheaux
authored andcommitted
Polish AbstractAuthenticationTargetUrlRequestHandler
PR gh-16557 Signed-off-by: Max Batischev <[email protected]>
1 parent 56d2550 commit c7673e8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

web/src/main/java/org/springframework/security/web/authentication/AbstractAuthenticationTargetUrlRequestHandler.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -195,8 +195,10 @@ protected String getTargetUrlParameter() {
195195

196196
/**
197197
* Allows overriding of the behaviour when redirecting to a target URL.
198+
* @param redirectStrategy {@link RedirectStrategy} to use
198199
*/
199200
public void setRedirectStrategy(RedirectStrategy redirectStrategy) {
201+
Assert.notNull(redirectStrategy, "redirectStrategy cannot be null");
200202
this.redirectStrategy = redirectStrategy;
201203
}
202204

web/src/test/java/org/springframework/security/web/authentication/AbstractAuthenticationTargetUrlRequestHandlerTests.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525
import org.springframework.mock.web.MockHttpServletResponse;
2626

2727
import static org.assertj.core.api.Assertions.assertThat;
28+
import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
2829

2930
/**
3031
* @author Dayan Kodippily
@@ -108,4 +109,9 @@ void returnDefaultTargetUrlIfUseRefererIsFalse() {
108109
assertThat(this.handler.determineTargetUrl(this.request, this.response)).isEqualTo(DEFAULT_TARGET_URL);
109110
}
110111

112+
@Test
113+
void setRedirectStrategyWhenGivenNullThenThrowsException() {
114+
assertThatIllegalArgumentException().isThrownBy(() -> this.handler.setRedirectStrategy(null));
115+
}
116+
111117
}

0 commit comments

Comments
 (0)