Initialize OpenSAML in OpenSamlAssertingPartyMetadataRepository
Closes gh-16042 This commit adds a static initializer block to both OpenSaml4AssertingPartyMetadataRepository and OpenSaml5AssertingPartyMetadataRepository. This ensures OpenSAML is initialized upon class loading, preventing failures when methods like withMetadataLocation are invoked without prior initialization.
This commit is contained in:
parent
5a95952c95
commit
7b51eab9fe
|
@ -50,6 +50,7 @@ import org.springframework.core.io.ResourceLoader;
|
||||||
import org.springframework.lang.NonNull;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.security.saml2.Saml2Exception;
|
import org.springframework.security.saml2.Saml2Exception;
|
||||||
|
import org.springframework.security.saml2.core.OpenSamlInitializationService;
|
||||||
import org.springframework.security.saml2.provider.service.registration.BaseOpenSamlAssertingPartyMetadataRepository.MetadataResolverAdapter;
|
import org.springframework.security.saml2.provider.service.registration.BaseOpenSamlAssertingPartyMetadataRepository.MetadataResolverAdapter;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
@ -68,6 +69,10 @@ import org.springframework.util.Assert;
|
||||||
*/
|
*/
|
||||||
public final class OpenSaml4AssertingPartyMetadataRepository implements AssertingPartyMetadataRepository {
|
public final class OpenSaml4AssertingPartyMetadataRepository implements AssertingPartyMetadataRepository {
|
||||||
|
|
||||||
|
static {
|
||||||
|
OpenSamlInitializationService.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
private final BaseOpenSamlAssertingPartyMetadataRepository delegate;
|
private final BaseOpenSamlAssertingPartyMetadataRepository delegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -53,7 +53,6 @@ import org.w3c.dom.Element;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.core.io.ResourceLoader;
|
import org.springframework.core.io.ResourceLoader;
|
||||||
import org.springframework.security.saml2.Saml2Exception;
|
import org.springframework.security.saml2.Saml2Exception;
|
||||||
import org.springframework.security.saml2.core.OpenSamlInitializationService;
|
|
||||||
import org.springframework.security.saml2.core.TestSaml2X509Credentials;
|
import org.springframework.security.saml2.core.TestSaml2X509Credentials;
|
||||||
import org.springframework.security.saml2.provider.service.authentication.TestOpenSamlObjects;
|
import org.springframework.security.saml2.provider.service.authentication.TestOpenSamlObjects;
|
||||||
|
|
||||||
|
@ -71,10 +70,6 @@ import static org.mockito.Mockito.withSettings;
|
||||||
*/
|
*/
|
||||||
public class OpenSaml4AssertingPartyMetadataRepositoryTests {
|
public class OpenSaml4AssertingPartyMetadataRepositoryTests {
|
||||||
|
|
||||||
static {
|
|
||||||
OpenSamlInitializationService.initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MetadataDispatcher dispatcher = new MetadataDispatcher()
|
private static MetadataDispatcher dispatcher = new MetadataDispatcher()
|
||||||
.addResponse("/entity.xml", readFile("test-metadata.xml"))
|
.addResponse("/entity.xml", readFile("test-metadata.xml"))
|
||||||
.addResponse("/entities.xml", readFile("test-entitiesdescriptor.xml"));
|
.addResponse("/entities.xml", readFile("test-entitiesdescriptor.xml"));
|
||||||
|
|
|
@ -50,6 +50,7 @@ import org.springframework.core.io.ResourceLoader;
|
||||||
import org.springframework.lang.NonNull;
|
import org.springframework.lang.NonNull;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.security.saml2.Saml2Exception;
|
import org.springframework.security.saml2.Saml2Exception;
|
||||||
|
import org.springframework.security.saml2.core.OpenSamlInitializationService;
|
||||||
import org.springframework.security.saml2.provider.service.registration.BaseOpenSamlAssertingPartyMetadataRepository.MetadataResolverAdapter;
|
import org.springframework.security.saml2.provider.service.registration.BaseOpenSamlAssertingPartyMetadataRepository.MetadataResolverAdapter;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
@ -68,6 +69,10 @@ import org.springframework.util.Assert;
|
||||||
*/
|
*/
|
||||||
public final class OpenSaml5AssertingPartyMetadataRepository implements AssertingPartyMetadataRepository {
|
public final class OpenSaml5AssertingPartyMetadataRepository implements AssertingPartyMetadataRepository {
|
||||||
|
|
||||||
|
static {
|
||||||
|
OpenSamlInitializationService.initialize();
|
||||||
|
}
|
||||||
|
|
||||||
private final BaseOpenSamlAssertingPartyMetadataRepository delegate;
|
private final BaseOpenSamlAssertingPartyMetadataRepository delegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -53,7 +53,6 @@ import org.w3c.dom.Element;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.core.io.ResourceLoader;
|
import org.springframework.core.io.ResourceLoader;
|
||||||
import org.springframework.security.saml2.Saml2Exception;
|
import org.springframework.security.saml2.Saml2Exception;
|
||||||
import org.springframework.security.saml2.core.OpenSamlInitializationService;
|
|
||||||
import org.springframework.security.saml2.core.TestSaml2X509Credentials;
|
import org.springframework.security.saml2.core.TestSaml2X509Credentials;
|
||||||
import org.springframework.security.saml2.provider.service.authentication.TestOpenSamlObjects;
|
import org.springframework.security.saml2.provider.service.authentication.TestOpenSamlObjects;
|
||||||
|
|
||||||
|
@ -71,10 +70,6 @@ import static org.mockito.Mockito.withSettings;
|
||||||
*/
|
*/
|
||||||
public class OpenSaml5AssertingPartyMetadataRepositoryTests {
|
public class OpenSaml5AssertingPartyMetadataRepositoryTests {
|
||||||
|
|
||||||
static {
|
|
||||||
OpenSamlInitializationService.initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static MetadataDispatcher dispatcher = new MetadataDispatcher()
|
private static MetadataDispatcher dispatcher = new MetadataDispatcher()
|
||||||
.addResponse("/entity.xml", readFile("test-metadata.xml"))
|
.addResponse("/entity.xml", readFile("test-metadata.xml"))
|
||||||
.addResponse("/entities.xml", readFile("test-entitiesdescriptor.xml"));
|
.addResponse("/entities.xml", readFile("test-entitiesdescriptor.xml"));
|
||||||
|
|
Loading…
Reference in New Issue