Eolisation de l'applicatif MSE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

certificates.py 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # -*- coding: utf-8 -*-
  2. def getIDPCert(idp_url, key_type):
  3. # Import modules
  4. from xml.dom import minidom
  5. import urllib2
  6. import re
  7. import yaml
  8. try:
  9. dom = minidom.parse(urllib2.urlopen(idp_url))
  10. keyDescriptors = dom.getElementsByTagName('KeyDescriptor');
  11. except:
  12. return ""
  13. res = "\n"
  14. for i, keyDescriptor in enumerate(keyDescriptors, start=1):
  15. if keyDescriptor.getAttribute('use') == key_type:
  16. X509Certificates = keyDescriptor.getElementsByTagName('ds:X509Certificate')
  17. for i, X509Certificate in enumerate(X509Certificates, start=1):
  18. resTmp = re.sub(r"[\n\t\s]*", "", X509Certificate.firstChild.nodeValue)
  19. resTmp = " - " + resTmp + " \n"
  20. res += resTmp
  21. res += "\n"
  22. return res
  23. def getEOLECert(eole_cert_path, output_path):
  24. import re
  25. f = open(eole_cert_path, 'r')
  26. r = open(output_path, 'w')
  27. for i, line in enumerate(f):
  28. if not line.startswith('--'):
  29. r.write(line)
  30. r.close()
  31. f.close()
  32. r = open(output_path, 'r')
  33. res = r.read()
  34. res = re.sub(r"[\n\t\s]*", "", res)
  35. r.close()
  36. return res