use of uk.gov.ida.saml.core.domain.PersistentId in project verify-hub by alphagov.
the class HubAttributeQueryRequestToSamlAttributeQueryTransformerTest method transform_shouldProperlyTransform.
@Test
public void transform_shouldProperlyTransform() {
PersistentId persistentId = new PersistentId("default-name-id");
HubAttributeQueryRequest originalQuery = aHubAttributeQueryRequest().withId("originalId").withPersistentId(persistentId).build();
AttributeQuery transformedQuery = transformer.apply(originalQuery);
assertThat(transformedQuery.getID()).isEqualTo(originalQuery.getId());
assertThat(transformedQuery.getSubject().getNameID().getValue()).isEqualTo(persistentId.getNameId());
assertThat(transformedQuery.getIssuer().getValue()).isEqualTo(originalQuery.getIssuer());
assertThat(transformedQuery.getVersion()).isEqualTo(SAMLVersion.VERSION_20);
}
use of uk.gov.ida.saml.core.domain.PersistentId in project verify-hub by alphagov.
the class PassthroughAssertionUnmarshaller method fromAssertion.
public PassthroughAssertion fromAssertion(Assertion assertion) {
PersistentId persistentId = new PersistentId(assertion.getSubject().getNameID().getValue());
Optional<AuthnContext> levelOfAssurance = Optional.empty();
Optional<String> principalIpAddress = getPrincipalIpAddress(assertion.getAttributeStatements());
if (!assertion.getAuthnStatements().isEmpty()) {
String levelOfAssuranceAsString = assertion.getAuthnStatements().get(0).getAuthnContext().getAuthnContextClassRef().getAuthnContextClassRef();
levelOfAssurance = Optional.ofNullable(authnContextFactory.authnContextForLevelOfAssurance(levelOfAssuranceAsString));
}
String underlyingAssertion = assertionStringTransformer.apply(assertion);
Optional<FraudDetectedDetails> fraudDetectedDetails = Optional.empty();
if (levelOfAssurance.isPresent() && levelOfAssurance.get().equals(AuthnContext.LEVEL_X)) {
String idpFraudEventId = getIdpFraudEventId(assertion.getAttributeStatements());
fraudDetectedDetails = Optional.of(new FraudDetectedDetails(idpFraudEventId, gpg45Status(assertion.getAttributeStatements())));
}
return new PassthroughAssertion(persistentId, levelOfAssurance, underlyingAssertion, fraudDetectedDetails, principalIpAddress);
}
use of uk.gov.ida.saml.core.domain.PersistentId in project verify-hub by alphagov.
the class HubEidasAttributeQueryRequestBuilder method createCycle3Assertion.
private Optional<HubAssertion> createCycle3Assertion(EidasAttributeQueryRequestDto attributeQueryRequestDto) {
Optional<HubAssertion> cycle3AttributeAssertion = Optional.empty();
Optional<uk.gov.ida.hub.samlengine.domain.Cycle3Dataset> serializableCycle3Dataset = attributeQueryRequestDto.getCycle3Dataset();
if (serializableCycle3Dataset.isPresent()) {
AssertionRestrictions assertionRestrictions = new AssertionRestrictions(attributeQueryRequestDto.getAssertionExpiry(), attributeQueryRequestDto.getRequestId(), attributeQueryRequestDto.getAuthnRequestIssuerEntityId());
Optional<Cycle3Dataset> cycle3Data = serializableCycle3Dataset.map(uk.gov.ida.hub.samlengine.domain.Cycle3Dataset::getAttributes).map(Cycle3Dataset::createFromData);
HubAssertion hubAssertion = new HubAssertion(UUID.randomUUID().toString(), hubEntityId, DateTime.now(), new PersistentId(attributeQueryRequestDto.getPersistentId().getNameId()), assertionRestrictions, cycle3Data);
cycle3AttributeAssertion = Optional.of(hubAssertion);
}
return cycle3AttributeAssertion;
}
use of uk.gov.ida.saml.core.domain.PersistentId in project verify-hub by alphagov.
the class MatchingServiceResponseTranslatorServiceTest method setUpForTranslate.
private void setUpForTranslate(Optional<AuthnContext> authnContext, Optional<FraudDetectedDetails> fraudDetectedDetails, String encryptedAssertion, String inResponseTo, String issuer, String samlResponse, MatchingServiceIdaStatus status) {
final PassthroughAssertion assertion = new PassthroughAssertion(new PersistentId("persistentId"), authnContext, encryptedAssertion, fraudDetectedDetails, Optional.of("principalIpAddressAsSeenByIdp"));
final InboundResponseFromMatchingService inboundResponseFromMatchingService = InboundResponseFromMatchingServiceBuilder.anInboundResponseFromMatchingService().withInResponseTo(inResponseTo).withIssuerId(issuer).withMatchingServiceAssertion(assertion).withStatus(status).build();
Response response = mock(Response.class);
Issuer responseIssuer = mock(Issuer.class);
when(response.getIssuer()).thenReturn(responseIssuer);
when(responseUnmarshaller.apply(samlResponse)).thenReturn(response);
when(responseToInboundResponseFromMatchingServiceTransformer.transform(response)).thenReturn(inboundResponseFromMatchingService);
when(assertionBlobEncrypter.encryptAssertionBlob(eq(TEST_RP), any())).thenReturn(encryptedAssertion);
}
use of uk.gov.ida.saml.core.domain.PersistentId in project verify-hub by alphagov.
the class HubAttributeQueryRequestBuilder method createCycle3Assertion.
private Optional<HubAssertion> createCycle3Assertion(AttributeQueryRequestDto attributeQueryRequestDto) {
Optional<HubAssertion> cycle3AttributeAssertion = Optional.empty();
if (attributeQueryRequestDto.getCycle3Dataset().isPresent()) {
AssertionRestrictions assertionRestrictions = new AssertionRestrictions(attributeQueryRequestDto.getAssertionExpiry(), attributeQueryRequestDto.getRequestId(), attributeQueryRequestDto.getAuthnRequestIssuerEntityId());
Optional<Cycle3Dataset> cycle3Data = Optional.of(Cycle3Dataset.createFromData(attributeQueryRequestDto.getCycle3Dataset().get().getAttributes()));
cycle3AttributeAssertion = Optional.of(new HubAssertion(UUID.randomUUID().toString(), hubEntityId, DateTime.now(), new PersistentId(attributeQueryRequestDto.getPersistentId().getNameId()), assertionRestrictions, cycle3Data));
}
return cycle3AttributeAssertion;
}
Aggregations