use of uk.gov.ida.saml.core.domain.HubAssertion in project verify-hub by alphagov.
the class HubAssertionMarshallerTest method transform_shouldTransformAssertionId.
@Test
public void transform_shouldTransformAssertionId() {
String assertionId = "assertion-id";
HubAssertion assertion = aHubAssertion().withId(assertionId).build();
Assertion transformedAssertion = marshaller.toSaml(assertion);
assertThat(transformedAssertion.getID()).isEqualTo(assertionId);
}
use of uk.gov.ida.saml.core.domain.HubAssertion 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;
}
use of uk.gov.ida.saml.core.domain.HubAssertion in project verify-hub by alphagov.
the class HubAssertionMarshaller method toSaml.
public Assertion toSaml(HubAssertion hubAssertion) {
Assertion transformedAssertion = openSamlXmlObjectFactory.createAssertion();
transformedAssertion.setIssueInstant(hubAssertion.getIssueInstant());
Issuer transformedIssuer = openSamlXmlObjectFactory.createIssuer(hubAssertion.getIssuerId());
transformedAssertion.setIssuer(transformedIssuer);
transformedAssertion.setID(hubAssertion.getId());
if (hubAssertion.getCycle3Data().isPresent()) {
Cycle3Dataset cycle3Data = hubAssertion.getCycle3Data().get();
transformedAssertion.getAttributeStatements().add(transform(cycle3Data));
}
transformedAssertion.setSubject(outboundAssertionToSubjectTransformer.transform(hubAssertion));
return transformedAssertion;
}
use of uk.gov.ida.saml.core.domain.HubAssertion in project verify-hub by alphagov.
the class HubAttributeQueryRequestToSamlAttributeQueryTransformer method apply.
public AttributeQuery apply(HubAttributeQueryRequest originalQuery) {
AttributeQuery transformedQuery = samlObjectFactory.createAttributeQuery();
Issuer issuer = samlObjectFactory.createIssuer(originalQuery.getIssuer());
transformedQuery.setID(originalQuery.getId());
transformedQuery.setIssuer(issuer);
transformedQuery.setIssueInstant(DateTime.now());
if (originalQuery.getUserAccountCreationAttributes().isPresent()) {
transformedQuery.getAttributes().addAll(createAttributeList(originalQuery.getUserAccountCreationAttributes().get()));
}
Subject subject = samlObjectFactory.createSubject();
NameID nameId = samlObjectFactory.createNameId(originalQuery.getPersistentId().getNameId());
nameId.setSPNameQualifier(originalQuery.getAuthnRequestIssuerEntityId());
nameId.setNameQualifier(originalQuery.getAssertionConsumerServiceUrl().toASCIIString());
subject.setNameID(nameId);
SubjectConfirmation subjectConfirmation = samlObjectFactory.createSubjectConfirmation();
SubjectConfirmationData subjectConfirmationData = samlObjectFactory.createSubjectConfirmationData();
Stream.of(originalQuery.getEncryptedMatchingDatasetAssertion(), originalQuery.getEncryptedAuthnAssertion()).map(encryptedAssertionUnmarshaller::transform).forEach(subjectConfirmationData.getUnknownXMLObjects(EncryptedAssertion.DEFAULT_ELEMENT_NAME)::add);
final Optional<HubAssertion> cycle3DatasetAssertion = originalQuery.getCycle3AttributeAssertion();
if (cycle3DatasetAssertion.isPresent()) {
Assertion transformedCycle3DatasetAssertion = hubAssertionMarshaller.toSaml(cycle3DatasetAssertion.get());
subjectConfirmationData.getUnknownXMLObjects(Assertion.DEFAULT_ELEMENT_NAME).add(transformedCycle3DatasetAssertion);
}
subjectConfirmation.setSubjectConfirmationData(subjectConfirmationData);
subject.getSubjectConfirmations().add(subjectConfirmation);
transformedQuery.setSubject(subject);
return transformedQuery;
}
Aggregations