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