summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland Hedberg <roland.hedberg@adm.umu.se>2013-04-10 19:26:36 +0200
committerRoland Hedberg <roland.hedberg@adm.umu.se>2013-04-10 19:26:36 +0200
commit897a70da4fb7e4206b92ec899095b926dc7f7c52 (patch)
tree707fa6c54c412865e93650241c6d5d5cf9ceb281
parentf455330b38e3891949fce61df1e240e8d0d180b4 (diff)
downloadpysaml2-897a70da4fb7e4206b92ec899095b926dc7f7c52.tar.gz
MongoDB based identity cache.
-rw-r--r--src/saml2/mdbcache.py28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/saml2/mdbcache.py b/src/saml2/mdbcache.py
index 452c727f..2f5d9c45 100644
--- a/src/saml2/mdbcache.py
+++ b/src/saml2/mdbcache.py
@@ -64,7 +64,8 @@ class Cache(object):
else:
for entity_id in entities:
try:
- info = self.get(subject_id, entity_id, check_not_on_or_after)
+ info = self.get(subject_id, entity_id,
+ check_not_on_or_after)
except ToOld:
oldees.append(entity_id)
continue
@@ -125,7 +126,6 @@ class Cache(object):
_ = self._cache.insert(doc)
-
def reset(self, subject_id, entity_id):
""" Scrap the assertions received from a IdP or an AA about a special
subject.
@@ -134,9 +134,8 @@ class Cache(object):
:param entity_id: The identifier of the entity_id of the assertion
:return:
"""
- self._cache.update({"subject_id":subject_id,
- "entity_id":entity_id},
- {"$set": {"info":{}, "timestamp": 0}})
+ self._cache.update({"subject_id": subject_id, "entity_id": entity_id},
+ {"$set": {"info": {}, "timestamp": 0}})
def entities(self, subject_id):
""" Returns all the entities of assertions for a subject, disregarding
@@ -151,7 +150,6 @@ class Cache(object):
except ValueError:
return []
-
def receivers(self, subject_id):
""" Another name for entities() just to make it more logic in the IdP
scenario """
@@ -166,8 +164,8 @@ class Cache(object):
valid or not.
"""
- item = self._cache.find_one({"subject_id":subject_id,
- "entity_id":entity_id})
+ item = self._cache.find_one({"subject_id": subject_id,
+ "entity_id": entity_id})
try:
return time_util.not_on_or_after(item["timestamp"])
except ToOld:
@@ -185,19 +183,17 @@ class Cache(object):
def update(self, subject_id, entity_id, ava):
""" """
- item = self._cache.find_one({"subject_id":subject_id,
- "entity_id":entity_id})
+ item = self._cache.find_one({"subject_id": subject_id,
+ "entity_id": entity_id})
info = item["info"]
info["ava"].update(ava)
- self._cache.update({"subject_id":subject_id,
- "entity_id":entity_id},
- {"$set": {"info":info}})
+ self._cache.update({"subject_id": subject_id, "entity_id": entity_id},
+ {"$set": {"info": info}})
def valid_to(self, subject_id, entity_id, newtime):
""" """
- self._cache.update({"subject_id":subject_id,
- "entity_id":entity_id},
- {"$set": {"timestamp": newtime}})
+ self._cache.update({"subject_id": subject_id, "entity_id": entity_id},
+ {"$set": {"timestamp": newtime}})
def clear(self):
self._cache.remove() \ No newline at end of file