Search in sources :

Example 1 with SamlRequestDto

use of uk.gov.ida.hub.samlengine.domain.SamlRequestDto in project verify-hub by alphagov.

the class IdpAuthnRequestGeneratorServiceTest method get_sendAuthnRequest_shouldReturnDtoWithSamlRequestAndPostLocation.

@Test
public void get_sendAuthnRequest_shouldReturnDtoWithSamlRequestAndPostLocation() {
    String idpEntityId = UUID.randomUUID().toString();
    IdaAuthnRequestFromHubDto dto = new IdaAuthnRequestFromHubDto("1", null, Optional.of(false), null, idpEntityId, false);
    String samlRequest = "samlRequest";
    URI ssoUri = UriBuilder.fromPath(UUID.randomUUID().toString()).build();
    when(idaAuthnRequestFromHubStringTransformer.apply(Matchers.<IdaAuthnRequestFromHub>any())).thenReturn(samlRequest);
    when(idpSingleSignOnServiceHelper.getSingleSignOn(idpEntityId)).thenReturn(ssoUri);
    when(idaAuthnRequestTranslator.getIdaAuthnRequestFromHub(dto, ssoUri, HUB_ENTITY_ID)).thenReturn(null);
    final SamlRequestDto output = idpAuthnRequestGeneratorService.generateSaml(dto);
    assertThat(output.getSamlRequest()).isEqualTo(samlRequest);
    assertThat(output.getSsoUri()).isEqualTo(ssoUri);
}
Also used : IdaAuthnRequestFromHubDto(uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto) SamlRequestDto(uk.gov.ida.hub.samlengine.domain.SamlRequestDto) URI(java.net.URI) Test(org.junit.Test)

Example 2 with SamlRequestDto

use of uk.gov.ida.hub.samlengine.domain.SamlRequestDto in project verify-hub by alphagov.

the class CountryAuthnRequestGeneratorService method generateSaml.

public SamlRequestDto generateSaml(IdaAuthnRequestFromHubDto idaAuthnRequestFromHubDto) {
    URI ssoUri = idaAuthnRequestFromHubDto.getoverriddenSsoUrl() != null ? idaAuthnRequestFromHubDto.getoverriddenSsoUrl() : countrySingleSignOnServiceHelper.getSingleSignOn(idaAuthnRequestFromHubDto.getIdpEntityId());
    EidasAuthnRequestFromHub eidasAuthnRequestFromHub = eidasAuthnRequestTranslator.getEidasAuthnRequestFromHub(idaAuthnRequestFromHubDto, ssoUri, hubEidasEntityId);
    String request = eidasRequestStringTransformer.apply(eidasAuthnRequestFromHub);
    return new SamlRequestDto(request, ssoUri);
}
Also used : EidasAuthnRequestFromHub(uk.gov.ida.saml.hub.domain.EidasAuthnRequestFromHub) SamlRequestDto(uk.gov.ida.hub.samlengine.domain.SamlRequestDto) URI(java.net.URI)

Example 3 with SamlRequestDto

use of uk.gov.ida.hub.samlengine.domain.SamlRequestDto in project verify-hub by alphagov.

the class IdpAuthnRequestGeneratorService method generateSaml.

public SamlRequestDto generateSaml(IdaAuthnRequestFromHubDto idaAuthnRequestFromHubDto) {
    URI ssoUri = idpSingleSignOnServiceHelper.getSingleSignOn(idaAuthnRequestFromHubDto.getIdpEntityId());
    IdaAuthnRequestFromHub idaAuthnRequestFromHub = idaAuthnRequestTranslator.getIdaAuthnRequestFromHub(idaAuthnRequestFromHubDto, ssoUri, hubEntityId);
    String request = idaRequestStringTransformer.apply(idaAuthnRequestFromHub);
    return new SamlRequestDto(request, ssoUri);
}
Also used : IdaAuthnRequestFromHub(uk.gov.ida.saml.hub.domain.IdaAuthnRequestFromHub) SamlRequestDto(uk.gov.ida.hub.samlengine.domain.SamlRequestDto) URI(java.net.URI)

Example 4 with SamlRequestDto

use of uk.gov.ida.hub.samlengine.domain.SamlRequestDto in project verify-hub by alphagov.

the class CountryAuthnRequestGeneratorServiceTest method generateSamlRequest.

@Test
public void generateSamlRequest() {
    // Given
    String theCountryEntityId = "theCountryEntityId";
    IdaAuthnRequestFromHubDto dto = new IdaAuthnRequestFromHubDto("1", null, Optional.of(false), null, theCountryEntityId, false);
    URI ssoUri = UriBuilder.fromPath("/the-sso-uri").build();
    String samlRequest = "samlRequest";
    when(eidasAuthnRequestFromHubStringTransformer.apply(any())).thenReturn(samlRequest);
    when(countrySingleSignOnServiceHelper.getSingleSignOn(theCountryEntityId)).thenReturn(ssoUri);
    when(eidasAuthnRequestTranslator.getEidasAuthnRequestFromHub(dto, ssoUri, HUB_ENTITY_ID)).thenReturn(null);
    // When
    final SamlRequestDto output = service.generateSaml(dto);
    // Then
    assertThat(output.getSamlRequest()).isEqualTo(samlRequest);
    assertThat(output.getSsoUri()).isEqualTo(ssoUri);
    verify(countrySingleSignOnServiceHelper).getSingleSignOn(theCountryEntityId);
    verify(eidasAuthnRequestFromHubStringTransformer).apply(any(EidasAuthnRequestFromHub.class));
    verifyNoMoreInteractions(countrySingleSignOnServiceHelper, eidasAuthnRequestFromHubStringTransformer);
}
Also used : EidasAuthnRequestFromHub(uk.gov.ida.saml.hub.domain.EidasAuthnRequestFromHub) IdaAuthnRequestFromHubDto(uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto) SamlRequestDto(uk.gov.ida.hub.samlengine.domain.SamlRequestDto) URI(java.net.URI) Test(org.junit.Test)

Example 5 with SamlRequestDto

use of uk.gov.ida.hub.samlengine.domain.SamlRequestDto in project verify-hub by alphagov.

the class CountryAuthnRequestGeneratorServiceTest method generateSamlRequestWithOverriddenSsoUri.

@Test
public void generateSamlRequestWithOverriddenSsoUri() {
    // Given
    String theCountryEntityId = "theCountryEntityId";
    URI overriddenSsoURI = URI.create("http://overridden.foo.bar");
    IdaAuthnRequestFromHubDto dto = new IdaAuthnRequestFromHubDto("1", null, Optional.of(false), null, theCountryEntityId, false, overriddenSsoURI);
    URI ssoUri = UriBuilder.fromPath("/the-sso-uri").build();
    String samlRequest = "samlRequest";
    when(eidasAuthnRequestFromHubStringTransformer.apply(any())).thenReturn(samlRequest);
    when(eidasAuthnRequestTranslator.getEidasAuthnRequestFromHub(dto, ssoUri, HUB_ENTITY_ID)).thenReturn(null);
    // When
    final SamlRequestDto output = service.generateSaml(dto);
    // Then
    assertThat(output.getSamlRequest()).isEqualTo(samlRequest);
    assertThat(output.getSsoUri()).isEqualTo(overriddenSsoURI);
    verifyNoMoreInteractions(countrySingleSignOnServiceHelper);
}
Also used : IdaAuthnRequestFromHubDto(uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto) SamlRequestDto(uk.gov.ida.hub.samlengine.domain.SamlRequestDto) URI(java.net.URI) Test(org.junit.Test)

Aggregations

URI (java.net.URI)7 SamlRequestDto (uk.gov.ida.hub.samlengine.domain.SamlRequestDto)7 Test (org.junit.Test)5 IdaAuthnRequestFromHubDto (uk.gov.ida.hub.samlengine.contracts.IdaAuthnRequestFromHubDto)4 Response (javax.ws.rs.core.Response)2 EidasAuthnRequestFromHub (uk.gov.ida.saml.hub.domain.EidasAuthnRequestFromHub)2 DateTime (org.joda.time.DateTime)1 IdaAuthnRequestFromHub (uk.gov.ida.saml.hub.domain.IdaAuthnRequestFromHub)1