From efac509926916c022171cef2e04303e645127b0d Mon Sep 17 00:00:00 2001 From: Emmanuel Raviart Date: Mon, 2 Aug 2004 17:26:28 +0000 Subject: Check that Lasso is inited and shotdown only once. Lasso Python modules now calls init() at first import (I need this behaviour, because I have several "import lasso" in Expression and I don't know which one will be called first and I don't want to do something like: import lasso if not lasso.inited: lasso.init() ). --- python/examples/defederation.py | 1 - python/examples/login.py | 2 -- python/examples/logout.py | 2 -- python/examples/mapping.py | 2 -- python/examples/registration.py | 2 -- python/examples/test.py | 2 -- python/examples/user.py | 2 -- python/lasso.py | 15 +++++++++++++++ python/tests/login_tests.py | 1 - 9 files changed, 15 insertions(+), 14 deletions(-) (limited to 'python') diff --git a/python/examples/defederation.py b/python/examples/defederation.py index b97a6c3e..34d060c1 100644 --- a/python/examples/defederation.py +++ b/python/examples/defederation.py @@ -9,7 +9,6 @@ spuser_dump = "1111111111111111111111111" -lasso.init() # SP : spserver = lasso.Server.new("../../examples/sp.xml", diff --git a/python/examples/login.py b/python/examples/login.py index 2f7d1d81..b379ab02 100644 --- a/python/examples/login.py +++ b/python/examples/login.py @@ -7,8 +7,6 @@ import string import lasso -lasso.init() - #################### # Service provider # #################### diff --git a/python/examples/logout.py b/python/examples/logout.py index 131e0e62..b8e86431 100644 --- a/python/examples/logout.py +++ b/python/examples/logout.py @@ -4,8 +4,6 @@ import sys sys.path.insert(0, '../') import lasso -lasso.init() - # SP1 server and user : sp1server = lasso.Server.new("../../examples/sp1.xml", "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", diff --git a/python/examples/mapping.py b/python/examples/mapping.py index bde6ec57..5a71abfc 100644 --- a/python/examples/mapping.py +++ b/python/examples/mapping.py @@ -4,8 +4,6 @@ import sys sys.path.insert(0, '../') import lasso -lasso.init() - req = lasso.NameIdentifierMappingRequest.new("http://providerid.com", "CDSC7SCD65SCDSDCCDS", "http://qualifier.com", "federated") print 'dump req : ', req.dump() diff --git a/python/examples/registration.py b/python/examples/registration.py index de922cde..23d2fb8d 100644 --- a/python/examples/registration.py +++ b/python/examples/registration.py @@ -4,8 +4,6 @@ import sys sys.path.insert(0, '../') import lasso -lasso.init() - # servers : spserver = lasso.Server.new("../../examples/sp.xml", "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", diff --git a/python/examples/test.py b/python/examples/test.py index 9f4ada8f..03541eca 100755 --- a/python/examples/test.py +++ b/python/examples/test.py @@ -5,8 +5,6 @@ import sys sys.path.insert(0, '../') import lasso -lasso.init() - # creation d'une AuthnRequest req = lasso.AuthnRequest("http://providerid.com") req.set_forceAuthn(0) diff --git a/python/examples/user.py b/python/examples/user.py index f03761b5..0aa641de 100644 --- a/python/examples/user.py +++ b/python/examples/user.py @@ -4,8 +4,6 @@ import sys sys.path.insert(0, '../') import lasso -lasso.init() - lasso_assertions = """""" diff --git a/python/lasso.py b/python/lasso.py index ed58c01f..4d317feb 100644 --- a/python/lasso.py +++ b/python/lasso.py @@ -29,6 +29,8 @@ __docformat__ = "plaintext en" import lassomod from lasso_strings import * +_inited = False + class Error(Exception): def __init__(self, msg): self.msg = msg @@ -39,14 +41,23 @@ def init(): """ Init Lasso Library. """ + global _inited + if _inited: + raise Error('Lasso already inited') + _inited = True return lassomod.init() def shutdown(): """ Shutdown Lasso Library. """ + global _inited + if not _inited: + raise Error('Lasso not inited or already shotdown') + _inited = False return lassomod.shutdown() + ################################################################################ # xml : low level classes ################################################################################ @@ -1221,3 +1232,7 @@ class Lecp: def process_authn_response_envelope_msg(self, response_msg): return lassomod.lecp_process_authn_response_envelope_msg(self, response_msg) + + +if not _inited: + init() diff --git a/python/tests/login_tests.py b/python/tests/login_tests.py index 872610a2..26f79cb4 100644 --- a/python/tests/login_tests.py +++ b/python/tests/login_tests.py @@ -34,7 +34,6 @@ sys.path.insert(0, '../.libs') import lasso -lasso.init() class LoginTestCase(unittest.TestCase): -- cgit