use of org.opensaml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class IdaAuthnRequestFromHubToAuthnRequestTransformerTest method shouldSetForceAuthnToFalse.
@Test
public void shouldSetForceAuthnToFalse() {
IdaAuthnRequestFromHub originalRequestFromTransaction = anIdaAuthnRequest().withForceAuthentication(Optional.of(false)).buildFromHub();
AuthnRequest transformedRequest = transformer.apply(originalRequestFromTransaction);
assertThat(transformedRequest.isForceAuthn()).isEqualTo(false);
originalRequestFromTransaction = anIdaAuthnRequest().withForceAuthentication(Optional.empty()).buildFromHub();
transformedRequest = transformer.apply(originalRequestFromTransaction);
assertThat(transformedRequest.isForceAuthn()).isEqualTo(false);
}
use of org.opensaml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class AuthnRequestFromRelyingPartyUnmarshallerTest method fromSamlMessage_shouldMapAuthnRequestToAuthnRequestFromRelyingParty.
@Test
public void fromSamlMessage_shouldMapAuthnRequestToAuthnRequestFromRelyingParty() throws Exception {
DateTime issueInstant = new DateTime();
SignatureImpl signature = new SignatureBuilder().buildObject();
AuthnRequest authnRequest = new AuthnRequestBuilder().buildObject();
authnRequest.setID("some-id");
Issuer issuer = new IssuerBuilder().buildObject();
issuer.setValue("some-service-entity-id");
authnRequest.setIssuer(issuer);
authnRequest.setIssueInstant(issueInstant);
authnRequest.setDestination("http://example.com");
authnRequest.setForceAuthn(true);
authnRequest.setAssertionConsumerServiceURL("some-url");
authnRequest.setAssertionConsumerServiceIndex(5);
authnRequest.setSignature(signature);
authnRequest.setExtensions(createApplicationVersionExtensions("some-version"));
AuthnRequestFromRelyingParty authnRequestFromRelyingParty = unmarshaller.fromSamlMessage(authnRequest);
AuthnRequestFromRelyingParty expected = new AuthnRequestFromRelyingParty("some-id", "some-service-entity-id", issueInstant, URI.create("http://example.com"), Optional.of(true), Optional.of(URI.create("some-url")), Optional.of(5), Optional.of(signature), Optional.of("some-version"));
assertThat(authnRequestFromRelyingParty).isEqualTo(expected);
}
use of org.opensaml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class AuthnRequestFromTransactionValidatorTest method validateRequest_shouldThrowExceptionIfIsDuplicateRequestIdIsPresent.
@Test
public void validateRequest_shouldThrowExceptionIfIsDuplicateRequestIdIsPresent() {
final String requestId = generateRequestId();
final String oneIssuerId = "some-issuer-id";
final String anotherIssuerId = "some-other-issuer-id";
final AuthnRequest authnRequest = anAuthnRequest().withId(requestId).withIssuer(anIssuer().withIssuerId(oneIssuerId).build()).build();
validator.validate(authnRequest);
final AuthnRequest duplicateIdAuthnRequest = anAuthnRequest().withId(requestId).withIssuer(anIssuer().withIssuerId(anotherIssuerId).build()).build();
validateException(assertThrows(SamlTransformationErrorException.class, () -> validator.validate(duplicateIdAuthnRequest)), SamlTransformationErrorFactory.duplicateRequestId(requestId, duplicateIdAuthnRequest.getIssuer().getValue()));
}
use of org.opensaml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class AuthnRequestFromTransactionValidatorTest method validate_shouldThrowExceptionIfVersionNumberIsMissing.
@Test
public void validate_shouldThrowExceptionIfVersionNumberIsMissing() {
AuthnRequest authnRequest = anAuthnRequest().withVersionNumber(null).build();
validateException(assertThrows(SamlTransformationErrorException.class, () -> validator.validate(authnRequest)), SamlTransformationErrorFactory.missingRequestVersion(authnRequest.getID()));
}
use of org.opensaml.saml2.core.AuthnRequest in project verify-hub by alphagov.
the class AuthnRequestFromTransactionValidatorTest method validateRequest_shouldThrowExceptionIfRequestIsTooOld.
@Test
public void validateRequest_shouldThrowExceptionIfRequestIsTooOld() {
DateTimeFreezer.freezeTime();
String requestId = generateRequestId();
DateTime issueInstant = DateTime.now().minusMinutes(5).minusSeconds(1);
final AuthnRequest authnRequest = anAuthnRequest().withId(requestId).withIssueInstant(issueInstant).build();
validateException(assertThrows(SamlTransformationErrorException.class, () -> validator.validate(authnRequest)), SamlTransformationErrorFactory.requestTooOld(requestId, issueInstant.withZone(DateTimeZone.UTC), DateTime.now()));
}
Aggregations