'Create an object that represents a SAML AttributeStatement.
<ns0:AttributeStatement>
<ns0:Attribute Name="openstack_user">
<ns0:AttributeValue
xsi:type="xs:string">test_user</ns0:AttributeValue>
</ns0:Attribute>
<ns0:Attribute Name="openstack_user_domain">
<ns0:AttributeValue
xsi:type="xs:string">Default</ns0:AttributeValue>
</ns0:Attribute>
<ns0:Attribute Name="openstack_roles">
<ns0:AttributeValue
xsi:type="xs:string">admin</ns0:AttributeValue>
<ns0:AttributeValue
xsi:type="xs:string">member</ns0:AttributeValue>
</ns0:Attribute>
<ns0:Attribute Name="openstack_project">
<ns0:AttributeValue
xsi:type="xs:string">development</ns0:AttributeValue>
</ns0:Attribute>
<ns0:Attribute Name="openstack_project_domain">
<ns0:AttributeValue
xsi:type="xs:string">Default</ns0:AttributeValue>
</ns0:Attribute>
</ns0:AttributeStatement>
:returns: XML <AttributeStatement> object'

def _create_attribute_statement(self, user, user_domain_name, roles, project, project_domain_name):

    def _build_attribute(attribute_name, attribute_values):
        attribute = saml.Attribute()
        attribute.name = attribute_name
        for value in attribute_values:
            attribute_value = saml.AttributeValue()
            attribute_value.set_text(value)
            attribute.attribute_value.append(attribute_value)
        return attribute
    user_attribute = _build_attribute('openstack_user', [user])
    roles_attribute = _build_attribute('openstack_roles', roles)
    project_attribute = _build_attribute('openstack_project', [project])
    project_domain_attribute = _build_attribute('openstack_project_domain', [project_domain_name])
    user_domain_attribute = _build_attribute('openstack_user_domain', [user_domain_name])
    attribute_statement = saml.AttributeStatement()
    attribute_statement.attribute.append(user_attribute)
    attribute_statement.attribute.append(roles_attribute)
    attribute_statement.attribute.append(project_attribute)
    attribute_statement.attribute.append(project_domain_attribute)
    attribute_statement.attribute.append(user_domain_attribute)
    return attribute_statement
