use of org.opensaml.saml.saml2.core.impl.AttributeBuilder in project verify-hub by alphagov.
the class VerifiedAttributesLoggerTest method shouldLogPreviousAddressHistory.
@Test
public void shouldLogPreviousAddressHistory() throws Exception {
AttributeValue previousAddressAttributeValue = new AddressAttributeValueBuilder_1_1().withFrom(DateTime.now().minusYears(10)).withTo(DateTime.now().minusYears(1)).withVerified(false).build();
Attribute previousAddressAttribute = new AttributeBuilder().buildObject();
previousAddressAttribute.setName(IdaConstants.Attributes_1_1.PreviousAddress.NAME);
previousAddressAttribute.getAttributeValues().add(previousAddressAttributeValue);
List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().addPreviousAddress(previousAddressAttribute).build().getAttributes();
AttributeStatementLogData actual = mapper.readValue(formatAttributes("any-issuer", LEVEL_2, attributes), AttributeStatementLogData.class);
Map<String, List<VerifiedAttributeLogData>> attributesMap = actual.getAttributes();
assertThat(attributesMap.get(IdaConstants.Attributes_1_1.PreviousAddress.NAME)).isEqualTo(List.of(new VerifiedAttributeLogData(false, "more than 180 days")));
}
use of org.opensaml.saml.saml2.core.impl.AttributeBuilder in project verify-hub by alphagov.
the class VerifiedAttributesLoggerTest method shouldLogDateOfBirthHistory.
@Test
public void shouldLogDateOfBirthHistory() throws Exception {
Attribute dateOfBirthAttribute = new AttributeBuilder().buildObject();
dateOfBirthAttribute.setName(IdaConstants.Attributes_1_1.DateOfBirth.NAME);
AttributeValue oldDateOfBirthAttributeValue = new DateAttributeValueBuilder().withTo(DateTime.now().minusDays(1)).withVerified(true).build();
AttributeValue currentDateOfBirthAttributeValue = new DateAttributeValueBuilder().withTo(null).build();
dateOfBirthAttribute.getAttributeValues().add(oldDateOfBirthAttributeValue);
dateOfBirthAttribute.getAttributeValues().add(currentDateOfBirthAttributeValue);
List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withDateOfBirth(dateOfBirthAttribute).build().getAttributes();
AttributeStatementLogData actual = mapper.readValue(formatAttributes("any-issuer", LEVEL_2, attributes), AttributeStatementLogData.class);
Map<String, List<VerifiedAttributeLogData>> attributesMap = actual.getAttributes();
assertThat(attributesMap.get(IdaConstants.Attributes_1_1.DateOfBirth.NAME)).isEqualTo(List.of(new VerifiedAttributeLogData(true, "less than 180 days"), new VerifiedAttributeLogData(false, null)));
}
use of org.opensaml.saml.saml2.core.impl.AttributeBuilder in project verify-hub by alphagov.
the class AuthnRequestFromRelyingPartyUnmarshallerTest method createApplicationVersionExtensions.
private Extensions createApplicationVersionExtensions(String version) throws Exception {
Extensions extensions = new ExtensionsBuilder().buildObject();
Attribute versionsAttribute = new AttributeBuilder().buildObject();
versionsAttribute.setName("Versions");
versionsAttribute.getAttributeValues().add(createApplicationVersion(version));
extensions.getUnknownXMLObjects().add(encrypter.encrypt(versionsAttribute));
return extensions;
}
use of org.opensaml.saml.saml2.core.impl.AttributeBuilder in project spring-security by spring-projects.
the class TestOpenSamlObjects method customAttributeStatement.
static AttributeStatement customAttributeStatement(String attributeName, XMLObject customAttributeValue) {
AttributeStatementBuilder attributeStatementBuilder = new AttributeStatementBuilder();
AttributeBuilder attributeBuilder = new AttributeBuilder();
Attribute attribute = attributeBuilder.buildObject();
attribute.setName(attributeName);
attribute.getAttributeValues().add(customAttributeValue);
AttributeStatement attributeStatement = attributeStatementBuilder.buildObject();
attributeStatement.getAttributes().add(attribute);
return attributeStatement;
}
Aggregations