From 191365ee796e64d6bae8483c89daa1bfd00c3ec6 Mon Sep 17 00:00:00 2001 From: dan-s1 Date: Tue, 4 Feb 2025 00:57:30 +0000 Subject: [PATCH] NIFI-14227 Replaced the deprecated methods in RelyingPartyRegistration with suggested replacements --- ...elyingPartyRegistrationRepositoryTest.java | 19 ++++++++++--------- ...dRelyingPartyRegistrationResolverTest.java | 6 +++--- ...l2AuthenticationRequestRepositoryTest.java | 6 +++--- ...ndardSaml2LogoutRequestRepositoryTest.java | 6 +++--- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/registration/StandardRelyingPartyRegistrationRepositoryTest.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/registration/StandardRelyingPartyRegistrationRepositoryTest.java index 632077922058..ae6a30a8ffe2 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/registration/StandardRelyingPartyRegistrationRepositoryTest.java +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/registration/StandardRelyingPartyRegistrationRepositoryTest.java @@ -24,6 +24,7 @@ import org.junit.jupiter.api.Test; import org.opensaml.xmlsec.signature.support.SignatureConstants; import org.springframework.security.saml2.core.Saml2X509Credential; +import org.springframework.security.saml2.provider.service.registration.AssertingPartyMetadata; import org.springframework.security.saml2.provider.service.registration.RelyingPartyRegistration; import javax.net.ssl.X509ExtendedKeyManager; @@ -67,9 +68,9 @@ void testFindByRegistrationId() { assertNull(registration.getSingleLogoutServiceLocation()); assertNull(registration.getSingleLogoutServiceResponseLocation()); - final RelyingPartyRegistration.AssertingPartyDetails assertingPartyDetails = registration.getAssertingPartyDetails(); - assertFalse(assertingPartyDetails.getWantAuthnRequestsSigned()); - assertTrue(assertingPartyDetails.getSigningAlgorithms().contains(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256)); + final AssertingPartyMetadata assertingPartyMetadata = registration.getAssertingPartyMetadata(); + assertFalse(assertingPartyMetadata.getWantAuthnRequestsSigned()); + assertTrue(assertingPartyMetadata.getSigningAlgorithms().contains(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256)); final Collection signingCredentials = registration.getSigningX509Credentials(); assertTrue(signingCredentials.isEmpty()); @@ -96,12 +97,12 @@ void testFindByRegistrationIdSingleLogoutEnabled() throws Exception { assertEquals(StandardRelyingPartyRegistrationRepository.SINGLE_LOGOUT_RESPONSE_SERVICE_LOCATION, registration.getSingleLogoutServiceLocation()); assertEquals(StandardRelyingPartyRegistrationRepository.SINGLE_LOGOUT_RESPONSE_SERVICE_LOCATION, registration.getSingleLogoutServiceResponseLocation()); - final RelyingPartyRegistration.AssertingPartyDetails assertingPartyDetails = registration.getAssertingPartyDetails(); - assertFalse(assertingPartyDetails.getWantAuthnRequestsSigned()); - assertTrue(assertingPartyDetails.getSigningAlgorithms().contains(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA512)); + final AssertingPartyMetadata assertingPartyMetadata = registration.getAssertingPartyMetadata(); + assertFalse(assertingPartyMetadata.getWantAuthnRequestsSigned()); + assertTrue(assertingPartyMetadata.getSigningAlgorithms().contains(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA512)); assertSigningCredentialsFound(registration); - assertEncryptionCredentialsFound(assertingPartyDetails); + assertEncryptionCredentialsFound(assertingPartyMetadata); } private void assertSigningCredentialsFound(final RelyingPartyRegistration registration) { @@ -113,8 +114,8 @@ private void assertSigningCredentialsFound(final RelyingPartyRegistration regist assertEquals(CERTIFICATE_PRINCIPAL, certificate.getIssuerX500Principal()); } - private void assertEncryptionCredentialsFound(final RelyingPartyRegistration.AssertingPartyDetails assertingPartyDetails) { - final Collection encryptionCredentials = assertingPartyDetails.getEncryptionX509Credentials(); + private void assertEncryptionCredentialsFound(final AssertingPartyMetadata assertingPartyMetadata) { + final Collection encryptionCredentials = assertingPartyMetadata.getEncryptionX509Credentials(); assertFalse(encryptionCredentials.isEmpty()); final Optional certificateCredential = encryptionCredentials.stream().filter( credential -> CERTIFICATE_PRINCIPAL.equals(credential.getCertificate().getSubjectX500Principal()) diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/service/web/StandardRelyingPartyRegistrationResolverTest.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/service/web/StandardRelyingPartyRegistrationResolverTest.java index 989552505ad3..d93dcccf7f71 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/service/web/StandardRelyingPartyRegistrationResolverTest.java +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/service/web/StandardRelyingPartyRegistrationResolverTest.java @@ -114,9 +114,9 @@ private RelyingPartyRegistration.Builder getRegistrationBuilder() { return RelyingPartyRegistration.withRegistrationId(REGISTRATION_ID) .entityId(REGISTRATION_ID) .assertionConsumerServiceLocation(SERVICE_LOCATION) - .assertingPartyDetails(assertingPartyDetails -> { - assertingPartyDetails.entityId(REGISTRATION_ID); - assertingPartyDetails.singleSignOnServiceLocation(SERVICE_LOCATION); + .assertingPartyMetadata(assertingPartyMetadata -> { + assertingPartyMetadata.entityId(REGISTRATION_ID); + assertingPartyMetadata.singleSignOnServiceLocation(SERVICE_LOCATION); }); } diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/service/web/StandardSaml2AuthenticationRequestRepositoryTest.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/service/web/StandardSaml2AuthenticationRequestRepositoryTest.java index 94ced3368084..264682de82ce 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/service/web/StandardSaml2AuthenticationRequestRepositoryTest.java +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/service/web/StandardSaml2AuthenticationRequestRepositoryTest.java @@ -128,9 +128,9 @@ void testRemoveAuthenticationRequestFound() { private AbstractSaml2AuthenticationRequest getRequest() { final RelyingPartyRegistration registration = RelyingPartyRegistration.withRegistrationId(Saml2RegistrationProperty.REGISTRATION_ID.getProperty()) .entityId(Saml2RegistrationProperty.REGISTRATION_ID.getProperty()) - .assertingPartyDetails(assertingPartyDetails -> { - assertingPartyDetails.entityId(Saml2RegistrationProperty.REGISTRATION_ID.getProperty()); - assertingPartyDetails.singleSignOnServiceLocation(LOCATION); + .assertingPartyMetadata(assertingPartyMetadata -> { + assertingPartyMetadata.entityId(Saml2RegistrationProperty.REGISTRATION_ID.getProperty()); + assertingPartyMetadata.singleSignOnServiceLocation(LOCATION); }) .build(); return Saml2PostAuthenticationRequest.withRelyingPartyRegistration(registration).samlRequest(SAML_REQUEST).build(); diff --git a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/web/authentication/logout/StandardSaml2LogoutRequestRepositoryTest.java b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/web/authentication/logout/StandardSaml2LogoutRequestRepositoryTest.java index 7e1caab0faca..0a2501c27165 100644 --- a/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/web/authentication/logout/StandardSaml2LogoutRequestRepositoryTest.java +++ b/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-security/src/test/java/org/apache/nifi/web/security/saml2/web/authentication/logout/StandardSaml2LogoutRequestRepositoryTest.java @@ -128,9 +128,9 @@ void testRemoveLogoutRequestFound() { private Saml2LogoutRequest getRequest() { final RelyingPartyRegistration registration = RelyingPartyRegistration.withRegistrationId(Saml2RegistrationProperty.REGISTRATION_ID.getProperty()) .entityId(Saml2RegistrationProperty.REGISTRATION_ID.getProperty()) - .assertingPartyDetails(assertingPartyDetails -> { - assertingPartyDetails.entityId(Saml2RegistrationProperty.REGISTRATION_ID.getProperty()); - assertingPartyDetails.singleSignOnServiceLocation(LOCATION); + .assertingPartyMetadata(assertingPartyMetadata -> { + assertingPartyMetadata.entityId(Saml2RegistrationProperty.REGISTRATION_ID.getProperty()); + assertingPartyMetadata.singleSignOnServiceLocation(LOCATION); }) .build(); return Saml2LogoutRequest.withRelyingPartyRegistration(registration).samlRequest(SAML_REQUEST).relayState(RELAY_STATE).build();