summaryrefslogtreecommitdiffstats
path: root/virtualenv/pffedportal
diff options
context:
space:
mode:
authorThomas NOEL <tnoel@entrouvert.com>2013-12-24 12:16:26 (GMT)
committerThomas NOEL <tnoel@entrouvert.com>2013-12-24 12:16:26 (GMT)
commit705fb7ca09e5586fe0ab0752e5ca1f77536a0b67 (patch)
tree39b866fc1fbb0a3ea093747e01adf00a3e891f5a /virtualenv/pffedportal
parent12e181eccc5d09363817d86afc3e8617d22fae91 (diff)
downloadunivnautes-old-705fb7ca09e5586fe0ab0752e5ca1f77536a0b67.zip
univnautes-old-705fb7ca09e5586fe0ab0752e5ca1f77536a0b67.tar.gz
univnautes-old-705fb7ca09e5586fe0ab0752e5ca1f77536a0b67.tar.bz2
get idp name from mdui:displayname (hack)
Diffstat (limited to 'virtualenv/pffedportal')
-rwxr-xr-xvirtualenv/pffedportal/create_loginhtml.py48
1 files changed, 37 insertions, 11 deletions
diff --git a/virtualenv/pffedportal/create_loginhtml.py b/virtualenv/pffedportal/create_loginhtml.py
index 8d74cbb..75c2880 100755
--- a/virtualenv/pffedportal/create_loginhtml.py
+++ b/virtualenv/pffedportal/create_loginhtml.py
@@ -9,7 +9,9 @@ output a merge of idp + geo informations from discojuice
import os
os.environ['DJANGO_SETTINGS_MODULE'] = "settings"
-from authentic2.saml.common import get_idp_list_sorted
+from authentic2.saml.models import LibertyProvider
+from xml.etree import ElementTree as ET
+from operator import itemgetter
import sys
import json
import math
@@ -46,18 +48,42 @@ for geofile in sys.argv[1:]:
geo_idps.update(geo2idp(geofile))
-print """{% extends "login0.html" %}
-{% block idps %}
-"""
+def get_ui_displayname(provider):
+ def get_first_child(xml, child):
+ for c in xml:
+ if c.tag.endswith(child):
+ return c
+ return None
+ xml = ET.fromstring(provider.metadata.encode('utf-8'))
+ for tag in ('IDPSSODescriptor', 'Extensions', 'UIInfo', 'DisplayName'):
+ xml = get_first_child(xml, tag)
+ if xml is None:
+ return provider.name
+ return xml.text
+
+
n = 0
-for idp in get_idp_list_sorted():
+idps = []
+for provider in LibertyProvider.objects.all():
n += 1
- entity_id = idp['entity_id']
- name = idp['name']
- geo = geo_idps.get(entity_id, {}).get('geo', { 'lat': 47.0 + 2.0*math.sin(n), 'lon': 2.5 + 3.0*math.cos(n) })
- href = '/sso?' + urllib.urlencode([('entity_id', entity_id)])
- li = u'<li><a href="%s" class="idplink" data-lat="%s" data-lon="%s" data-entityid="%s" data-filtertext="%s">%s</a></li>' % \
- (href, geo['lat'], geo['lon'], entity_id, name, name)
+ geo = geo_idps.get(provider.entity_id, {}).get('geo',
+ {'lat': 47.0+2.0*math.sin(n), 'lon': 2.5+3.0*math.cos(n)})
+ idps.append({
+ 'entityid': provider.entity_id,
+ 'name': get_ui_displayname(provider),
+ 'lat': geo['lat'],
+ 'lon': geo['lon'],
+ 'href': '/sso?' + urllib.urlencode([('entity_id', provider.entity_id)]),
+ })
+
+print """{% extends "login0.html" %}
+{% block idps %}"""
+
+for idp in sorted(idps, key=itemgetter('name')):
+ li = u'<li><a href="%(href)s" class="idplink" ' \
+ 'data-lat="%(lat)s" data-lon="%(lon)s" ' \
+ 'data-entityid="%(entityid)s" ' \
+ 'data-filtertext="%(name)s">%(name)s</a></li>' % idp
print li.encode("utf-8")
print "{% endblock %}"