Skip to content

Commit 54a4792

Browse files
committed
Remove Unneeded OpenSAML 4 References
This will reduce the number of components that need to be duplicated between the OpenSAML 4 and 5 support Issue gh-11658
1 parent ab842b7 commit 54a4792

File tree

5 files changed

+7
-23
lines changed

5 files changed

+7
-23
lines changed

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/registration/RelyingPartyRegistration.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import java.util.List;
2525
import java.util.function.Consumer;
2626

27-
import org.opensaml.xmlsec.signature.support.SignatureConstants;
28-
2927
import org.springframework.security.saml2.core.Saml2X509Credential;
3028
import org.springframework.util.Assert;
3129
import org.springframework.util.CollectionUtils;
@@ -838,7 +836,7 @@ public Builder singleLogoutServiceBinding(Saml2MessageBinding singleLogoutServic
838836
*/
839837
public AssertingPartyDetails build() {
840838
List<String> signingAlgorithms = this.signingAlgorithms.isEmpty()
841-
? Collections.singletonList(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256)
839+
? Collections.singletonList("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256")
842840
: Collections.unmodifiableList(this.signingAlgorithms);
843841

844842
return new AssertingPartyDetails(this.entityId, this.wantAuthnRequestsSigned, signingAlgorithms,

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/core/OpenSamlInitializationServiceTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.junit.jupiter.api.Test;
2020
import org.opensaml.core.config.ConfigurationService;
2121
import org.opensaml.core.xml.config.XMLObjectProviderRegistry;
22+
import org.opensaml.saml.saml2.core.AuthnRequest;
2223

2324
import org.springframework.security.saml2.Saml2Exception;
2425

@@ -36,7 +37,7 @@ public class OpenSamlInitializationServiceTests {
3637
public void initializeWhenInvokedMultipleTimesThenInitializesOnce() {
3738
OpenSamlInitializationService.initialize();
3839
XMLObjectProviderRegistry registry = ConfigurationService.get(XMLObjectProviderRegistry.class);
39-
assertThat(registry.getParserPool()).isNotNull();
40+
assertThat(registry.getBuilderFactory().getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME)).isNotNull();
4041
assertThatExceptionOfType(Saml2Exception.class)
4142
.isThrownBy(() -> OpenSamlInitializationService.requireInitialize((r) -> {
4243
}))

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/core/TestSaml2X509Credentials.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818

1919
import java.io.ByteArrayInputStream;
2020
import java.nio.charset.StandardCharsets;
21-
import java.security.KeyException;
2221
import java.security.PrivateKey;
2322
import java.security.cert.CertificateException;
2423
import java.security.cert.CertificateFactory;
2524
import java.security.cert.X509Certificate;
2625

27-
import org.opensaml.security.crypto.KeySupport;
28-
26+
import org.springframework.security.converter.RsaKeyConverters;
2927
import org.springframework.security.saml2.Saml2Exception;
3028
import org.springframework.security.saml2.core.Saml2X509Credential.Saml2X509CredentialType;
3129

@@ -84,12 +82,7 @@ private static X509Certificate certificate(String cert) {
8482
}
8583

8684
private static PrivateKey privateKey(String key) {
87-
try {
88-
return KeySupport.decodePrivateKey(key.getBytes(StandardCharsets.UTF_8), new char[0]);
89-
}
90-
catch (KeyException ex) {
91-
throw new Saml2Exception(ex);
92-
}
85+
return RsaKeyConverters.pkcs8().convert(new ByteArrayInputStream(key.getBytes(StandardCharsets.UTF_8)));
9386
}
9487

9588
private static X509Certificate idpCertificate() {

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/credentials/TestSaml2X509Credentials.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818

1919
import java.io.ByteArrayInputStream;
2020
import java.nio.charset.StandardCharsets;
21-
import java.security.KeyException;
2221
import java.security.PrivateKey;
2322
import java.security.cert.CertificateException;
2423
import java.security.cert.CertificateFactory;
2524
import java.security.cert.X509Certificate;
2625

27-
import org.opensaml.security.crypto.KeySupport;
28-
26+
import org.springframework.security.converter.RsaKeyConverters;
2927
import org.springframework.security.saml2.Saml2Exception;
3028
import org.springframework.security.saml2.core.Saml2X509Credential;
3129

@@ -74,12 +72,7 @@ private static X509Certificate certificate(String cert) {
7472
}
7573

7674
private static PrivateKey privateKey(String key) {
77-
try {
78-
return KeySupport.decodePrivateKey(key.getBytes(StandardCharsets.UTF_8), new char[0]);
79-
}
80-
catch (KeyException ex) {
81-
throw new Saml2Exception(ex);
82-
}
75+
return RsaKeyConverters.pkcs8().convert(new ByteArrayInputStream(key.getBytes(StandardCharsets.UTF_8)));
8376
}
8477

8578
private static X509Certificate idpCertificate() {

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/authentication/TestCustomOpenSamlObjects.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ public CustomSamlObjectUnmarshaller() {
198198
protected void processChildElement(@Nonnull XMLObject parentXMLObject, @Nonnull XMLObject childXMLObject)
199199
throws UnmarshallingException {
200200
final CustomOpenSamlObject customSamlObject = (CustomOpenSamlObject) parentXMLObject;
201-
super.processChildElement(customSamlObject, childXMLObject);
202201
customSamlObject.getUnknownXMLObjects().add(childXMLObject);
203202
}
204203

0 commit comments

Comments
 (0)