tools/adfs2fed.py
def exportAdfs2Fed(idpUrl, scope):
	"""
	Modifies ADFS metadata removing and inserting elements in order to avoid parsing problems on Shibboleth-side
	"""
	adfsEndpoint = "/FederationMetadata/2007-06/FederationMetadata.xml"
	shibNameSpace = 'xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"'
	extensions = '<Extensions>\n    <shibmd:Scope regexp="false">' + scope + '</shibmd:Scope>\n  </Extensions>\n  '
	mdString = ""
	try:
		# get metadata
		metadata = urllib2.urlopen(idpUrl + adfsEndpoint)
		root = etree.fromstring(metadata.read())
		# remove signature, RoleDescriptor and SPSSODescriptor elements in order to avoid incompatibilities with
		# the Switch WAYF shipped parser
		root.remove(root.find('{http://www.w3.org/2000/09/xmldsig#}Signature'))
		root.remove(root.find('{urn:oasis:names:tc:SAML:2.0:metadata}RoleDescriptor'))
		root.remove(root.find('{urn:oasis:names:tc:SAML:2.0:metadata}RoleDescriptor'))
		root.remove(root.find('{urn:oasis:names:tc:SAML:2.0:metadata}SPSSODescriptor'))
		# add SAML1 SingleSignOn binding, in order to avoid Switch WAYF limitation (without this the IdP
		# configuration will not be loaded
		binding = etree.XML('<SingleSignOnService Binding="urn:mace:shibboleth:1.0:profiles:AuthnRequest" Location="' + idpUrl + '/adfs/ls/"/>')
		root[0].insert(8,binding)
		# add scope extension
		mdString = etree.tostring(root, pretty_print=True)
		mdString = mdString.replace('xmlns="urn:oasis:names:tc:SAML:2.0:metadata"', 'xmlns="urn:oasis:names:tc:SAML:2.0:metadata"' + ' ' + shibNameSpace)
		mdString = mdString.replace('<IDPSSODescriptor', extensions + '<IDPSSODescriptor')
	except Exception, e:
		print(e)
	return mdString

	Modifies ADFS metadata removing and inserting elements in order to avoid parsing problems on Shibboleth-side
	
Modifies ADFS metadata removing and inserting elements in order to avoid parsing problems on Shibboleth-side
Modifies ADFS metadata removing and inserting elements in order to avoid parsing problems on Shibboleth - side
def exportAdfs2Fed(idpUrl, scope):
	adfsEndpoint = "/FederationMetadata/2007-06/FederationMetadata.xml"
	shibNameSpace = 'xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"'
	extensions = '<Extensions>\n    <shibmd:Scope regexp="false">' + scope + '</shibmd:Scope>\n  </Extensions>\n  '
	mdString = ""
	try:
		metadata = urllib2.urlopen(idpUrl + adfsEndpoint)
		root = etree.fromstring(metadata.read())
		root.remove(root.find('{http://www.w3.org/2000/09/xmldsig#}Signature'))
		root.remove(root.find('{urn:oasis:names:tc:SAML:2.0:metadata}RoleDescriptor'))
		root.remove(root.find('{urn:oasis:names:tc:SAML:2.0:metadata}RoleDescriptor'))
		root.remove(root.find('{urn:oasis:names:tc:SAML:2.0:metadata}SPSSODescriptor'))
		binding = etree.XML('<SingleSignOnService Binding="urn:mace:shibboleth:1.0:profiles:AuthnRequest" Location="' + idpUrl + '/adfs/ls/"/>')
		root[0].insert(8,binding)
		mdString = etree.tostring(root, pretty_print=True)
		mdString = mdString.replace('xmlns="urn:oasis:names:tc:SAML:2.0:metadata"', 'xmlns="urn:oasis:names:tc:SAML:2.0:metadata"' + ' ' + shibNameSpace)
		mdString = mdString.replace('<IDPSSODescriptor', extensions + '<IDPSSODescriptor')
	except Exception, e:
		print(e)
	return mdString
def exportAdfs2Fed ( idpUrl , scope ) : adfsEndpoint = "/FederationMetadata/2007-06/FederationMetadata.xml" shibNameSpace = 'xmlns:shibmd="urn:mace:shibboleth:metadata:1.0"' extensions = '<Extensions>\n    <shibmd:Scope regexp="false">' + scope + '</shibmd:Scope>\n  </Extensions>\n  ' mdString = "" try : metadata = urllib2 . urlopen ( idpUrl + adfsEndpoint ) root = etree . fromstring ( metadata . read ( ) ) root . remove ( root . find ( '{http://www.w3.org/2000/09/xmldsig#}Signature' ) ) root . remove ( root . find ( '{urn:oasis:names:tc:SAML:2.0:metadata}RoleDescriptor' ) ) root . remove ( root . find ( '{urn:oasis:names:tc:SAML:2.0:metadata}RoleDescriptor' ) ) root . remove ( root . find ( '{urn:oasis:names:tc:SAML:2.0:metadata}SPSSODescriptor' ) ) binding = etree . XML ( '<SingleSignOnService Binding="urn:mace:shibboleth:1.0:profiles:AuthnRequest" Location="' + idpUrl + '/adfs/ls/"/>' ) root [ 0 ] . insert ( 8 , binding ) mdString = etree . tostring ( root , pretty_print = True ) mdString = mdString . replace ( 'xmlns="urn:oasis:names:tc:SAML:2.0:metadata"' , 'xmlns="urn:oasis:names:tc:SAML:2.0:metadata"' + ' ' + shibNameSpace ) mdString = mdString . replace ( '<IDPSSODescriptor' , extensions + '<IDPSSODescriptor' ) except Exception , e : print ( e ) return mdString
Modifies ADFS metadata removing and inserting elements in order to avoid parsing problems on Shibboleth-side
Modifies ADFS metadata removing and inserting elements in order to avoid parsing problems on Shibboleth - side
"""
	Modifies ADFS metadata removing and inserting elements in order to avoid parsing problems on Shibboleth-side
	""" # get metadata # remove signature, RoleDescriptor and SPSSODescriptor elements in order to avoid incompatibilities with # the Switch WAYF shipped parser # add SAML1 SingleSignOn binding, in order to avoid Switch WAYF limitation (without this the IdP # configuration will not be loaded # add scope extension
idpUrl
scope