Search in sources :

Example 6 with AuthnContext

use of uk.gov.ida.saml.core.domain.AuthnContext in project verify-hub by alphagov.

the class MatchingServiceResponseTranslatorServiceTest method populateReturnDtoCorrectly_handleNoMatchResponse.

@Test
public void populateReturnDtoCorrectly_handleNoMatchResponse() {
    final String inResponseTo = "inResponseTo";
    final String issuer = "issuer";
    final Optional<AuthnContext> authnContext = Optional.of(AuthnContext.LEVEL_2);
    final Optional<FraudDetectedDetails> fraudDetectedDetails = Optional.empty();
    final String underlyingAssertionBlob = "underlyingAssertionBlob";
    final MatchingServiceIdaStatus status = MatchingServiceIdaStatus.NoMatchingServiceMatchFromMatchingService;
    final SamlResponseDto samlResponse = new SamlResponseDto("saml");
    setUpForTranslate(authnContext, fraudDetectedDetails, underlyingAssertionBlob, inResponseTo, issuer, samlResponse.getSamlResponse(), status);
    final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = matchingServiceResponseTranslatorService.translate(samlResponse);
    assertThat(inboundResponseFromMatchingServiceDto.getInResponseTo()).isEqualTo(inResponseTo);
    assertThat(inboundResponseFromMatchingServiceDto.getUnderlyingMatchingServiceAssertionBlob().isPresent()).isTrue();
    assertThat(inboundResponseFromMatchingServiceDto.getUnderlyingMatchingServiceAssertionBlob().get()).isEqualTo(underlyingAssertionBlob);
    assertThat(inboundResponseFromMatchingServiceDto.getIssuer()).isEqualTo(issuer);
    assertThat(inboundResponseFromMatchingServiceDto.getLevelOfAssurance().isPresent()).isTrue();
    assertThat(inboundResponseFromMatchingServiceDto.getLevelOfAssurance().get().name()).isEqualTo(authnContext.get().name());
    assertThat(inboundResponseFromMatchingServiceDto.getStatus()).isEqualTo(status);
}
Also used : SamlResponseDto(uk.gov.ida.hub.samlengine.domain.SamlResponseDto) FraudDetectedDetails(uk.gov.ida.saml.core.domain.FraudDetectedDetails) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.samlengine.contracts.InboundResponseFromMatchingServiceDto) AuthnContext(uk.gov.ida.saml.core.domain.AuthnContext) MatchingServiceIdaStatus(uk.gov.ida.saml.hub.transformers.inbound.MatchingServiceIdaStatus) Test(org.junit.Test)

Example 7 with AuthnContext

use of uk.gov.ida.saml.core.domain.AuthnContext in project verify-hub by alphagov.

the class MatchingServiceResponseTranslatorServiceTest method populateReturnDtoCorrectly_handleUserAccountCreatedResponse.

@Test
public void populateReturnDtoCorrectly_handleUserAccountCreatedResponse() {
    final String inResponseTo = "inResponseTo";
    final String issuer = "issuer";
    final Optional<AuthnContext> authnContext = Optional.of(AuthnContext.LEVEL_2);
    final Optional<FraudDetectedDetails> fraudDetectedDetails = Optional.empty();
    final String underlyingAssertionBlob = "underlyingAssertionBlob";
    final MatchingServiceIdaStatus status = MatchingServiceIdaStatus.UserAccountCreated;
    final SamlResponseDto samlResponse = new SamlResponseDto("saml");
    setUpForTranslate(authnContext, fraudDetectedDetails, underlyingAssertionBlob, inResponseTo, issuer, samlResponse.getSamlResponse(), status);
    final InboundResponseFromMatchingServiceDto inboundResponseFromMatchingServiceDto = matchingServiceResponseTranslatorService.translate(samlResponse);
    assertThat(inboundResponseFromMatchingServiceDto.getInResponseTo()).isEqualTo(inResponseTo);
    assertThat(inboundResponseFromMatchingServiceDto.getUnderlyingMatchingServiceAssertionBlob().isPresent()).isTrue();
    assertThat(inboundResponseFromMatchingServiceDto.getUnderlyingMatchingServiceAssertionBlob().get()).isEqualTo(underlyingAssertionBlob);
    assertThat(inboundResponseFromMatchingServiceDto.getIssuer()).isEqualTo(issuer);
    assertThat(inboundResponseFromMatchingServiceDto.getLevelOfAssurance().isPresent()).isTrue();
    assertThat(inboundResponseFromMatchingServiceDto.getLevelOfAssurance().get().name()).isEqualTo(authnContext.get().name());
    assertThat(inboundResponseFromMatchingServiceDto.getStatus()).isEqualTo(status);
}
Also used : SamlResponseDto(uk.gov.ida.hub.samlengine.domain.SamlResponseDto) FraudDetectedDetails(uk.gov.ida.saml.core.domain.FraudDetectedDetails) InboundResponseFromMatchingServiceDto(uk.gov.ida.hub.samlengine.contracts.InboundResponseFromMatchingServiceDto) AuthnContext(uk.gov.ida.saml.core.domain.AuthnContext) MatchingServiceIdaStatus(uk.gov.ida.saml.hub.transformers.inbound.MatchingServiceIdaStatus) Test(org.junit.Test)

Example 8 with AuthnContext

use of uk.gov.ida.saml.core.domain.AuthnContext in project verify-hub by alphagov.

the class IdaAuthnRequestTranslator method getIdaAuthnRequestFromHub.

public IdaAuthnRequestFromHub getIdaAuthnRequestFromHub(IdaAuthnRequestFromHubDto idaAuthnRequestFromHubDto, URI ssoUri, String hubEntityId) {
    List<AuthnContext> levelsOfAssurance = idaAuthnRequestFromHubDto.getLevelsOfAssurance();
    AuthnContextComparisonTypeEnumeration comparisonType;
    if (idaAuthnRequestFromHubDto.getUseExactComparisonType()) {
        comparisonType = EXACT;
    } else {
        comparisonType = MINIMUM;
        if (levelsOfAssurance.size() == 1) {
            levelsOfAssurance = Arrays.asList(levelsOfAssurance.get(0), levelsOfAssurance.get(0));
        }
    }
    return createRequestToSendFromHub(idaAuthnRequestFromHubDto.getId(), levelsOfAssurance, idaAuthnRequestFromHubDto.getForceAuthentication(), idaAuthnRequestFromHubDto.getSessionExpiryTimestamp(), ssoUri, comparisonType, hubEntityId);
}
Also used : AuthnContextComparisonTypeEnumeration(org.opensaml.saml.saml2.core.AuthnContextComparisonTypeEnumeration) AuthnContext(uk.gov.ida.saml.core.domain.AuthnContext)

Aggregations

AuthnContext (uk.gov.ida.saml.core.domain.AuthnContext)8 Test (org.junit.Test)5 InboundResponseFromMatchingServiceDto (uk.gov.ida.hub.samlengine.contracts.InboundResponseFromMatchingServiceDto)5 SamlResponseDto (uk.gov.ida.hub.samlengine.domain.SamlResponseDto)4 FraudDetectedDetails (uk.gov.ida.saml.core.domain.FraudDetectedDetails)4 MatchingServiceIdaStatus (uk.gov.ida.saml.hub.transformers.inbound.MatchingServiceIdaStatus)4 Response (org.opensaml.saml.saml2.core.Response)2 LevelOfAssurance (uk.gov.ida.hub.samlengine.domain.LevelOfAssurance)2 Strings.isNullOrEmpty (com.google.common.base.Strings.isNullOrEmpty)1 List (java.util.List)1 Optional (java.util.Optional)1 Inject (javax.inject.Inject)1 Assertion (org.opensaml.saml.saml2.core.Assertion)1 AuthnContextComparisonTypeEnumeration (org.opensaml.saml.saml2.core.AuthnContextComparisonTypeEnumeration)1 NameID (org.opensaml.saml.saml2.core.NameID)1 Subject (org.opensaml.saml.saml2.core.Subject)1 IDPSSODescriptor (org.opensaml.saml.saml2.metadata.IDPSSODescriptor)1 SamlAuthnResponseTranslatorDto (uk.gov.ida.hub.samlengine.contracts.SamlAuthnResponseTranslatorDto)1 InboundResponseFromCountry (uk.gov.ida.hub.samlengine.domain.InboundResponseFromCountry)1 InboundResponseFromIdpDto (uk.gov.ida.hub.samlengine.domain.InboundResponseFromIdpDto)1