Search in sources :

Example 6 with OBRIRole

use of com.forgerock.openbanking.model.OBRIRole in project openbanking-aspsp by OpenBankingToolkit.

the class DynamicRegistrationApiControllerTest method failIfSsaIsNotSignedByTrustedParty_register.

@Test
public void failIfSsaIsNotSignedByTrustedParty_register() throws InvalidPsd2EidasCertificate, DynamicClientRegistrationException {
    Collection<OBRIRole> authorities = new ArrayList<>(List.of(OBRIRole.ROLE_ANONYMOUS, OBRIRole.UNREGISTERED_TPP, OBRIRole.ROLE_EIDAS));
    X509Authentication principal = testSpec.getPrincipal(authorities);
    given(this.tppRegistrationService.validateSsaAgainstIssuingDirectoryJwksUri(anyString(), anyString())).willThrow(new DynamicClientRegistrationException("Test throw", UNAPPROVED_SOFTWARE_STATEMENT));
    // when
    DynamicClientRegistrationException exception = catchThrowableOfType(() -> dynamicRegistrationApiController.register(registrationRequestJwtSerialised, principal), DynamicClientRegistrationException.class);
    assertThat(exception.getErrorType()).isEqualTo(UNAPPROVED_SOFTWARE_STATEMENT);
}
Also used : OBRIRole(com.forgerock.openbanking.model.OBRIRole) DynamicClientRegistrationException(com.forgerock.openbanking.common.error.exception.dynamicclientregistration.DynamicClientRegistrationException) X509Authentication(com.forgerock.spring.security.multiauth.model.authentication.X509Authentication) Test(org.junit.Test)

Example 7 with OBRIRole

use of com.forgerock.openbanking.model.OBRIRole in project openbanking-aspsp by OpenBankingToolkit.

the class ApiClientIdentityFactoryTest method returnsApiClientFRTransport_getApiClientIdentity.

@Test
public void returnsApiClientFRTransport_getApiClientIdentity() throws CertificateException, IOException, ApiClientException, InvalidPsd2EidasCertificate, OAuth2InvalidClientException {
    // given
    X509Certificate[] certificatesChain = TestHelperFunctions.getCertChainFromFile("src/test/resources/certificates/fr-transport.pem");
    Psd2CertInfo certInfo = new Psd2CertInfo(certificatesChain);
    String tppName = "TestTppName";
    Collection<OBRIRole> authorities = new ArrayList<>();
    authorities.add(OBRIRole.UNREGISTERED_TPP);
    PSD2Authentication authentication = new PSD2Authentication(tppName, authorities, certificatesChain, certInfo);
    ApiClientIdentityFactory identityFactory = new ApiClientIdentityFactory();
    // when
    ApiClientIdentity identity = identityFactory.getApiClientIdentity(authentication);
    // then
    assertThat(identity).isInstanceOf(ApiClientIdentityFRTransport.class);
}
Also used : OBRIRole(com.forgerock.openbanking.model.OBRIRole) ArrayList(java.util.ArrayList) PSD2Authentication(com.forgerock.spring.security.multiauth.model.authentication.PSD2Authentication) Psd2CertInfo(com.forgerock.cert.Psd2CertInfo) X509Certificate(java.security.cert.X509Certificate) Test(org.junit.Test)

Example 8 with OBRIRole

use of com.forgerock.openbanking.model.OBRIRole in project openbanking-aspsp by OpenBankingToolkit.

the class ApiClientIdentityFactoryTest method returnsApiClientOBWac_getApiClientIdentity.

@Test
public void returnsApiClientOBWac_getApiClientIdentity() throws CertificateException, IOException, ApiClientException, InvalidPsd2EidasCertificate, OAuth2InvalidClientException {
    // given
    X509Certificate[] certificatesChain = TestHelperFunctions.getCertChainFromFile("src/test/resources/certificates/OBWac.pem");
    Psd2CertInfo certInfo = new Psd2CertInfo(certificatesChain);
    String tppName = "TestTppName";
    Collection<OBRIRole> authorities = new ArrayList<>();
    authorities.add(OBRIRole.UNREGISTERED_TPP);
    PSD2Authentication authentication = new PSD2Authentication(tppName, authorities, certificatesChain, certInfo);
    ApiClientIdentityFactory identityFactory = new ApiClientIdentityFactory();
    // when
    ApiClientIdentity identity = identityFactory.getApiClientIdentity(authentication);
    // then
    assertThat(identity).isInstanceOf(ApiClientIdentityOBWac.class);
}
Also used : OBRIRole(com.forgerock.openbanking.model.OBRIRole) ArrayList(java.util.ArrayList) PSD2Authentication(com.forgerock.spring.security.multiauth.model.authentication.PSD2Authentication) Psd2CertInfo(com.forgerock.cert.Psd2CertInfo) X509Certificate(java.security.cert.X509Certificate) Test(org.junit.Test)

Aggregations

OBRIRole (com.forgerock.openbanking.model.OBRIRole)8 Test (org.junit.Test)8 X509Authentication (com.forgerock.spring.security.multiauth.model.authentication.X509Authentication)5 Psd2CertInfo (com.forgerock.cert.Psd2CertInfo)3 RegistrationRequest (com.forgerock.openbanking.common.services.onboarding.registrationrequest.RegistrationRequest)3 PSD2Authentication (com.forgerock.spring.security.multiauth.model.authentication.PSD2Authentication)3 X509Certificate (java.security.cert.X509Certificate)3 ArrayList (java.util.ArrayList)3 DynamicClientRegistrationException (com.forgerock.openbanking.common.error.exception.dynamicclientregistration.DynamicClientRegistrationException)2 ApiClientIdentity (com.forgerock.openbanking.common.services.onboarding.apiclient.ApiClientIdentity)2 Tpp (com.forgerock.openbanking.model.Tpp)2 OIDCRegistrationResponse (com.forgerock.openbanking.model.oidc.OIDCRegistrationResponse)2