diff options
author | Emmanuel Raviart <eraviart@entrouvert.com> | 2005-01-26 14:35:05 +0000 |
---|---|---|
committer | Emmanuel Raviart <eraviart@entrouvert.com> | 2005-01-26 14:35:05 +0000 |
commit | 46db75a3beebca75dd659c7415fe1269b86cc8b5 (patch) | |
tree | 7c3853a8e0661c78b6ac9e70609956f0bf639705 /python/examples | |
parent | 10d94be454ae5b428e3301aa64dd4edaae44c425 (diff) | |
download | lasso-46db75a3beebca75dd659c7415fe1269b86cc8b5.tar.gz lasso-46db75a3beebca75dd659c7415fe1269b86cc8b5.tar.xz lasso-46db75a3beebca75dd659c7415fe1269b86cc8b5.zip |
Removed obsolete Python sample code.
Diffstat (limited to 'python/examples')
-rw-r--r-- | python/examples/.cvsignore | 2 | ||||
-rw-r--r-- | python/examples/Makefile.am | 8 | ||||
-rw-r--r-- | python/examples/defederation.py | 44 | ||||
-rw-r--r-- | python/examples/login.py | 100 | ||||
-rw-r--r-- | python/examples/logout.py | 85 | ||||
-rw-r--r-- | python/examples/mapping.py | 36 | ||||
-rw-r--r-- | python/examples/registration.py | 41 | ||||
-rwxr-xr-x | python/examples/test.py | 83 | ||||
-rw-r--r-- | python/examples/user.py | 47 |
9 files changed, 0 insertions, 446 deletions
diff --git a/python/examples/.cvsignore b/python/examples/.cvsignore deleted file mode 100644 index 282522db..00000000 --- a/python/examples/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/python/examples/Makefile.am b/python/examples/Makefile.am deleted file mode 100644 index acb93a16..00000000 --- a/python/examples/Makefile.am +++ /dev/null @@ -1,8 +0,0 @@ -EXTRA_DIST = \ - defederation.py \ - login.py \ - logout.py \ - mapping.py \ - registration.py \ - test.py \ - user.py diff --git a/python/examples/defederation.py b/python/examples/defederation.py deleted file mode 100644 index 0b709575..00000000 --- a/python/examples/defederation.py +++ /dev/null @@ -1,44 +0,0 @@ -#! /usr/bin/env python - -import sys -sys.path.insert(0, '../') -import lasso - - -spidentity_dump = "<LassoIdentity><LassoFederations><LassoFederation RemoteProviderID=\"https://identity-provider:2003/liberty-alliance/metadata\"><LassoRemoteNameIdentifier><NameIdentifier NameQualifier=\"qualifier.com\" Format=\"federated\">1111111111111111111111111</NameIdentifier></LassoRemoteNameIdentifier></LassoFederation></LassoFederations></LassoIdentity>" - -idpidentity_dump = "<LassoIdentity><LassoFederations><LassoFederation RemoteProviderID=\"https://service-provider:2003/liberty-alliance/metadata\"><LassoLocalNameIdentifier><NameIdentifier NameQualifier=\"qualifier.com\" Format=\"federated\">1111111111111111111111111</NameIdentifier></LassoLocalNameIdentifier></LassoFederation></LassoFederations></LassoIdentity>" - - -# SP : -spserver = lasso.Server.new("../../examples/sp.xml", - "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", - lasso.SIGNATURE_METHOD_RSA_SHA1) -spserver.add_provider("../../examples/idp.xml", None, None) - -spdefederation = lasso.FederationTermination.new(spserver, lasso.providerTypeSp) -spdefederation.set_identity_from_dump(spidentity_dump) -spdefederation.init_notification() -spdefederation.build_notification_msg() -print 'url : ', spdefederation.msg_url -print 'body : ', spdefederation.msg_body - -notification_msg = spdefederation.msg_body - - -# IDP : -idpserver = lasso.Server.new("../../examples/idp.xml", - "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", - lasso.SIGNATURE_METHOD_RSA_SHA1) -idpserver.add_provider("../../examples/sp.xml", None, None) - -idpdefederation = lasso.FederationTermination.new(idpserver, lasso.providerTypeIdp) -idpdefederation.process_notification_msg(notification_msg, lasso.HTTP_METHOD_SOAP) -print 'NameIdentifier :', idpdefederation.nameIdentifier - -idpdefederation.set_identity_from_dump(idpidentity_dump); -idpdefederation.validate_notification() - -print 'End of federation termination notification' - -lasso.shutdown() diff --git a/python/examples/login.py b/python/examples/login.py deleted file mode 100644 index 77a0cdd3..00000000 --- a/python/examples/login.py +++ /dev/null @@ -1,100 +0,0 @@ -#! /usr/bin/env python -# -*- coding: utf-8 -*- - -import sys -sys.path.insert(0, '../') -import string - -import lasso - -#################### -# Service provider # -#################### -server = lasso.Server.new("../../examples/sp.xml", - "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", - lasso.SIGNATURE_METHOD_RSA_SHA1) - -server.add_provider("../../examples/idp.xml", None, None) -server_dump = server.dump() -server.destroy() - -# create AuthnRequest -server = lasso.Server.new_from_dump(server_dump) -splogin = lasso.Login.new(server) -ret = splogin.init_authn_request("https://identity-provider:2003/liberty-alliance/metadata") -splogin.request.set_isPassive(0) -splogin.request.set_forceAuthn(1) -splogin.request.set_nameIDPolicy(lasso.libNameIDPolicyTypeFederated) -splogin.request.set_relayState("fake") -splogin.request.set_consent(lasso.LIB_CONSENT_OBTAINED) -splogin.request.set_protocolProfile(lasso.LIB_PROTOCOL_PROFILE_BRWS_ART) - -splogin.build_authn_request_msg() -print "message url =", splogin.msg_url - -##################### -# Identity provider # -##################### -server = lasso.Server.new("../../examples/idp.xml", - None, "../../examples/rsakey.pem", "../../examples/rootcert.pem", - lasso.SIGNATURE_METHOD_RSA_SHA1) - -server.add_provider("../../examples/sp.xml", - "../../examples/rsapub.pem", "../../examples/rsacert.pem") - -# create AuthnResponse OR artifact (depending ProtocolProfile) -idplogin = lasso.Login.new(server) - -# get query part in msg_url -authn_request_msg = string.split(splogin.msg_url, '?')[1] -ret = idplogin.init_from_authn_request_msg(authn_request_msg, - lasso.HTTP_METHOD_REDIRECT) - -print "ProtocolProfile =", idplogin.protocolProfile - -must_authenticate = idplogin.must_authenticate() -print "User must be authenticated =", must_authenticate - -if idplogin.protocolProfile == lasso.LOGIN_PROTOCOL_PROFILE_BRWS_ART: - ret = idplogin.build_artifact_msg(1, - lasso.SAML_AUTHENTICATION_METHOD_PASSWORD, - "", - lasso.HTTP_METHOD_REDIRECT) - print "ret = %d, msg_url = %s" % (ret, idplogin.msg_url) - sess = idplogin.get_session() - print sess.providerIDs - -#################### -# Service provider # -#################### -server = lasso.Server.new("../../examples/sp.xml", - "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", - lasso.SIGNATURE_METHOD_RSA_SHA1) - -server.add_provider("../../examples/idp.xml", None, None) - -# create Request OR finish (if an authnResponse was received) -splogin = lasso.Login.new(server) - -response_msg = string.split(idplogin.msg_url, '?')[1] -ret = splogin.init_request(response_msg, - lasso.HTTP_METHOD_REDIRECT) - -ret = splogin.build_request_msg() -print "ret = %d, msg_url = %s, msg_body = %s" % (ret, splogin.msg_url, splogin.msg_body) - -##################### -# Identity provider # -##################### -server = lasso.Server.new("../../examples/idp.xml", - None, "../../examples/rsakey.pem", "../../examples/rootcert.pem", - lasso.SIGNATURE_METHOD_RSA_SHA1) - -server.add_provider("../../examples/sp.xml", - "../../examples/rsapub.pem", "../../examples/rsacert.pem") - -# create Response -idplogin = lasso.Login.new(server) - -ret = idplogin.process_request_msg(splogin.msg_body) -print "samlp:AssertionArtifact = %s" % idplogin.assertionArtifact diff --git a/python/examples/logout.py b/python/examples/logout.py deleted file mode 100644 index 46113731..00000000 --- a/python/examples/logout.py +++ /dev/null @@ -1,85 +0,0 @@ -#! /usr/bin/env python - -import sys -sys.path.insert(0, '../') -import lasso - -# SP1 server and user : -sp1server = lasso.Server.new("../../examples/sp1.xml", - "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", - lasso.SIGNATURE_METHOD_RSA_SHA1) -sp1server.add_provider("../../examples/idp.xml", None, None) - -sp1user_dump = "<LassoUser><LassoAssertions><LassoAssertion RemoteProviderID=\"https://identity-provider:2003/liberty-alliance/metadata\"><Assertion AssertionID=\"C9DS8CD7CSD6CDSCKDKCS\"></Assertion></LassoAssertion></LassoAssertions><LassoIdentities><LassoIdentity RemoteProviderID=\"https://identity-provider:2003/liberty-alliance/metadata\"><LassoRemoteNameIdentifier><NameIdentifier NameQualifier=\"qualifier.com\" Format=\"federated\">11111111111111111111111111</NameIdentifier></LassoRemoteNameIdentifier></LassoIdentity></LassoIdentities></LassoUser>" - -# SP2 server and user : -sp2server = lasso.Server.new("../../examples/sp2.xml", - "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", - lasso.SIGNATURE_METHOD_RSA_SHA1) -sp2server.add_provider("../../examples/idp.xml", None, None) - -sp2user_dump = "<LassoUser><LassoAssertions><LassoAssertion RemoteProviderID=\"https://identity-provider:2003/liberty-alliance/metadata\"><Assertion AssertionID=\"4IK43JCJSDCSDKCSCSDL\"></Assertion></LassoAssertion></LassoAssertions><LassoIdentities><LassoIdentity RemoteProviderID=\"https://identity-provider:2003/liberty-alliance/metadata\"><LassoRemoteNameIdentifier><NameIdentifier NameQualifier=\"qualifier.com\" Format=\"federated\">222222222222222222222222</NameIdentifier></LassoRemoteNameIdentifier></LassoIdentity></LassoIdentities></LassoUser>" - -# IDP server and user : -idpserver = lasso.Server.new("../../examples/idp.xml", - "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", - lasso.SIGNATURE_METHOD_RSA_SHA1) -idpserver.add_provider("../../examples/sp1.xml", None, None) -idpserver.add_provider("../../examples/sp2.xml", None, None) -idpserver.add_provider("../../examples/sp3.xml", None, None) - -idpuser_dump = "<LassoUser><LassoAssertions><LassoAssertion RemoteProviderID=\"https://service-provider1:2003/liberty-alliance/metadata\"><Assertion AssertionID=\"C9DS8CD7CSD6CDSCKDKCS\"></Assertion></LassoAssertion><LassoAssertion RemoteProviderID=\"https://service-provider2:2003/liberty-alliance/metadata\"><Assertion AssertionID=\"4IK43JCJSDCSDKCSCSDL\"></Assertion></LassoAssertion></LassoAssertions><LassoIdentities><LassoIdentity RemoteProviderID=\"https://service-provider1:2003/liberty-alliance/metadata\"><LassoLocalNameIdentifier><NameIdentifier NameQualifier=\"qualifier.com\" Format=\"federated\">11111111111111111111111111</NameIdentifier></LassoLocalNameIdentifier></LassoIdentity><LassoIdentity RemoteProviderID=\"https://service-provider2:2003/liberty-alliance/metadata\"><LassoLocalNameIdentifier><NameIdentifier NameQualifier=\"qualifier.com\" Format=\"federated\">222222222222222222222222</NameIdentifier></LassoLocalNameIdentifier></LassoIdentity></LassoIdentities></LassoUser>" - - - -# SP1 build a request : -sp1user = lasso.User.new_from_dump(sp1user_dump) - -sp1logout = lasso.Logout.new(sp1server, lasso.providerTypeSp) - -sp1logout.set_user_from_dump(sp1user_dump) - -sp1logout.init_request() - -request = sp1logout.request -request.set_relayState("http://relaystate.com") - -sp1logout.build_request_msg() - -msg_url = sp1logout.msg_url -msg_body = sp1logout.msg_body - -sp1logout.destroy() - -# IDP process request and return a response : -idpuser = lasso.User.new_from_dump(idpuser_dump) -idplogout = lasso.Logout.new(idpserver, lasso.providerTypeIdp) - -if lasso.get_request_type_from_soap_msg(msg_body)==lasso.REQUEST_TYPE_LOGOUT: - print "it's a logout request !" - -#fake response, only for test ! -response_msg_body = "<Envelope><LogoutResponse><ProviderID>https://service-provider2:2003/liberty-alliance/metadata</ProviderID><Status><StatusCode Value=\"Samlp:Success\"></StatusCode></Status></LogoutResponse></Envelope>" - -idplogout.load_request_msg(msg_body, lasso.HTTP_METHOD_SOAP) -nameIdentifier = idplogout.nameIdentifier -print "get the user dump from NameIdentifier : ", nameIdentifier -idplogout.set_user_from_dump(idpuser_dump) -idplogout.process_request() - -print "RelayState :", idplogout.msg_relayState - -next_provider_id = idplogout.get_next_providerID() -while next_provider_id: - idplogout.init_request(next_provider_id) - idplogout.build_request_msg() - - print "send soap msg to url", idplogout.msg_url - # remote SP send back a LogoutResponse, process it. - idplogout.process_response_msg(response_msg_body, lasso.HTTP_METHOD_SOAP) - - next_provider_id = idplogout.get_next_providerID() - -idplogout.build_response_msg() - -print "End of logout" diff --git a/python/examples/mapping.py b/python/examples/mapping.py deleted file mode 100644 index 5a71abfc..00000000 --- a/python/examples/mapping.py +++ /dev/null @@ -1,36 +0,0 @@ -#! /usr/bin/env python - -import sys -sys.path.insert(0, '../') -import lasso - -req = lasso.NameIdentifierMappingRequest.new("http://providerid.com", - "CDSC7SCD65SCDSDCCDS", "http://qualifier.com", "federated") -print 'dump req : ', req.dump() - -query = req.url_encode(1, './rsakey.pem') -print 'req url encoded : ', query - -soap = req.soap_envelop() -print 'req soap envelopped : ', soap - -req = lasso.NameIdentifierMappingRequest.new_from_query(query) -print 'dump req2 from query : ', req.dump() - -req = lasso.NameIdentifierMappingRequest.new_from_soap(soap) -print 'dump req3 from soap : ', req.dump() - -res = lasso.NameIdentifierMappingResponse.new_from_request_soap(soap, "http://providerid.com", "success") -print 'dump res from request soap : ', res.dump() - -query = res.url_encode(1, 'rsakey.pem') -soap = res.soap_envelop() - -#res = lasso.NameIdentifierMappingResponse.new_from_request_query(query, "http://providerid.com", "success") -#print 'dump res from request query : ', res.dump() - -res = lasso.NameIdentifierMappingResponse.new_from_soap(soap) -print 'dump res from request soap : ', res.dump() - -res = lasso.NameIdentifierMappingResponse.new_from_query(query) -print 'dump res from request query : ', res.dump() diff --git a/python/examples/registration.py b/python/examples/registration.py deleted file mode 100644 index a619fd54..00000000 --- a/python/examples/registration.py +++ /dev/null @@ -1,41 +0,0 @@ -#! /usr/bin/env python - -import sys -sys.path.insert(0, '../') -import lasso - -# servers : -spserver = lasso.Server.new("../../examples/sp.xml", - "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", - lasso.SIGNATURE_METHOD_RSA_SHA1) - -spserver.add_provider("../../examples/idp.xml", None, None) - -idpserver = lasso.Server.new("../../examples/idp.xml", - "../../examples/rsapub.pem", "../../examples/rsakey.pem", "../../examples/rsacert.pem", - lasso.SIGNATURE_METHOD_RSA_SHA1) - -spserver.add_provider("../../examples/sp.xml", None, None) - -# users : -spuser_dump = "<LassoUser><LassoIdentities><LassoIdentity RemoteProviderID=\"https://identity-provider:2003/liberty-alliance/metadata\"><LassoRemoteNameIdentifier><NameIdentifier NameQualifier=\"qualifier.com\" Format=\"federated\">LLLLLLLLLLLLLLLLLLLLLLLLL</NameIdentifier></LassoRemoteNameIdentifier></LassoIdentity></LassoIdentities></LassoUser>" - -spuser = lasso.User.new_from_dump(spuser_dump) - -idpuser_dump = "<LassoUser><LassoIdentities><LassoIdentity RemoteProviderID=\"https://service-provider:2003/liberty-alliance/metadata\"><LassoLocalNameIdentifier><NameIdentifier NameQualifier=\"qualifier.com\" Format=\"federated\">LLLLLLLLLLLLLLLLLLLLLLLLL</NameIdentifier></LassoLocalNameIdentifier></LassoIdentity></LassoIdentities></LassoUser>" - -idpuser = lasso.User.new_from_dump(idpuser_dump) - - -# sp register name identifier : -print 'new registration' -spregistration = lasso.RegisterNameIdentifier.new(spserver, spuser, lasso.providerTypeSp) -spregistration.init_request("https://identity-provider:2003/liberty-alliance/metadata") -#spregistration.build_request_msg() -print 'url : ', spregistration.msg_url -print 'body : ', spregistration.msg_body - - -print 'End of registration' - -lasso.shutdown() diff --git a/python/examples/test.py b/python/examples/test.py deleted file mode 100755 index 03541eca..00000000 --- a/python/examples/test.py +++ /dev/null @@ -1,83 +0,0 @@ -#! /usr/bin/env python -# -*- coding: utf-8 -*- - -import sys -sys.path.insert(0, '../') -import lasso - -# creation d'une AuthnRequest -req = lasso.AuthnRequest("http://providerid.com") -req.set_forceAuthn(0) -req.set_isPassive(1) -req.set_protocolProfile(lasso.libProtocolProfilePost) -req.set_requestAuthnContext(["test1", "test2"], - None, - lasso.libAuthnContextComparisonExact) -req.set_scoping(proxyCount=1) - -# url encodage de la request (+ signature) -query = req.export_to_query(1, "../../examples/rsakey.pem") -req.destroy() - -# creation de la response AuthnResponse OU Response -# en fonction de la valeur de ProtocolProfile -protocolProfile = lasso.authn_request_get_protocolProfile(query) -if protocolProfile == lasso.libProtocolProfilePost: - # partie IDP - res = lasso.AuthnResponse.new_from_request_query(query, "http://providerid.com") - # verification de la signature de la query - print "Query signature check:", res.verify_signature("../../examples/rsapub.pem", - "../../examples/rsakey.pem") - must_authenticate = res.must_authenticate(is_authenticated=0) - print "Must authenticate? :", must_authenticate - - if must_authenticate: - # dump (sauvegarde avant authentification) - dump_response = res.dump() - res.destroy() - - # reconstruction de la reponse apres authentification du Principal - res = lasso.AuthnResponse.new_from_dump(dump_response) - res.process_authentication_result(1) - - # if NameIDPolicy omitted or none and federation KO - # statusCode = lib:FederationDoesNotExist - - # creation de l'assertion - assertion = lasso.Assertion("issuer", res.get_attr_value("InResponseTo")) - authentication_statement = lasso.AuthenticationStatement("password", - "tralala", - "dslqkjfslfj", - "http://service-provider.com", - "federated", - "wxkfjesmqfj", - "http://idp-provider.com", - "federated") - assertion.add_authenticationStatement(authentication_statement) - assertion.set_signature(1, "../../examples/rsakey.pem", - "../../examples/rsacert.pem"); - # ajout de l'assertion - res.add_assertion(assertion) - - # export de la response (base64 encodée) pr envoi au SP - res_b64 = res.export_to_base64() - res.destroy() -else: - print "La Response (par artifact) n'est pas encore implementée" - lasso.shutdown() - sys.exit(0) - -# partie SP -# reconstruction de la reponse -res = lasso.AuthnResponse.new_from_export(res_b64, type=1) -# Verification de la signature de l'assertion -assertion = res.get_child("Assertion") -if assertion: - print "Assertion signature check: ", res.get_child("Assertion").verify_signature("../../examples/rootcert.pem") -# recuperation du StatusCode -status_code = res.get_child("StatusCode") -# recuperation de la valeur de l'attribut "Value" -print "Resultat de la demande d'authentification:", status_code.get_attr_value("Value") -res.destroy() - -lasso.shutdown() diff --git a/python/examples/user.py b/python/examples/user.py deleted file mode 100644 index 0aa641de..00000000 --- a/python/examples/user.py +++ /dev/null @@ -1,47 +0,0 @@ -#! /usr/bin/env python - -import sys -sys.path.insert(0, '../') -import lasso - - -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>""" - -lasso_identities = """<LassoIdentities><LassoIdentity RemoteProviderID="https://service-provider1:2003/liberty-alliance/metadata"><LassoRemoteNameIdentifier><NameIdentifier>111111111111111111111111111111</NameIdentifier></LassoRemoteNameIdentifier></LassoIdentity></LassoIdentities>""" - - -user_dump = "<LassoUser>%s%s</LassoUser>" % (lasso_assertions, lasso_identities) - -user = lasso.User.new_from_dump(user_dump); - -print "Dump of user environ : %s\n" % user.dump() - -next_provider_id = user.get_next_assertion_remote_providerID() -while(next_provider_id): - print "Next provider id : ", next_provider_id - assertion = user.get_assertion(next_provider_id) - print "his Assertion : ", assertion.dump() - print "Remove his assertion from user ..." - user.remove_assertion(next_provider_id) - - next_provider_id = user.get_next_assertion_remote_providerID() - -print "All assertions deleted\n" - -print "Dump of user environ :" -print user.dump() - -user2 = lasso.User.new_from_dump(user.dump()); -print 'user2 dump 1' -print user2.dump() - -assertion = lasso.Assertion("http://nowhere.com", "CD8CS7C6CS6CD6C6SC6SSDC6CS6D") - -print 'user dump 1' -print user.dump() - -user.add_assertion("https://service-provider1:2003/liberty-alliance/metadata", assertion) - -print user.dump() - -user.destroy() |