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 CsrfTokenRepositorygetCsrfTokenRepository(jakarta.servlet.http.HttpServletRequest request) Gets theCsrfTokenRepositoryfor the specifiedHttpServletRequest.static CsrfTokenRequestHandlergetCsrfTokenRequestHandler(jakarta.servlet.http.HttpServletRequest request) Gets theCsrfTokenRequestHandlerfor the specifiedHttpServletRequest.static SecurityContextRepositorygetSecurityContextRepository(jakarta.servlet.http.HttpServletRequest request) Gets theSecurityContextRepositoryfor the specifiedHttpServletRequest.static voidsetCsrfTokenRepository(jakarta.servlet.http.HttpServletRequest request, CsrfTokenRepository repository) Sets theCsrfTokenRepositoryfor the specifiedHttpServletRequest.static voidsetSecurityContextRepository(jakarta.servlet.http.HttpServletRequest request, SecurityContextRepository securityContextRepository) Sets theSecurityContextRepositoryfor the specifiedHttpServletRequest.
-
Method Details
-
getSecurityContextRepository
public static SecurityContextRepository getSecurityContextRepository(jakarta.servlet.http.HttpServletRequest request) Gets theSecurityContextRepositoryfor the specifiedHttpServletRequest. If one is not found, a defaultHttpSessionSecurityContextRepositoryis used.- Parameters:
request- theHttpServletRequestto obtain theSecurityContextRepository- Returns:
- the
SecurityContextRepositoryfor the specifiedHttpServletRequest
-
setSecurityContextRepository
public static void setSecurityContextRepository(jakarta.servlet.http.HttpServletRequest request, SecurityContextRepository securityContextRepository) Sets theSecurityContextRepositoryfor the specifiedHttpServletRequest.- Parameters:
request- theHttpServletRequestto obtain theSecurityContextRepositorysecurityContextRepository- theSecurityContextRepositoryto set
-
getCsrfTokenRepository
public static CsrfTokenRepository getCsrfTokenRepository(jakarta.servlet.http.HttpServletRequest request) Gets theCsrfTokenRepositoryfor the specifiedHttpServletRequest. If one is not found, the defaultHttpSessionCsrfTokenRepositoryis used.- Parameters:
request- theHttpServletRequestto obtain theCsrfTokenRepository- Returns:
- the
CsrfTokenRepositoryfor the specifiedHttpServletRequest
-
getCsrfTokenRequestHandler
public static CsrfTokenRequestHandler getCsrfTokenRequestHandler(jakarta.servlet.http.HttpServletRequest request) Gets theCsrfTokenRequestHandlerfor the specifiedHttpServletRequest. If one is not found, the defaultXorCsrfTokenRequestAttributeHandleris used.- Parameters:
request- theHttpServletRequestto obtain theCsrfTokenRequestHandler- Returns:
- the
CsrfTokenRequestHandlerfor the specifiedHttpServletRequest
-
setCsrfTokenRepository
public static void setCsrfTokenRepository(jakarta.servlet.http.HttpServletRequest request, CsrfTokenRepository repository) Sets theCsrfTokenRepositoryfor the specifiedHttpServletRequest.- Parameters:
request- theHttpServletRequestto obtain theCsrfTokenRepositoryrepository- theCsrfTokenRepositoryto set
-