diff options
author | Roland Hedberg <roland.hedberg@adm.umu.se> | 2009-11-03 20:09:17 +0100 |
---|---|---|
committer | Roland Hedberg <roland.hedberg@adm.umu.se> | 2009-11-03 20:09:17 +0100 |
commit | e7abf65f660ceca6ad2d722b7877c8e068c5bc69 (patch) | |
tree | 78565f2e27a43f218afe26e7b3e57efcd6ed4f4b /src/saml2 | |
parent | c965acac340feffac26a22ecd11e7a0076c75360 (diff) | |
download | pysaml2-e7abf65f660ceca6ad2d722b7877c8e068c5bc69.tar.gz |
refactored plus new test
Diffstat (limited to 'src/saml2')
-rw-r--r-- | src/saml2/server.py | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/saml2/server.py b/src/saml2/server.py index d1e46157..52430ca7 100644 --- a/src/saml2/server.py +++ b/src/saml2/server.py @@ -31,11 +31,15 @@ class UnknownPricipal(Exception): class UnsupportedBinding(Exception): pass + +class OtherError(Exception): + pass EXCEPTION2STATUS = { VersionMismatch: samlp.STATUS_VERSION_MISMATCH, UnknownPricipal: samlp.STATUS_UNKNOWN_PRINCIPAL, UnsupportedBinding: samlp.STATUS_UNSUPPORTED_BINDING, + OtherError: samlp.STATUS_UNKNOWN_PRINCIPAL, } def properties(klass): @@ -59,11 +63,11 @@ class Server(object): #assert "service_url" in self.conf assert "entityid" in self.conf - if "my_key" not in self.conf: - self.conf["my_key"] = None + if "key_file" not in self.conf: + self.conf["key_file"] = None else: # If you have a key file you have to have a cert file - assert "my_cert" in self.conf + assert "cert_file" in self.conf if "metadata" in self.conf: md = MetaData() @@ -88,12 +92,12 @@ class Server(object): def status_from_exception(self, exception): return { "status_code": { - "value": STATUS_RESPONDER, + "value": samlp.STATUS_RESPONDER, "status_code": { - "value": EXCEPTION2STATUS( exception), + "value": EXCEPTION2STATUS[exception.__class__], }, - "message": exception.args[0], - } + }, + "status_message": exception.args[0], } def status(self, status, message=None, status_code=None): @@ -225,6 +229,10 @@ class Server(object): if not consumer_url: # what to do ? raise UnsupportedBinding(spentityid) + if consumer_url != return_destination: + # serious error on someones behalf + raise OtherError("ConsumerURL and return destination mismatch") + policy = request.name_id_policy if policy.allow_create.lower() == "true" and \ policy.format == saml.NAMEID_FORMAT_TRANSIENT: |