|  | @@ -40,6 +40,8 @@ import java.util.stream.Collectors;
 | 
	
		
			
				|  |  |  import jakarta.servlet.ServletContext;
 | 
	
		
			
				|  |  |  import jakarta.servlet.http.HttpServletRequest;
 | 
	
		
			
				|  |  |  import jakarta.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  | +import org.jspecify.annotations.NullUnmarked;
 | 
	
		
			
				|  |  | +import org.jspecify.annotations.Nullable;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import org.springframework.core.convert.converter.Converter;
 | 
	
		
			
				|  |  |  import org.springframework.core.io.DefaultResourceLoader;
 | 
	
	
		
			
				|  | @@ -397,6 +399,7 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  	 * @return the {@link OidcLoginRequestPostProcessor} for additional customization
 | 
	
		
			
				|  |  |  	 * @since 5.3
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  | +	@NullUnmarked
 | 
	
		
			
				|  |  |  	public static OAuth2LoginRequestPostProcessor oauth2Login() {
 | 
	
		
			
				|  |  |  		OAuth2AccessToken accessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, "access-token", null,
 | 
	
		
			
				|  |  |  				null, Collections.singleton("read"));
 | 
	
	
		
			
				|  | @@ -425,6 +428,7 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  	 * @return the {@link OidcLoginRequestPostProcessor} for additional customization
 | 
	
		
			
				|  |  |  	 * @since 5.3
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  | +	@NullUnmarked
 | 
	
		
			
				|  |  |  	public static OidcLoginRequestPostProcessor oidcLogin() {
 | 
	
		
			
				|  |  |  		OAuth2AccessToken accessToken = new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, "access-token", null,
 | 
	
		
			
				|  |  |  				null, Collections.singleton("read"));
 | 
	
	
		
			
				|  | @@ -513,6 +517,7 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  		private CsrfRequestPostProcessor() {
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +		@NullUnmarked
 | 
	
		
			
				|  |  |  		@Override
 | 
	
		
			
				|  |  |  		public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
 | 
	
		
			
				|  |  |  			CsrfTokenRepository repository = WebTestUtils.getCsrfTokenRepository(request);
 | 
	
	
		
			
				|  | @@ -577,7 +582,7 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			@Override
 | 
	
		
			
				|  |  | -			public void saveToken(CsrfToken token, HttpServletRequest request, HttpServletResponse response) {
 | 
	
		
			
				|  |  | +			public void saveToken(@Nullable CsrfToken token, HttpServletRequest request, HttpServletResponse response) {
 | 
	
		
			
				|  |  |  				if (isEnabled(request)) {
 | 
	
		
			
				|  |  |  					request.setAttribute(TOKEN_ATTR_NAME, token);
 | 
	
		
			
				|  |  |  				}
 | 
	
	
		
			
				|  | @@ -587,7 +592,7 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			@Override
 | 
	
		
			
				|  |  | -			public CsrfToken loadToken(HttpServletRequest request) {
 | 
	
		
			
				|  |  | +			public @Nullable CsrfToken loadToken(HttpServletRequest request) {
 | 
	
		
			
				|  |  |  				if (isEnabled(request)) {
 | 
	
		
			
				|  |  |  					return (CsrfToken) request.getAttribute(TOKEN_ATTR_NAME);
 | 
	
		
			
				|  |  |  				}
 | 
	
	
		
			
				|  | @@ -697,8 +702,9 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  		 * @return the MD5 of the digest authentication response, encoded in hex
 | 
	
		
			
				|  |  |  		 * @throws IllegalArgumentException if the supplied qop value is unsupported.
 | 
	
		
			
				|  |  |  		 */
 | 
	
		
			
				|  |  | -		private static String generateDigest(String username, String realm, String password, String httpMethod,
 | 
	
		
			
				|  |  | -				String uri, String qop, String nonce, String nc, String cnonce) throws IllegalArgumentException {
 | 
	
		
			
				|  |  | +		private static String generateDigest(String username, String realm, String password,
 | 
	
		
			
				|  |  | +				@Nullable String httpMethod, @Nullable String uri, String qop, String nonce, String nc, String cnonce)
 | 
	
		
			
				|  |  | +				throws IllegalArgumentException {
 | 
	
		
			
				|  |  |  			String a1Md5 = encodePasswordInA1Format(username, realm, password);
 | 
	
		
			
				|  |  |  			String a2 = httpMethod + ":" + uri;
 | 
	
		
			
				|  |  |  			String a2Md5 = md5Hex(a2);
 | 
	
	
		
			
				|  | @@ -1129,6 +1135,7 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  			return this;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +		@NullUnmarked
 | 
	
		
			
				|  |  |  		@Override
 | 
	
		
			
				|  |  |  		public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
 | 
	
		
			
				|  |  |  			CsrfFilter.skipRequest(request);
 | 
	
	
		
			
				|  | @@ -1255,6 +1262,7 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  			return new OAuth2AccessToken(OAuth2AccessToken.TokenType.BEARER, "token", issuedAt, expiresAt);
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +		@NullUnmarked
 | 
	
		
			
				|  |  |  		private Instant getInstant(Map<String, Object> attributes, String name) {
 | 
	
		
			
				|  |  |  			Object value = attributes.get(name);
 | 
	
		
			
				|  |  |  			if (value == null) {
 | 
	
	
		
			
				|  | @@ -1407,13 +1415,14 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		private OAuth2AccessToken accessToken;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		private OidcIdToken idToken;
 | 
	
		
			
				|  |  | +		private @Nullable OidcIdToken idToken;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +		@SuppressWarnings("NullAway.Init")
 | 
	
		
			
				|  |  |  		private OidcUserInfo userInfo;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		private Supplier<OidcUser> oidcUser = this::defaultPrincipal;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		private Collection<GrantedAuthority> authorities;
 | 
	
		
			
				|  |  | +		private @Nullable Collection<GrantedAuthority> authorities;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		private OidcLoginRequestPostProcessor(OAuth2AccessToken accessToken) {
 | 
	
		
			
				|  |  |  			this.accessToken = accessToken;
 | 
	
	
		
			
				|  | @@ -1525,6 +1534,7 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  			return authorities;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +		@NullUnmarked
 | 
	
		
			
				|  |  |  		private OidcIdToken getOidcIdToken() {
 | 
	
		
			
				|  |  |  			if (this.idToken != null) {
 | 
	
		
			
				|  |  |  				return this.idToken;
 | 
	
	
		
			
				|  | @@ -1546,11 +1556,12 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  	 * @author Josh Cummings
 | 
	
		
			
				|  |  |  	 * @since 5.3
 | 
	
		
			
				|  |  |  	 */
 | 
	
		
			
				|  |  | +	@NullUnmarked
 | 
	
		
			
				|  |  |  	public static final class OAuth2ClientRequestPostProcessor implements RequestPostProcessor {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		private String registrationId = "test";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		private ClientRegistration clientRegistration;
 | 
	
		
			
				|  |  | +		private @Nullable ClientRegistration clientRegistration;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  		private String principalName = "user";
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1610,6 +1621,7 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  			return this;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +		@NullUnmarked
 | 
	
		
			
				|  |  |  		@Override
 | 
	
		
			
				|  |  |  		public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
 | 
	
		
			
				|  |  |  			if (this.clientRegistration == null) {
 | 
	
	
		
			
				|  | @@ -1650,14 +1662,15 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			private final OAuth2AuthorizedClientManager delegate;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -			private OAuth2AuthorizedClientRepository authorizedClientRepository;
 | 
	
		
			
				|  |  | +			private @Nullable OAuth2AuthorizedClientRepository authorizedClientRepository;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			TestOAuth2AuthorizedClientManager(OAuth2AuthorizedClientManager delegate) {
 | 
	
		
			
				|  |  |  				this.delegate = delegate;
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +			@NullUnmarked
 | 
	
		
			
				|  |  |  			@Override
 | 
	
		
			
				|  |  | -			public OAuth2AuthorizedClient authorize(OAuth2AuthorizeRequest authorizeRequest) {
 | 
	
		
			
				|  |  | +			public @Nullable OAuth2AuthorizedClient authorize(OAuth2AuthorizeRequest authorizeRequest) {
 | 
	
		
			
				|  |  |  				HttpServletRequest request = authorizeRequest.getAttribute(HttpServletRequest.class.getName());
 | 
	
		
			
				|  |  |  				if (isEnabled(request)) {
 | 
	
		
			
				|  |  |  					return this.authorizedClientRepository.loadAuthorizedClient(
 | 
	
	
		
			
				|  | @@ -1670,7 +1683,8 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  				request.setAttribute(ENABLED_ATTR_NAME, Boolean.TRUE);
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -			boolean isEnabled(HttpServletRequest request) {
 | 
	
		
			
				|  |  | +			@NullUnmarked
 | 
	
		
			
				|  |  | +			boolean isEnabled(@Nullable HttpServletRequest request) {
 | 
	
		
			
				|  |  |  				return Boolean.TRUE.equals(request.getAttribute(ENABLED_ATTR_NAME));
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1689,7 +1703,8 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			private final OAuth2AuthorizedClientRepository delegate;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -			TestOAuth2AuthorizedClientRepository(OAuth2AuthorizedClientRepository delegate) {
 | 
	
		
			
				|  |  | +			@NullUnmarked
 | 
	
		
			
				|  |  | +			TestOAuth2AuthorizedClientRepository(@Nullable OAuth2AuthorizedClientRepository delegate) {
 | 
	
		
			
				|  |  |  				this.delegate = delegate;
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1748,7 +1763,8 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  			 * @return the {@link OAuth2AuthorizedClientManager} for the specified
 | 
	
		
			
				|  |  |  			 * {@link HttpServletRequest}
 | 
	
		
			
				|  |  |  			 */
 | 
	
		
			
				|  |  | -			static OAuth2AuthorizedClientRepository getAuthorizedClientRepository(HttpServletRequest request) {
 | 
	
		
			
				|  |  | +			static @Nullable OAuth2AuthorizedClientRepository getAuthorizedClientRepository(
 | 
	
		
			
				|  |  | +					HttpServletRequest request) {
 | 
	
		
			
				|  |  |  				OAuth2AuthorizedClientManager manager = getOAuth2AuthorizedClientManager(request);
 | 
	
		
			
				|  |  |  				if (manager == null) {
 | 
	
		
			
				|  |  |  					return DEFAULT_CLIENT_REPO;
 | 
	
	
		
			
				|  | @@ -1781,7 +1797,8 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  				((TestOAuth2AuthorizedClientManager) manager).authorizedClientRepository = repository;
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -			static OAuth2AuthorizedClientManager getOAuth2AuthorizedClientManager(HttpServletRequest request) {
 | 
	
		
			
				|  |  | +			static @Nullable OAuth2AuthorizedClientManager getOAuth2AuthorizedClientManager(
 | 
	
		
			
				|  |  | +					HttpServletRequest request) {
 | 
	
		
			
				|  |  |  				OAuth2AuthorizedClientArgumentResolver resolver = findResolver(request,
 | 
	
		
			
				|  |  |  						OAuth2AuthorizedClientArgumentResolver.class);
 | 
	
		
			
				|  |  |  				if (resolver == null) {
 | 
	
	
		
			
				|  | @@ -1809,7 +1826,7 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			@SuppressWarnings("unchecked")
 | 
	
		
			
				|  |  | -			static <T extends HandlerMethodArgumentResolver> T findResolver(HttpServletRequest request,
 | 
	
		
			
				|  |  | +			static <T extends HandlerMethodArgumentResolver> @Nullable T findResolver(HttpServletRequest request,
 | 
	
		
			
				|  |  |  					Class<T> resolverClass) {
 | 
	
		
			
				|  |  |  				if (!ClassUtils.isPresent(
 | 
	
		
			
				|  |  |  						"org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter", null)) {
 | 
	
	
		
			
				|  | @@ -1820,7 +1837,7 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  			private static class WebMvcClasspathGuard {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -				static <T extends HandlerMethodArgumentResolver> T findResolver(HttpServletRequest request,
 | 
	
		
			
				|  |  | +				static <T extends HandlerMethodArgumentResolver> @Nullable T findResolver(HttpServletRequest request,
 | 
	
		
			
				|  |  |  						Class<T> resolverClass) {
 | 
	
		
			
				|  |  |  					ServletContext servletContext = request.getServletContext();
 | 
	
		
			
				|  |  |  					RequestMappingHandlerAdapter mapping = getRequestMappingHandlerAdapter(servletContext);
 | 
	
	
		
			
				|  | @@ -1839,7 +1856,7 @@ public final class SecurityMockMvcRequestPostProcessors {
 | 
	
		
			
				|  |  |  					return null;
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -				private static RequestMappingHandlerAdapter getRequestMappingHandlerAdapter(
 | 
	
		
			
				|  |  | +				private static @Nullable RequestMappingHandlerAdapter getRequestMappingHandlerAdapter(
 | 
	
		
			
				|  |  |  						ServletContext servletContext) {
 | 
	
		
			
				|  |  |  					WebApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
 | 
	
		
			
				|  |  |  					if (context != null) {
 |