From 59ac22b04515590fef289f62002131dee40d1bf9 Mon Sep 17 00:00:00 2001 From: Deep Dhamala Date: Mon, 7 Jul 2025 08:23:26 +0545 Subject: [PATCH] Fix Error message for unsupported Spring Security XSD versions Closes gh-17153 Signed-off-by: Deep Dhamala --- .../security/config/SecurityNamespaceHandler.java | 6 ++---- .../security/config/SecurityNamespaceHandlerTests.java | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java index 7f39e23b6db..4a0129b6436 100644 --- a/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java +++ b/config/src/main/java/org/springframework/security/config/SecurityNamespaceHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2024 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -94,9 +94,7 @@ public SecurityNamespaceHandler() { public BeanDefinition parse(Element element, ParserContext pc) { if (!namespaceMatchesVersion(element)) { pc.getReaderContext() - .fatal("You cannot use a spring-security-2.0.xsd or spring-security-3.0.xsd or " - + "spring-security-3.1.xsd schema or spring-security-3.2.xsd schema or spring-security-4.0.xsd schema " - + "with Spring Security 7.0. Please update your schema declarations to the 7.0 schema.", + .fatal("You cannot use any XSD older than spring-security-7.0.xsd. Either change to spring-security.xsd or spring-security-7.0.xsd", element); } String name = pc.getDelegate().getLocalName(element); diff --git a/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java b/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java index 501a5c5775c..6534f477110 100644 --- a/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java +++ b/config/src/test/java/org/springframework/security/config/SecurityNamespaceHandlerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2025 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,8 @@ public void pre32SchemaAreNotSupported() { .isThrownBy(() -> new InMemoryXmlApplicationContext( "", "3.0.3", null)) - .withMessageContaining("You cannot use a spring-security-2.0.xsd"); + .withMessageContaining( + "You cannot use any XSD older than spring-security-7.0.xsd. Either change to spring-security.xsd or spring-security-7.0.xsd"); } // SEC-1868