summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Gil <lgs@yaco.es>2012-06-02 09:33:14 +0200
committerLorenzo Gil <lgs@yaco.es>2012-06-02 09:33:14 +0200
commit5f4ff814e1c234b56593e30f5e6a1c106ccf7ed9 (patch)
tree4d1f4b81e2ece59a1826a8a67f23122da8f2f095
parent564f6af1489168cebea92c02826122a16bf90192 (diff)
downloadpysaml2-5f4ff814e1c234b56593e30f5e6a1c106ccf7ed9.tar.gz
Rename 'construct_logout_request' to '_logout_request' and make it private
-rw-r--r--src/saml2/client.py80
-rw-r--r--tests/test_50_server.py6
2 files changed, 43 insertions, 43 deletions
diff --git a/src/saml2/client.py b/src/saml2/client.py
index 5e98f9be..7f60ca03 100644
--- a/src/saml2/client.py
+++ b/src/saml2/client.py
@@ -280,6 +280,44 @@ class Saml2Client(object):
return signed_instance_factory(request, self.sec, to_sign)
+ def _logout_request(self, subject_id, destination,
+ issuer_entity_id, reason=None, expire=None):
+ """ Constructs a LogoutRequest
+
+ :param subject_id: The identifier of the subject
+ :param destination:
+ :param issuer_entity_id: The entity ID of the IdP the request is
+ target at.
+ :param reason: An indication of the reason for the logout, in the
+ form of a URI reference.
+ :param expire: The time at which the request expires,
+ after which the recipient may discard the message.
+ :return: A LogoutRequest instance
+ """
+
+ session_id = sid()
+ # create NameID from subject_id
+ name_id = saml.NameID(
+ text = self.users.get_entityid(subject_id, issuer_entity_id,
+ False))
+
+ request = samlp.LogoutRequest(
+ id=session_id,
+ version=VERSION,
+ issue_instant=instant(),
+ destination=destination,
+ issuer=self._issuer(),
+ name_id = name_id
+ )
+
+ if reason:
+ request.reason = reason
+
+ if expire:
+ request.not_on_or_after = expire
+
+ return request
+
#
# Public API
#
@@ -535,44 +573,6 @@ class Saml2Client(object):
log.info("No response")
return None
- def construct_logout_request(self, subject_id, destination,
- issuer_entity_id, reason=None, expire=None):
- """ Constructs a LogoutRequest
-
- :param subject_id: The identifier of the subject
- :param destination:
- :param issuer_entity_id: The entity ID of the IdP the request is
- target at.
- :param reason: An indication of the reason for the logout, in the
- form of a URI reference.
- :param expire: The time at which the request expires,
- after which the recipient may discard the message.
- :return: A LogoutRequest instance
- """
-
- session_id = sid()
- # create NameID from subject_id
- name_id = saml.NameID(
- text = self.users.get_entityid(subject_id, issuer_entity_id,
- False))
-
- request = samlp.LogoutRequest(
- id=session_id,
- version=VERSION,
- issue_instant=instant(),
- destination=destination,
- issuer=self._issuer(),
- name_id = name_id
- )
-
- if reason:
- request.reason = reason
-
- if expire:
- request.not_on_or_after = expire
-
- return request
-
def global_logout(self, subject_id, reason="", expire=None,
sign=None, log=None, return_to="/"):
""" More or less a layer of indirection :-/
@@ -635,8 +635,8 @@ class Saml2Client(object):
if log:
log.info("destination to provider: %s" % destination)
- request = self.construct_logout_request(subject_id, destination,
- entity_id, reason, expire)
+ request = self._logout_request(subject_id, destination,
+ entity_id, reason, expire)
to_sign = []
#if sign and binding != BINDING_HTTP_REDIRECT:
diff --git a/tests/test_50_server.py b/tests/test_50_server.py
index 0b3d258c..b70f50a3 100644
--- a/tests/test_50_server.py
+++ b/tests/test_50_server.py
@@ -343,7 +343,7 @@ class TestServer1():
}
self.client.users.add_information_about_person(sinfo)
- logout_request = self.client.construct_logout_request(
+ logout_request = self.client._logout_request(
subject_id="foba0001",
destination = "http://localhost:8088/slop",
issuer_entity_id = "urn:mace:example.com:saml:roland:idp",
@@ -370,7 +370,7 @@ class TestServer1():
sp = client.Saml2Client(config_file="server_conf")
sp.users.add_information_about_person(sinfo)
- logout_request = sp.construct_logout_request(subject_id = "foba0001",
+ logout_request = sp._logout_request(subject_id = "foba0001",
destination = "http://localhost:8088/slo",
issuer_entity_id = "urn:mace:example.com:saml:roland:idp",
reason = "I'm tired of this")
@@ -430,7 +430,7 @@ def _logout_request(conf_file):
}
sp.users.add_information_about_person(sinfo)
- return sp.construct_logout_request(
+ return sp._logout_request(
subject_id = "foba0001",
destination = "http://localhost:8088/slo",
issuer_entity_id = "urn:mace:example.com:saml:roland:idp",