1
1
/*
2
- * Copyright 2002-2023 the original author or authors.
2
+ * Copyright 2002-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
28
28
import org .springframework .security .core .AuthenticationException ;
29
29
import org .springframework .security .web .AuthenticationEntryPoint ;
30
30
import org .springframework .security .web .DefaultRedirectStrategy ;
31
+ import org .springframework .security .web .RedirectStrategy ;
31
32
import org .springframework .util .Assert ;
32
33
33
34
/**
@@ -61,6 +62,8 @@ public class CasAuthenticationEntryPoint implements AuthenticationEntryPoint, In
61
62
*/
62
63
private boolean encodeServiceUrlWithSessionId = true ;
63
64
65
+ private RedirectStrategy redirectStrategy = new DefaultRedirectStrategy ();
66
+
64
67
@ Override
65
68
public void afterPropertiesSet () {
66
69
Assert .hasLength (this .loginUrl , "loginUrl must be specified" );
@@ -74,8 +77,7 @@ public final void commence(final HttpServletRequest servletRequest, HttpServletR
74
77
String urlEncodedService = createServiceUrl (servletRequest , response );
75
78
String redirectUrl = createRedirectUrl (urlEncodedService );
76
79
preCommence (servletRequest , response );
77
- new DefaultRedirectStrategy ().sendRedirect (servletRequest , response , redirectUrl );
78
- // response.sendRedirect(redirectUrl);
80
+ this .redirectStrategy .sendRedirect (servletRequest , response , redirectUrl );
79
81
}
80
82
81
83
/**
@@ -149,4 +151,14 @@ protected boolean getEncodeServiceUrlWithSessionId() {
149
151
return this .encodeServiceUrlWithSessionId ;
150
152
}
151
153
154
+ /**
155
+ * Sets the {@link RedirectStrategy} to use
156
+ * @param redirectStrategy the {@link RedirectStrategy} to use
157
+ * @since 6.3
158
+ */
159
+ public void setRedirectStrategy (RedirectStrategy redirectStrategy ) {
160
+ Assert .notNull (redirectStrategy , "redirectStrategy cannot be null" );
161
+ this .redirectStrategy = redirectStrategy ;
162
+ }
163
+
152
164
}
0 commit comments