Started to add code for using MongoDB as backend store.

This commit is contained in:
Roland Hedberg
2013-03-05 09:31:54 +01:00
parent 7c3691c62b
commit ff6d96e990

View File

@@ -86,10 +86,12 @@ class Server(Entity):
# default database is a shelve database which is OK in some setups
dbspec = self.config.getattr("subject_data", "idp")
idb = None
if isinstance(dbspec, basestring):
if not dbspec:
pass
elif isinstance(dbspec, basestring):
idb = shelve.open(dbspec, writeback=True)
else: # database spec is a a 2-tuple (type, address)
print >> sys.stderr, "DBSPEC: %s" % dbspec
print >> sys.stderr, "DBSPEC: %s" % (dbspec,)
(typ, addr) = dbspec
if typ == "shelve":
idb = shelve.open(addr, writeback=True)
@@ -97,6 +99,10 @@ class Server(Entity):
idb = memcache.Client(addr)
elif typ == "dict": # in-memory dictionary
idb = addr
elif typ == "mongodb":
from mongodict import MongoDict
idb = MongoDict(host='localhost', port=27017,
database=addr, collection='store')
if idb is not None:
self.ident = IdentDB(idb)
@@ -150,7 +156,6 @@ class Server(Entity):
return self._parse_request(xml_string, AttributeQuery,
"attribute_service", binding)
def parse_authz_decision_query(self, xml_string, binding):
""" Parse an attribute query
@@ -236,7 +241,8 @@ class Server(Entity):
if statement.session_index != session_index:
continue
if requested_context:
if not context_match(requested_context, statement.authn_context):
if not context_match(requested_context,
statement.authn_context):
continue
result.append(statement)
@@ -387,7 +393,6 @@ class Server(Entity):
# Just the assertion or the response and the assertion ?
to_sign = [(class_name(assertion), assertion.id)]
args["assertion"] = assertion
return self._response(in_response_to, destination, status, issuer,
@@ -424,7 +429,8 @@ class Server(Entity):
nid_formats = []
for _sp in self.metadata[sp_entity_id]["spsso_descriptor"]:
if "name_id_format" in _sp:
nid_formats.extend([n["text"] for n in _sp["name_id_format"]])
nid_formats.extend([n["text"] for n in
_sp["name_id_format"]])
name_id = self.ident.construct_nameid(userid, policy,
sp_entity_id,