@staticmethod<EOL><INDENT>def get_metadata(url, validate_cert=True):<DEDENT>
valid = False<EOL>if validate_cert:<EOL><INDENT>response = urllib2.urlopen(url)<EOL><DEDENT>else:<EOL><INDENT>ctx = ssl.create_default_context()<EOL>ctx.check_hostname = False<EOL>ctx.verify_mode = ssl.CERT_NONE<EOL>response = urllib2.urlopen(url, context=ctx)<EOL><DEDENT>xml = response.read()<EOL>if xml:<EOL><INDENT>try:<EOL><INDENT>dom = OneLogin_Saml2_XML.to_etree(xml)<EOL>idp_descriptor_nodes = OneLogin_Saml2_XML.query(dom, '<STR_LIT>')<EOL>if idp_descriptor_nodes:<EOL><INDENT>valid = True<EOL><DEDENT><DEDENT>except Exception:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>if not valid:<EOL><INDENT>raise Exception('<STR_LIT>' % (url))<EOL><DEDENT>return xml<EOL>
Gets the metadata XML from the provided URL
:param url: Url where the XML of the Identity Provider Metadata is published.
:type url: string

:param validate_cert: If the url uses https schema, that flag enables or not the verification of the associated certificate.
:type validate_cert: bool

:returns: metadata XML
:rtype: string