summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorEmmanuel Raviart <eraviart@entrouvert.com>2004-08-02 17:26:28 +0000
committerEmmanuel Raviart <eraviart@entrouvert.com>2004-08-02 17:26:28 +0000
commitefac509926916c022171cef2e04303e645127b0d (patch)
tree909c6e27046b0d00aa6e1dcd860090ac4dd458a1 /python
parentcc83fab4cff86d62e6ad0cb9661b0463b7e0464d (diff)
downloadlasso-efac509926916c022171cef2e04303e645127b0d.tar.gz
lasso-efac509926916c022171cef2e04303e645127b0d.tar.xz
lasso-efac509926916c022171cef2e04303e645127b0d.zip
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() ).
Diffstat (limited to 'python')
-rw-r--r--python/examples/defederation.py1
-rw-r--r--python/examples/login.py2
-rw-r--r--python/examples/logout.py2
-rw-r--r--python/examples/mapping.py2
-rw-r--r--python/examples/registration.py2
-rwxr-xr-xpython/examples/test.py2
-rw-r--r--python/examples/user.py2
-rw-r--r--python/lasso.py15
-rw-r--r--python/tests/login_tests.py1
9 files changed, 15 insertions, 14 deletions
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 = "<LassoUser><LassoIdentities><LassoIdentity RemoteProviderID=\"htt
idpuser_dump = "<LassoUser><LassoIdentities><LassoIdentity RemoteProviderID=\"https://service-provider:2003/liberty-alliance/metadata\"><LassoLocalNameIdentifier><NameIdentifier NameQualifier=\"qualifier.com\" Format=\"federated\">1111111111111111111111111</NameIdentifier></LassoLocalNameIdentifier></LassoIdentity></LassoIdentities></LassoUser>"
-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 = """<LassoAssertions><LassoAssertion RemoteProviderID="https://service-provider1:2003/liberty-alliance/metadata"><Assertion AssertionID="1234567890"></Assertion></LassoAssertion><LassoAssertion RemoteProviderID="https://service-provider2:2003/liberty-alliance/metadata"><Assertion AssertionID="1234567890"></Assertion></LassoAssertion><LassoAssertion RemoteProviderID="https://service-provider3:2003/liberty-alliance/metadata"><Assertion AssertionID="1234567890"></Assertion></LassoAssertion></LassoAssertions>"""
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):