use of org.opensaml.saml.saml2.core.SubjectConfirmation 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;
}
use of org.opensaml.saml.saml2.core.SubjectConfirmation in project spring-security by spring-projects.
the class OpenSamlAuthenticationProviderTests method assertion.
private Assertion assertion() {
Assertion assertion = TestOpenSamlObjects.assertion();
assertion.setIssueInstant(DateTime.now());
for (SubjectConfirmation confirmation : assertion.getSubject().getSubjectConfirmations()) {
SubjectConfirmationData data = confirmation.getSubjectConfirmationData();
data.setNotBefore(DateTime.now().minus(Duration.millis(5 * 60 * 1000)));
data.setNotOnOrAfter(DateTime.now().plus(Duration.millis(5 * 60 * 1000)));
}
Conditions conditions = assertion.getConditions();
conditions.setNotBefore(DateTime.now().minus(Duration.millis(5 * 60 * 1000)));
conditions.setNotOnOrAfter(DateTime.now().plus(Duration.millis(5 * 60 * 1000)));
return assertion;
}
use of org.opensaml.saml.saml2.core.SubjectConfirmation in project spring-security by spring-projects.
the class OpenSaml4AuthenticationProviderTests method assertion.
private Assertion assertion() {
Assertion assertion = TestOpenSamlObjects.assertion();
assertion.setIssueInstant(Instant.now());
for (SubjectConfirmation confirmation : assertion.getSubject().getSubjectConfirmations()) {
SubjectConfirmationData data = confirmation.getSubjectConfirmationData();
data.setNotBefore(Instant.now().minus(Duration.ofMillis(5 * 60 * 1000)));
data.setNotOnOrAfter(Instant.now().plus(Duration.ofMillis(5 * 60 * 1000)));
}
Conditions conditions = assertion.getConditions();
conditions.setNotBefore(Instant.now().minus(Duration.ofMillis(5 * 60 * 1000)));
conditions.setNotOnOrAfter(Instant.now().plus(Duration.ofMillis(5 * 60 * 1000)));
return assertion;
}
Aggregations