use of org.opensaml.saml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class IdaAuthnRequestFromHubToAuthnRequestTransformerTest method shouldCreateANameIdPolicyElementWithAFormatOfPersistentInTheTransformedRequest.
@Test
public void shouldCreateANameIdPolicyElementWithAFormatOfPersistentInTheTransformedRequest() {
AuthnRequest transformedRequest = transformer.apply(anIdaAuthnRequest().buildFromHub());
assertThat(transformedRequest.getNameIDPolicy().getFormat()).isEqualTo(NameIDType.PERSISTENT);
}
use of org.opensaml.saml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class IdaAuthnRequestFromHubToAuthnRequestTransformerTest method shouldMaintainTheAuthnContextsInPreferenceOrder.
@Test
public void shouldMaintainTheAuthnContextsInPreferenceOrder() {
IdaAuthnRequestFromHub originalRequestFromHub = anIdaAuthnRequest().withLevelsOfAssurance(Arrays.asList(AuthnContext.LEVEL_1, AuthnContext.LEVEL_2)).buildFromHub();
AuthnRequest transformedRequest = transformer.apply(originalRequestFromHub);
RequestedAuthnContext requestedAuthnContext = transformedRequest.getRequestedAuthnContext();
List<AuthnContextClassRef> authnContextClassRefs = requestedAuthnContext.getAuthnContextClassRefs();
List<String> authnContexts = authnContextClassRefs.stream().map(AuthnContextClassRef::getAuthnContextClassRef).collect(Collectors.toList());
assertThat(authnContexts).containsSequence(IdaAuthnContext.LEVEL_1_AUTHN_CTX, IdaAuthnContext.LEVEL_2_AUTHN_CTX);
}
use of org.opensaml.saml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class IdaAuthnRequestFromHubToAuthnRequestTransformerTest method shouldSetAllowCreateToTrue.
@Test
public void shouldSetAllowCreateToTrue() {
IdaAuthnRequestFromHub originalRequestFromHub = anIdaAuthnRequest().buildFromHub();
AuthnRequest transformedRequest = transformer.apply(originalRequestFromHub);
NameIDPolicy nameIDPolicy = transformedRequest.getNameIDPolicy();
assertThat(nameIDPolicy.getAllowCreate()).isEqualTo(true);
}
use of org.opensaml.saml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class IdaAuthnRequestFromHubToAuthnRequestTransformerTest method shouldCorrectlyMapLevelsOfAssurance.
@Test
public void shouldCorrectlyMapLevelsOfAssurance() {
List<AuthnContext> levelsOfAssurance = Arrays.asList(AuthnContext.LEVEL_1, AuthnContext.LEVEL_2);
List<String> expected = Arrays.asList(IdaAuthnContext.LEVEL_1_AUTHN_CTX, IdaAuthnContext.LEVEL_2_AUTHN_CTX);
IdaAuthnRequestFromHub originalRequestFromHub = anIdaAuthnRequest().withLevelsOfAssurance(levelsOfAssurance).buildFromHub();
AuthnRequest transformedRequest = transformer.apply(originalRequestFromHub);
RequestedAuthnContext requestedAuthnContext = transformedRequest.getRequestedAuthnContext();
List<String> actual = requestedAuthnContext.getAuthnContextClassRefs().stream().map(AuthnContextClassRef::getAuthnContextClassRef).collect(Collectors.toList());
assertThat(actual).containsAll(expected);
}
use of org.opensaml.saml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class RpAuthnRequestTranslatorService method translate.
public TranslatedAuthnRequestDto translate(SamlRequestWithAuthnRequestInformationDto samlRequestWithAuthnRequestInformationDto) {
AuthnRequest authnRequest = stringToAuthnRequestTransformer.apply(samlRequestWithAuthnRequestInformationDto.getSamlMessage());
MdcHelper.addContextToMdc(authnRequest.getID(), authnRequest.getIssuer().getValue());
AuthnRequestFromRelyingParty authnRequestFromRelyingParty = authnRequestToIdaRequestFromRelyingPartyTransformer.apply(authnRequest);
if (authnRequestFromRelyingParty.getVerifyServiceProviderVersion().isPresent()) {
logAndSendMetricForVspVersion(authnRequestFromRelyingParty);
}
UnknownMethodAlgorithmLogger.probeAuthnRequestForMethodAlgorithm(authnRequestFromRelyingParty);
return new TranslatedAuthnRequestDto(authnRequestFromRelyingParty.getId(), authnRequestFromRelyingParty.getIssuer(), authnRequestFromRelyingParty.getForceAuthentication(), authnRequestFromRelyingParty.getAssertionConsumerServiceUrl(), authnRequestFromRelyingParty.getAssertionConsumerServiceIndex());
}
Aggregations