Search in sources :

Example 6 with Attribute

use of org.opensaml.saml.saml1.core.Attribute in project verify-hub by alphagov.

the class VerifiedAttributesLoggerTest method shouldLogMiddleNamesNameHistory.

@Test
public void shouldLogMiddleNamesNameHistory() throws Exception {
    AttributeValue oldMiddleNamesAttributeValue = new PersonNameAttributeValueBuilder().withFrom(DateTime.parse("2000-12-31")).withTo(DateTime.now().minusDays(406)).withVerified(true).build();
    AttributeValue currentMiddleNamesAttributeValue = new PersonNameAttributeValueBuilder().withFrom(DateTime.now().minusDays(405)).withVerified(true).build();
    Attribute middleNamesAttribute = new AttributeBuilder().buildObject();
    middleNamesAttribute.setName(IdaConstants.Attributes_1_1.Middlename.NAME);
    middleNamesAttribute.getAttributeValues().add(oldMiddleNamesAttributeValue);
    middleNamesAttribute.getAttributeValues().add(currentMiddleNamesAttributeValue);
    List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withMiddleNames(middleNamesAttribute).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.Middlename.NAME)).isEqualTo(ImmutableList.of(new VerifiedAttributeLogData(true, "more than 405 days"), new VerifiedAttributeLogData(true, null)));
}
Also used : AttributeValue(org.opensaml.saml.saml2.core.AttributeValue) AttributeBuilder(org.opensaml.saml.saml2.core.impl.AttributeBuilder) Attribute(org.opensaml.saml.saml2.core.Attribute) AttributeStatementLogData(uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData) PersonNameAttributeValueBuilder(uk.gov.ida.saml.core.test.builders.PersonNameAttributeValueBuilder) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) VerifiedAttributeLogData(uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData) Test(org.junit.Test)

Example 7 with Attribute

use of org.opensaml.saml.saml1.core.Attribute in project verify-hub by alphagov.

the class VerifiedAttributesLoggerTest method shouldLogIssuerAndLevelOfAssurance.

@Test
public void shouldLogIssuerAndLevelOfAssurance() throws Exception {
    List<Attribute> anyAttributesList = aMatchingDatasetAttributeStatement_1_1().build().getAttributes();
    AttributeStatementLogData actual = mapper.readValue(formatAttributes("some-issuer", LEVEL_2, anyAttributesList), AttributeStatementLogData.class);
    assertThat(actual.getIssuer()).isEqualTo("some-issuer");
    assertThat(actual.getLevelOfAssurance()).isEqualTo(LEVEL_2);
}
Also used : Attribute(org.opensaml.saml.saml2.core.Attribute) AttributeStatementLogData(uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData) Test(org.junit.Test)

Example 8 with Attribute

use of org.opensaml.saml.saml1.core.Attribute in project verify-hub by alphagov.

the class VerifiedAttributesLoggerTest method shouldLogSurnameNameHistory.

@Test
public void shouldLogSurnameNameHistory() throws Exception {
    AttributeValue surnameAttributeValue = new PersonNameAttributeValueBuilder().withFrom(DateTime.parse("2000-12-31")).withVerified(true).build();
    Attribute surnameAttribute = new AttributeBuilder().buildObject();
    surnameAttribute.setName(IdaConstants.Attributes_1_1.Surname.NAME);
    surnameAttribute.getAttributeValues().add(surnameAttributeValue);
    List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withSurname(surnameAttribute).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.Surname.NAME)).isEqualTo(ImmutableList.of(new VerifiedAttributeLogData(true, null)));
}
Also used : AttributeValue(org.opensaml.saml.saml2.core.AttributeValue) AttributeBuilder(org.opensaml.saml.saml2.core.impl.AttributeBuilder) Attribute(org.opensaml.saml.saml2.core.Attribute) AttributeStatementLogData(uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData) PersonNameAttributeValueBuilder(uk.gov.ida.saml.core.test.builders.PersonNameAttributeValueBuilder) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) VerifiedAttributeLogData(uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData) Test(org.junit.Test)

Example 9 with Attribute

use of org.opensaml.saml.saml1.core.Attribute in project verify-hub by alphagov.

the class VerifiedAttributesLoggerTest method shouldLogCurrentAddressHistory.

@Test
public void shouldLogCurrentAddressHistory() throws Exception {
    AttributeValue currentAddressAttributeValue = new AddressAttributeValueBuilder_1_1().withFrom(DateTime.now().minusYears(1)).withVerified(true).build();
    Attribute currentAddressAttribute = new AttributeBuilder().buildObject();
    currentAddressAttribute.setName(IdaConstants.Attributes_1_1.CurrentAddress.NAME);
    currentAddressAttribute.getAttributeValues().add(currentAddressAttributeValue);
    List<Attribute> attributes = aMatchingDatasetAttributeStatement_1_1().withCurrentAddress(currentAddressAttribute).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.CurrentAddress.NAME)).isEqualTo(ImmutableList.of(new VerifiedAttributeLogData(true, null)));
}
Also used : AttributeValue(org.opensaml.saml.saml2.core.AttributeValue) AddressAttributeValueBuilder_1_1(uk.gov.ida.saml.core.test.builders.AddressAttributeValueBuilder_1_1) AttributeBuilder(org.opensaml.saml.saml2.core.impl.AttributeBuilder) Attribute(org.opensaml.saml.saml2.core.Attribute) AttributeStatementLogData(uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData) List(java.util.List) ImmutableList(com.google.common.collect.ImmutableList) VerifiedAttributeLogData(uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData) Test(org.junit.Test)

Example 10 with Attribute

use of org.opensaml.saml.saml1.core.Attribute in project verify-hub by alphagov.

the class EidasAttributeStatementAssertionValidatorTest method generateAttribute.

private Attribute generateAttribute(String name, String friendlyName, QName schemaType) {
    Attribute attribute = mock(Attribute.class);
    XMLObject xmlObject = mock(XMLObject.class);
    when(attribute.getName()).thenReturn(name);
    when(attribute.getFriendlyName()).thenReturn(friendlyName);
    when(attribute.getAttributeValues()).thenReturn(ImmutableList.of(xmlObject));
    when(xmlObject.getSchemaType()).thenReturn(schemaType);
    when(attribute.getNameFormat()).thenReturn(Attribute.URI_REFERENCE);
    return attribute;
}
Also used : Attribute(org.opensaml.saml.saml2.core.Attribute) XMLObject(org.opensaml.core.xml.XMLObject)

Aggregations

Attribute (org.opensaml.saml.saml2.core.Attribute)24 XMLObject (org.opensaml.core.xml.XMLObject)11 AttributeStatement (org.opensaml.saml.saml2.core.AttributeStatement)11 List (java.util.List)8 Test (org.junit.Test)7 AttributeStatementLogData (uk.gov.ida.hub.samlengine.logging.data.AttributeStatementLogData)7 ImmutableList (com.google.common.collect.ImmutableList)6 AttributeValue (org.opensaml.saml.saml2.core.AttributeValue)6 AttributeBuilder (org.opensaml.saml.saml2.core.impl.AttributeBuilder)6 VerifiedAttributeLogData (uk.gov.ida.hub.samlengine.logging.data.VerifiedAttributeLogData)6 Map (java.util.Map)5 HashMap (java.util.HashMap)4 Attribute (org.opensaml.saml2.core.Attribute)4 SecurityAssertion (ddf.security.assertion.SecurityAssertion)3 ClaimCollection (org.apache.cxf.rt.security.claims.ClaimCollection)3 SamlAssertionWrapper (org.apache.wss4j.common.saml.SamlAssertionWrapper)3 Element (org.w3c.dom.Element)3 GuestPrincipal (ddf.security.principal.GuestPrincipal)2 Principal (java.security.Principal)2 ArrayList (java.util.ArrayList)2