add: Allow caller to supply unique reference.

Being able to specify reference is useful to ensure consistency
during upgrades in a cluster of IdP:s.
This commit is contained in:
Fredrik Thulin
2013-09-27 16:19:49 +02:00
parent 74ec4a2162
commit 95db3577ec

View File

@@ -48,7 +48,7 @@ class AuthnBroker(object):
def better(self, a, b):
return b > a
def add(self, spec, method, level=0, authn_authority=""):
def add(self, spec, method, level=0, authn_authority="", reference=None):
"""
Adds a new authentication method.
Assumes not more than one authentication method per AuthnContext
@@ -58,6 +58,7 @@ class AuthnBroker(object):
of an AuthnContext
:param method: A identifier of the authentication method.
:param level: security level, positive integers, 0 is lowest
:param reference: Desired unique reference to this spec
:return:
"""
@@ -81,7 +82,9 @@ class AuthnBroker(object):
raise NotImplementedError()
self.next += 1
_ref = str(self.next)
_ref = reference
if _ref is None:
_ref = str(self.next)
self.db["info"][_ref] = _info
try:
self.db["key"][key].append(_ref)