Skip to content

Commit 31bae54

Browse files
committed
Removed Unused Files
Saml2Utils and Saml2ServletUtils are no longer used Issue gh-8768
1 parent 1361cb8 commit 31bae54

File tree

4 files changed

+30
-224
lines changed

4 files changed

+30
-224
lines changed

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/servlet/filter/Saml2ServletUtils.java

-81
This file was deleted.

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/servlet/filter/Saml2Utils.java

-73
This file was deleted.

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/servlet/filter/Saml2UtilsTests.java

-70
This file was deleted.

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/web/Saml2AuthenticationTokenConverterTests.java

+30
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package org.springframework.security.saml2.provider.service.web;
1818

19+
import java.io.IOException;
20+
import java.nio.charset.StandardCharsets;
1921
import javax.servlet.http.HttpServletRequest;
2022

2123
import org.junit.Test;
@@ -24,10 +26,13 @@
2426
import org.mockito.junit.MockitoJUnitRunner;
2527

2628
import org.springframework.core.convert.converter.Converter;
29+
import org.springframework.core.io.ClassPathResource;
2730
import org.springframework.mock.web.MockHttpServletRequest;
2831
import org.springframework.security.saml2.core.Saml2Utils;
2932
import org.springframework.security.saml2.provider.service.authentication.Saml2AuthenticationToken;
3033
import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration;
34+
import org.springframework.util.StreamUtils;
35+
import org.springframework.web.util.UriUtils;
3136

3237
import static java.nio.charset.StandardCharsets.UTF_8;
3338
import static org.assertj.core.api.Assertions.assertThat;
@@ -99,4 +104,29 @@ public void constructorWhenResolverIsNullThenIllegalArgument() {
99104
assertThatCode(() -> new Saml2AuthenticationTokenConverter(null))
100105
.isInstanceOf(IllegalArgumentException.class);
101106
}
107+
108+
@Test
109+
public void convertWhenUsingSamlUtilsBase64ThenXmlIsValid() throws Exception {
110+
Saml2AuthenticationTokenConverter converter = new Saml2AuthenticationTokenConverter
111+
(this.relyingPartyRegistrationResolver);
112+
when(this.relyingPartyRegistrationResolver.convert(any(HttpServletRequest.class)))
113+
.thenReturn(this.relyingPartyRegistration);
114+
MockHttpServletRequest request = new MockHttpServletRequest();
115+
request.setParameter("SAMLResponse", getSsoCircleEncodedXml());
116+
Saml2AuthenticationToken token = converter.convert(request);
117+
validateSsoCircleXml(token.getSaml2Response());
118+
}
119+
120+
private void validateSsoCircleXml(String xml) {
121+
assertThat(xml)
122+
.contains("InResponseTo=\"ARQ9a73ead-7dcf-45a8-89eb-26f3c9900c36\"")
123+
.contains(" ID=\"s246d157446618e90e43fb79bdd4d9e9e19cf2c7c4\"")
124+
.contains("<saml:Issuer>https://idp.ssocircle.com</saml:Issuer>");
125+
}
126+
127+
private String getSsoCircleEncodedXml() throws IOException {
128+
ClassPathResource resource = new ClassPathResource("saml2-response-sso-circle.encoded");
129+
String response = StreamUtils.copyToString(resource.getInputStream(), StandardCharsets.UTF_8);
130+
return UriUtils.decode(response, UTF_8);
131+
}
102132
}

0 commit comments

Comments
 (0)