 
   assertion_attributes = {}
   for attribute in attribute_statement[0].getElementsByTagNameNS(XMLNS.SAML, 'Attribute')
-    for attr in attribute.attributes
-      if attr.name is 'Name'
-        attribute_name = attr.value
+    for attr in attribute?.attributes or []
+      if attr?.name is 'Name'
+        attribute_name = attr?.value
     throw new Error("Invalid attribute without name") unless attribute_name?
     attribute_values = attribute.getElementsByTagNameNS(XMLNS.SAML, 'AttributeValue')
     assertion_attributes[attribute_name] = _(attribute_values).map (attribute_value) ->

  status = dom.getElementsByTagNameNS(XMLNS.SAMLP, 'Status')
  return status_list unless status.length is 1

  for status_code in status[0].childNodes
    if status_code.attributes?
      for attr in status_code.attributes
        if attr.name is 'Value'
          top_status = attr.value
          status_list[top_status] ?= []
    for sub_status_code in status_code.childNodes
      if sub_status_code.attributes?
        for attr in sub_status_code.attributes
          if attr.name is 'Value'
            status_list[top_status].push attr.value
  status_list

to_error = (err) ->

      if ignore_signature
        return cb_wf null, (new xmldom.DOMParser()).parseFromString(result)

      for cert in idp_certificates or []
        signed_data = check_saml_signature result, cert
        unless signed_data
          continue # Cert was not valid, try the next one
