Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

skolfederation links

  • Loading branch information...
commit b107cfa5417bb6ea0177d1671c27bf5494e5d635 1 parent 6560c6a
@leifj authored
View
35 examples/links.xrd
@@ -39,8 +39,41 @@
</XRD -->
<XRD>
<Subject>Skolfederation</Subject>
- <Link rel="urn:oasis:names:tc:SAML:2.0:metadata" href="http://md.skolfederation.se/md/skolfederation-1.0.xml">
+ <Link rel="urn:oasis:names:tc:SAML:2.0:metadata" href="http://meta01.skolfederation.se/skolfederation-2_0.xml">
<Title>Skolfederation Metadata</Title>
+ <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
+ <ds:X509Data>
+ <ds:X509Certificate>
+MIIE+DCCAuACCQDz68MlqYKzETANBgkqhkiG9w0BAQUFADA+MQswCQYDVQQGEwJT
+RTEhMB8GA1UEAxMYbWV0YTAxLnNrb2xmZWRlcmF0aW9uLnNlMQwwCgYDVQQKEwNJ
+SVMwHhcNMTMwNDAzMTMxMDQ3WhcNMjMwNDAxMTMxMDQ3WjA+MQswCQYDVQQGEwJT
+RTEhMB8GA1UEAxMYbWV0YTAxLnNrb2xmZWRlcmF0aW9uLnNlMQwwCgYDVQQKEwNJ
+SVMwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAwggIKAoICAQDTugaeIk5XZlnMWBpj
+rJZRvwm2YItd4Hbx285//LL9k2HjYhLnWwfdjv0yZSCuw49E47FdhT5j3rnQJayQ
+ifKffn6M2jMnDZh9MYx8SjT/CMFid5TXVS5jFcEtfzYfSl9Fv8rqFAjJTDDroneT
+dnMVRlcW03XVDG1ryOou3W1pCrRRsHe+HHkpP3H4cL9pSaXgR9ptAadTHfzEFFnX
+qVwvSJD1SMK7+OvFUDQCnoKYEdyNpFfsouwtessXtq4jTOZdzjTxeLIrVnfFpVPf
+F2xN8298x3fCDeoUPjQKDNYYwNq5N4U7RnsM+KYjTQ8rLelOyP5hsy/wETtUJ5vR
+OAa6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mtGlRI0wxYt7B/Wfaal9/KMRTnYkoA==
+ </ds:X509Certificate>
+ </ds:X509Data>
+ </ds:KeyInfo>
</Link>
</XRD>
</XRDS>
View
4 examples/mdx.fd
@@ -25,8 +25,8 @@
- http://pyff-project.org/collection=swamid-2.0
- break
- fork:
- - select as /md/skolfederation-1.0:
- - http://md.skolfederation.se/md/skolfederation-1.0.xml
+ - select as /md/skolfederation-2.0:
+ - http://meta01.skolfederation.se/skolfederation-2_0.xml
- break
- fork:
- select as /md/swamid-kalmar-1.0:
View
65 src/pyff/mdrepo.py
@@ -8,14 +8,12 @@
import hashlib
import urllib
from UserDict import DictMixin, UserDict
-import urlparse
from lxml import etree
from lxml.builder import ElementMaker
from lxml.etree import DocumentInvalid
import os
import re
from copy import deepcopy
-from publicsuffix import PublicSuffixList
from pyff import merge_strategies
import pyff.index
from pyff.logs import log
@@ -86,7 +84,6 @@ def __init__(self, index=pyff.index.MemoryIndex(), metadata_cache_enabled=False,
self.respect_cache_duration = True
self.default_cache_duration = "PT10M"
self.retry_limit = 5
- self.psl = PublicSuffixList()
super(MDRepository, self).__init__()
@@ -131,7 +128,7 @@ def __iter__(self):
def sha1_id(self, e):
return pyff.index.hash_id(e, 'sha1')
- def search(self, query=None, path=None, page=None, page_limit=10, suggest=None, entity_filter=None, client_ip=None):
+ def search(self, query=None, path=None, page=None, page_limit=10, entity_filter=None):
"""
:param query: A string to search for.
:param path: The repository collection (@Name) to search in - None for search in all collections
@@ -150,34 +147,9 @@ def search(self, query=None, path=None, page=None, page_limit=10, suggest=None,
:param id: A sha1-ID of the entityID - on the form {sha1}<sha1-hash-of-entityID>
"""
- def _tokenize(url):
- if "://" in url:
- url = urlparse.urlparse(url)
- host = url.netloc
- if ':' in url.netloc:
- (host, port) = url.netloc.split(':')
- return filter(lambda x: len(x) > 0, host.rstrip(self.psl.get_public_suffix(host)).split('.'))
- else:
- return []
-
- log.debug("suggest: %s" % suggest)
- log.debug("client_ip: %s" % client_ip)
-
if isinstance(query, basestring):
query = [query.lower()]
- if isinstance(client_ip, basestring):
- client_ip = [client_ip]
-
- if query is None or len(query) == 0:
- ql = []
- if suggest is not None and len(suggest) > 0:
- for u in suggest:
- ql.extend(_tokenize(u))
- query = ql
-
- log.debug("query: %s" % query)
-
def _lc_text(e):
if e.text is None:
return None
@@ -195,21 +167,25 @@ def _strings(elt):
return filter(lambda s: s is not None, lst)
def _ip_networks(elt):
- return [ipaddr.IPNetwork(x.text) for x in elt.findall('.//{%s}IPHInt' % NS['mdui'])]
-
- def _match(qq, addrs, elt):
- for qstr in _strings(elt):
- for q in qq:
+ return [ipaddr.IPNetwork(x.text) for x in elt.findall('.//{%s}IPHint' % NS['mdui'])]
+
+ def _match(qq, elt):
+ for q in qq:
+ if ':' in q or '.' in q:
+ nets = _ip_networks(elt)
+ try:
+ for net in nets:
+ if ':' in q and ipaddr.IPv6Address(q) in net:
+ return True
+ if '.' in q and ipaddr.IPv4Address(q) in net:
+ return True
+ except ValueError, ex:
+ pass
+ tokens = _strings(elt)
+ for qstr in tokens:
#log.debug("looking for '%s' in '%s'" % (q, qstr))
if q is not None and len(q) > 0 and q in qstr:
return True
-
- if addrs is not None and len(addrs) > 0:
- for net in _ip_networks(elt):
- for ip in [ipaddr.IPAddress(x) for x in addrs]:
- log.debug("looking for %s in %s" % (ip,net))
- if ip in net:
- return True
return False
f = []
@@ -221,15 +197,16 @@ def _match(qq, addrs, elt):
if f:
mexpr = "+".join(f)
- log.debug("mexpr: %s" % mexpr)
+ log.debug("match using '%s'" % mexpr)
res = [{'label': self.display(e),
'value': e.get('entityID'),
+ 'tokens': _strings(e),
'id': pyff.index.hash_id(e, 'sha1')}
- for e in pyff.index.EntitySet(filter(lambda ent: _match(query, client_ip, ent), self.lookup(mexpr)))]
+ for e in pyff.index.EntitySet(filter(lambda ent: _match(query, ent), self.lookup(mexpr)))]
res.sort(key=lambda i: i['label'])
- log.debug(res)
+ log.debug("search returning %s" % res)
if page is not None:
total = len(res)
View
45 src/pyff/mdx.py
@@ -70,6 +70,7 @@
from datetime import datetime
from lxml import etree
from pyff import __version__ as pyff_version
+from publicsuffix import PublicSuffixList
__author__ = 'leifj'
@@ -398,6 +399,7 @@ def __init__(self,
self.refresh.subscribe()
self.aliases = aliases
self.observers = observers
+ self.psl = PublicSuffixList()
if autoreload:
for f in pipes:
@@ -417,6 +419,10 @@ def new_repository(self, observers=[]):
return MDRepository(metadata_cache_enabled=self.cache_enabled)
class MediaAccept():
+
+ def __init__(self):
+ pass
+
def has_key(self, key):
return True
@@ -438,8 +444,6 @@ def request(self, **kwargs):
path = kwargs.get('path', None)
content_type = kwargs.get('content_type', None)
- log.debug("request pfx=%s, path=%s, content_type=%s" % (pfx, path, content_type))
-
def escape(m):
st = m.group(0)
if st == '<':
@@ -456,8 +460,8 @@ def _d(x):
x = x[8:].decode('base64')
if '.' in x:
- (p, sep, ext) = x.rpartition('.')
- return p, ext
+ (pth, sep, extn) = x.rpartition('.')
+ return pth, extn
else:
return x, None
@@ -481,8 +485,8 @@ def _d(x):
else:
q = path
- log.debug("request %s %s" % (path, ext))
- log.debug(cherrypy.request.headers)
+ log.debug("request path: %s, ext: %s, headers: %s" % (path, ext, cherrypy.request.headers))
+
accept = {}
if content_type is None:
if ext is not None and ext in _ctypes:
@@ -496,10 +500,10 @@ def _d(x):
with self.lock.readlock:
if ext == 'ds':
pdict = dict()
- entityID = kwargs.get('entityID', None)
- if entityID is None:
+ entity_id = kwargs.get('entityID', None)
+ if entity_id is None:
raise HTTPError(400, "400 Bad Request - missing entityID")
- pdict['sp'] = self.md.sha1_id(entityID)
+ pdict['sp'] = self.md.sha1_id(entity_id)
pdict['ret'] = kwargs.get('return', None)
if not path:
pdict['search'] = "/search/"
@@ -516,24 +520,35 @@ def _d(x):
page = kwargs.get('page', 0)
page_limit = kwargs.get('page_limit', 10)
entity_filter = kwargs.get('entity_filter', None)
- suggest = kwargs.get('suggest', None)
cherrypy.response.headers['Content-Type'] = 'application/json'
+
+ if query is None:
+ log.debug("empty query - creating one")
+ query = [cherrypy.request.remote.ipgit]
+ referrer = cherrypy.request.headers.get('referrer', None)
+ if referrer is not None:
+ log.debug("including referrer: %s" % referrer)
+ url = urlparse.urlparse(referrer)
+ host = url.netloc
+ if ':' in url.netloc:
+ (host, port) = url.netloc.split(':')
+ for host_part in host.rstrip(self.psl.get_public_suffix(host)).split('.'):
+ if host_part is not None and len(host_part) > 0:
+ query.append(host_part)
+ log.debug("created query: %s" % ",".join(query))
+
if paged:
res, more, total = self.md.search(query,
path=q,
page=int(page),
page_limit=int(page_limit),
- suggest=suggest,
- client_ip=cherrypy.request.remote.ip,
entity_filter=entity_filter)
- log.debug(dumps({'entities': res, 'more': more, 'total': total}))
+ #log.debug(dumps({'entities': res, 'more': more, 'total': total}))
return dumps({'entities': res, 'more': more, 'total': total})
else:
return dumps(self.md.search(query,
path=q,
- suggest=suggest,
- client_ip=cherrypy.request.remote.ip,
entity_filter=entity_filter))
elif accept.get('text/html'):
if not q:
View
64 src/pyff/site/static/js/pyff.js
@@ -97,6 +97,7 @@
seldiv.typeahead({
remote: uri+"?query=%QUERY&entity_filter={http://pyff-project.org/role}idp",
engine: Hogan,
+ limit: 10,
template: '{{label}}'
});
seldiv.bind('typeahead:selected',function(event,entity) {
@@ -166,52 +167,35 @@
$.fn.dsQuickLinks = function(id) {
this.each(function() {
- var div = $(this);
- var uri = div.attr('data-target');
+ var outer = $(this);
+ var uri = outer.attr('data-target');
+ var div = $('<div>').addClass("list-group");
+ outer.html(div);
- div.html($('<div>').addClass("list-group").append(function() {
+ var from_storage = 0;
+ div.append(function() {
var lst = $.jStorage.get('pyff.discovery.idps',[]);
for (var i = 0; i < lst.length; i++) {
- $(this).append(idp_template.render(lst[i]));
+ div.append(idp_template.render(lst[i]));
+ from_storage++;
}
- }));
-
- $.getJSON(uri+"?suggest="+id+"&suggest="+document.referrer+"&entity_filter={http://pyff-project.org/role}idp",function (data) {
- $.each(function(pos,elt) {
- elt.sticky = true
- $(this).append(idp_template.render(elt));
- });
});
- });
- };
-
- $.fn.dsQuickLinks2 = function() {
- this.each(function() {
- var $this = $(this);
- $this.html($('<div>').addClass("list-group").append(function() {
- var lst = $.jStorage.get('pyff.discovery.idps',[]);
- for (var i = 0; i < lst.length; i++) {
- var item = lst[i];
- var idp = $('<a>').addClass("select list-group-item").attr('href',item['entityID']);
- var dismiss = $('<button>').attr('type',"button").addClass('close unselect').attr('rel',item['entityID']).append("&times;");
- idp.append(dismiss);
- idp.append($('<h4>').addClass("list-group-item-heading").append(item['title']));
- var inner = $('<p>').addClass("list-group-item-text");
-
- if (item['icon']) {
- inner.append($('<img>').attr('src',item['icon']).addClass("fallback-icon hidden-xs idp-icon pull-right img-responsive img-thumbnail"));
- }
- if (item['descr']) {
- inner.append($('<div>').addClass('pull-left idp-description hidden-xs').append(item['descr']))
- }
-
- inner.append($('<div></div>').addClass("clearfix"));
- idp.append(inner);
-
- $(this).append(idp);
- }
- }));
+ if (from_storage == 0) {
+ $.getJSON(uri+"?entity_filter={http://pyff-project.org/role}idp", function (data) {
+ $.each(data,function(pos,elt) {
+ if (pos < 3) {
+ $.getJSON("/metadata/"+elt.id+".json", function (entites) {
+ $.each(entites,function(ipos,entity) {
+ console.log(entity);
+ entity.sticky = true
+ div.append(idp_template.render(entity));
+ })
+ });
+ }
+ });
+ });
+ }
});
};
View
9 src/pyff/utils.py
@@ -349,10 +349,15 @@ def _l(elt):
else:
return elts
+_xslt = dict()
+
def xslt_transform(t, stylesheet, params={}):
- xsl = etree.fromstring(resource_string(stylesheet, "xslt"))
- transform = etree.XSLT(xsl)
+ transform = None
+ if not stylesheet in _xslt:
+ xsl = etree.fromstring(resource_string(stylesheet, "xslt"))
+ _xslt[stylesheet] = etree.XSLT(xsl)
+ transform = _xslt[stylesheet]
return transform(t, **params)
Please sign in to comment.
Something went wrong with that request. Please try again.