Class WebTestUtils
java.lang.Object
org.springframework.security.test.web.support.WebTestUtils
A utility class for testing spring security
- Since:
- 4.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic CsrfTokenRepository
getCsrfTokenRepository
(jakarta.servlet.http.HttpServletRequest request) Gets theCsrfTokenRepository
for the specifiedHttpServletRequest
.static CsrfTokenRequestHandler
getCsrfTokenRequestHandler
(jakarta.servlet.http.HttpServletRequest request) Gets theCsrfTokenRequestHandler
for the specifiedHttpServletRequest
.static SecurityContextRepository
getSecurityContextRepository
(jakarta.servlet.http.HttpServletRequest request) Gets theSecurityContextRepository
for the specifiedHttpServletRequest
.static void
setCsrfTokenRepository
(jakarta.servlet.http.HttpServletRequest request, CsrfTokenRepository repository) Sets theCsrfTokenRepository
for the specifiedHttpServletRequest
.static void
setSecurityContextRepository
(jakarta.servlet.http.HttpServletRequest request, SecurityContextRepository securityContextRepository) Sets theSecurityContextRepository
for the specifiedHttpServletRequest
.
-
Method Details
-
getSecurityContextRepository
public static SecurityContextRepository getSecurityContextRepository(jakarta.servlet.http.HttpServletRequest request) Gets theSecurityContextRepository
for the specifiedHttpServletRequest
. If one is not found, a defaultHttpSessionSecurityContextRepository
is used.- Parameters:
request
- theHttpServletRequest
to obtain theSecurityContextRepository
- Returns:
- the
SecurityContextRepository
for the specifiedHttpServletRequest
-
setSecurityContextRepository
public static void setSecurityContextRepository(jakarta.servlet.http.HttpServletRequest request, SecurityContextRepository securityContextRepository) Sets theSecurityContextRepository
for the specifiedHttpServletRequest
.- Parameters:
request
- theHttpServletRequest
to obtain theSecurityContextRepository
securityContextRepository
- theSecurityContextRepository
to set
-
getCsrfTokenRepository
public static CsrfTokenRepository getCsrfTokenRepository(jakarta.servlet.http.HttpServletRequest request) Gets theCsrfTokenRepository
for the specifiedHttpServletRequest
. If one is not found, the defaultHttpSessionCsrfTokenRepository
is used.- Parameters:
request
- theHttpServletRequest
to obtain theCsrfTokenRepository
- Returns:
- the
CsrfTokenRepository
for the specifiedHttpServletRequest
-
getCsrfTokenRequestHandler
public static CsrfTokenRequestHandler getCsrfTokenRequestHandler(jakarta.servlet.http.HttpServletRequest request) Gets theCsrfTokenRequestHandler
for the specifiedHttpServletRequest
. If one is not found, the defaultXorCsrfTokenRequestAttributeHandler
is used.- Parameters:
request
- theHttpServletRequest
to obtain theCsrfTokenRequestHandler
- Returns:
- the
CsrfTokenRequestHandler
for the specifiedHttpServletRequest
-
setCsrfTokenRepository
public static void setCsrfTokenRepository(jakarta.servlet.http.HttpServletRequest request, CsrfTokenRepository repository) Sets theCsrfTokenRepository
for the specifiedHttpServletRequest
.- Parameters:
request
- theHttpServletRequest
to obtain theCsrfTokenRepository
repository
- theCsrfTokenRepository
to set
-