|
33 |
|
33 |
|
34 |
import os |
34 |
import os |
35 |
from glob import glob |
35 |
from glob import glob |
36 |
from subprocess import call |
36 |
from subprocess import call, Popen |
37 |
from time import sleep |
37 |
from time import sleep |
38 |
from urlparse import urlparse |
38 |
from urlparse import urlparse |
39 |
from defusedxml import ElementTree |
39 |
from defusedxml import ElementTree |
Lines 86-103
def download_idp_metadata(metadata):
|
Link Here
|
---|
|
86 |
filename = '/usr/share/univention-management-console/saml/idp/%s.xml' % (idp,) |
86 |
filename = '/usr/share/univention-management-console/saml/idp/%s.xml' % (idp,) |
87 |
for i in range(0, 60): |
87 |
for i in range(0, 60): |
88 |
print 'Try to download idp metadata (%s/60)' % (i + 1) |
88 |
print 'Try to download idp metadata (%s/60)' % (i + 1) |
89 |
rc = call([ |
89 |
p = Popen([ |
90 |
'/usr/bin/curl', |
90 |
'/usr/bin/curl', |
91 |
'--fail', |
91 |
'--fail', |
92 |
'--cacert', '/etc/univention/ssl/ucsCA/CAcert.pem', |
92 |
'--cacert', '/etc/univention/ssl/ucsCA/CAcert.pem', |
93 |
'-o', filename, |
93 |
'-o', filename, |
94 |
metadata, |
94 |
metadata, |
95 |
]) |
95 |
], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True) |
96 |
if rc and os.path.exists(filename): |
96 |
stdout, stderr = p.communicate() |
|
|
97 |
if p.returncode and os.path.exists(filename): |
97 |
os.remove(filename) |
98 |
os.remove(filename) |
98 |
if rc == 0: |
99 |
if p.returncode == 0: |
99 |
return True |
100 |
return True |
100 |
sleep(1) |
101 |
sleep(1) |
|
|
102 |
print stdout |
101 |
return False |
103 |
return False |
102 |
|
104 |
|
103 |
|
105 |
|