Apply formatting
This commit is contained in:
@@ -77,8 +77,9 @@ public class CustomUrlsApplicationITests {
|
||||
|
||||
@Test
|
||||
void metadataWhenGetThenForwardToUrl() throws Exception {
|
||||
this.mvc.perform(get("/saml/metadata")).andExpect(status().isOk())
|
||||
.andExpect(forwardedUrl("/saml2/service-provider-metadata/one"));
|
||||
this.mvc.perform(get("/saml/metadata"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(forwardedUrl("/saml2/service-provider-metadata/one"));
|
||||
}
|
||||
|
||||
private void performLogin() throws Exception {
|
||||
|
||||
@@ -82,9 +82,11 @@ public class SecurityConfiguration {
|
||||
@Value("classpath:credentials/rp-private.key") RSAPrivateKey privateKey) {
|
||||
Saml2X509Credential signing = Saml2X509Credential.signing(privateKey, relyingPartyCertificate());
|
||||
RelyingPartyRegistration two = RelyingPartyRegistrations
|
||||
.fromMetadataLocation("https://dev-05937739.okta.com/app/exk4842vmapcMkohr5d7/sso/saml/metadata")
|
||||
.registrationId("two").signingX509Credentials((c) -> c.add(signing))
|
||||
.singleLogoutServiceLocation("http://localhost:8080/logout/saml2/slo").build();
|
||||
.fromMetadataLocation("https://dev-05937739.okta.com/app/exk4842vmapcMkohr5d7/sso/saml/metadata")
|
||||
.registrationId("two")
|
||||
.signingX509Credentials((c) -> c.add(signing))
|
||||
.singleLogoutServiceLocation("http://localhost:8080/logout/saml2/slo")
|
||||
.build();
|
||||
return new InMemoryRelyingPartyRegistrationRepository(two);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,17 +61,22 @@ public class RefreshableRelyingPartyRegistrationRepository
|
||||
@Scheduled(fixedDelay = 30, timeUnit = TimeUnit.MINUTES)
|
||||
public void refreshMetadata() {
|
||||
for (Map.Entry<String, Saml2RelyingPartyProperties.Registration> byRegistrationId : this.relyingPartyProperties
|
||||
.getRegistration().entrySet()) {
|
||||
.getRegistration()
|
||||
.entrySet()) {
|
||||
fetchMetadata(byRegistrationId.getKey(), byRegistrationId.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void fetchMetadata(String registrationId, Saml2RelyingPartyProperties.Registration registration) {
|
||||
RelyingPartyRegistration relyingPartyRegistration = RelyingPartyRegistrations
|
||||
.fromMetadataLocation(registration.getAssertingparty().getMetadataUri())
|
||||
.signingX509Credentials((credentials) -> registration.getSigning().getCredentials().stream()
|
||||
.map(this::asSigningCredential).forEach(credentials::add))
|
||||
.registrationId(registrationId).build();
|
||||
.fromMetadataLocation(registration.getAssertingparty().getMetadataUri())
|
||||
.signingX509Credentials((credentials) -> registration.getSigning()
|
||||
.getCredentials()
|
||||
.stream()
|
||||
.map(this::asSigningCredential)
|
||||
.forEach(credentials::add))
|
||||
.registrationId(registrationId)
|
||||
.build();
|
||||
this.relyingPartyRegistrations.put(relyingPartyRegistration.getRegistrationId(), relyingPartyRegistration);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,9 @@ public class SamlExtensionFederationApplicationITests {
|
||||
|
||||
@Test
|
||||
void metadataWhenGetThenForwardToUrl() throws Exception {
|
||||
this.mvc.perform(get("/saml/metadata")).andExpect(status().isOk())
|
||||
.andExpect(forwardedUrl("/saml2/service-provider-metadata/one"));
|
||||
this.mvc.perform(get("/saml/metadata"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(forwardedUrl("/saml2/service-provider-metadata/one"));
|
||||
}
|
||||
|
||||
private void performLogin() throws Exception {
|
||||
|
||||
@@ -66,14 +66,16 @@ public class SecurityConfiguration {
|
||||
Saml2X509Credential signing = Saml2X509Credential.signing(key, x509Certificate(cert));
|
||||
Registration registration = properties.getRegistration().values().iterator().next();
|
||||
return new InMemoryRelyingPartyRegistrationRepository(RelyingPartyRegistrations
|
||||
.collectionFromMetadataLocation(registration.getAssertingparty().getMetadataUri()).stream()
|
||||
.map((builder) -> builder.registrationId(UUID.randomUUID().toString())
|
||||
.entityId(registration.getEntityId())
|
||||
.assertionConsumerServiceLocation(registration.getAcs().getLocation())
|
||||
.singleLogoutServiceLocation(registration.getSinglelogout().getUrl())
|
||||
.singleLogoutServiceResponseLocation(registration.getSinglelogout().getResponseUrl())
|
||||
.signingX509Credentials((credentials) -> credentials.add(signing)).build())
|
||||
.collect(Collectors.toList()));
|
||||
.collectionFromMetadataLocation(registration.getAssertingparty().getMetadataUri())
|
||||
.stream()
|
||||
.map((builder) -> builder.registrationId(UUID.randomUUID().toString())
|
||||
.entityId(registration.getEntityId())
|
||||
.assertionConsumerServiceLocation(registration.getAcs().getLocation())
|
||||
.singleLogoutServiceLocation(registration.getSinglelogout().getUrl())
|
||||
.singleLogoutServiceResponseLocation(registration.getSinglelogout().getResponseUrl())
|
||||
.signingX509Credentials((credentials) -> credentials.add(signing))
|
||||
.build())
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
X509Certificate x509Certificate(File location) {
|
||||
|
||||
Reference in New Issue
Block a user