diff options
author | Jaime Perez Crespo <jaime.perez@uninett.no> | 2015-08-05 16:51:07 +0200 |
---|---|---|
committer | Jaime Perez Crespo <jaime.perez@uninett.no> | 2015-08-05 16:51:07 +0200 |
commit | 0a856dff37bc84d56c2095f7351c23a2b1a3fbf8 (patch) | |
tree | 6d6b231f5fa30e8f4783f78f4b2144c924ab03ce | |
parent | 34cc8fb30aac0be4518398a01e253987d6d6daef (diff) | |
download | simplesamlphp-0a856dff37bc84d56c2095f7351c23a2b1a3fbf8.zip simplesamlphp-0a856dff37bc84d56c2095f7351c23a2b1a3fbf8.tar.gz simplesamlphp-0a856dff37bc84d56c2095f7351c23a2b1a3fbf8.tar.bz2 |
Remove duplicated code.
-rw-r--r-- | lib/SimpleSAML/XHTML/IdPDisco.php | 21 | ||||
-rw-r--r-- | modules/discopower/lib/PowerIdPDisco.php | 29 |
2 files changed, 15 insertions, 35 deletions
diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php index f01e7f4..065e2e5 100644 --- a/lib/SimpleSAML/XHTML/IdPDisco.php +++ b/lib/SimpleSAML/XHTML/IdPDisco.php @@ -505,15 +505,14 @@ class SimpleSAML_XHTML_IdPDisco /** - * Handles a request to this discovery service. + * Check if an IdP is set or if the request is passive, and redirect accordingly. * - * The IdP disco parameters should be set before calling this function. + * @return void If there is no IdP targeted and this is not a passive request. */ - public function handleRequest() + protected function start() { $idp = $this->getTargetIdp(); if ($idp !== null) { - $extDiscoveryStorage = $this->config->getString('idpdisco.extDiscoveryStorage', null); if ($extDiscoveryStorage !== null) { $this->log('Choice made ['.$idp.'] (Forwarding to external discovery storage)'); @@ -530,15 +529,23 @@ class SimpleSAML_XHTML_IdPDisco ); \SimpleSAML\Utils\HTTP::redirectTrustedURL($this->returnURL, array($this->returnIdParam => $idp)); } - - return; } if ($this->isPassive) { $this->log('Choice not made. (Redirecting the user back without answer)'); \SimpleSAML\Utils\HTTP::redirectTrustedURL($this->returnURL); - return; } + } + + + /** + * Handles a request to this discovery service. + * + * The IdP disco parameters should be set before calling this function. + */ + public function handleRequest() + { + $this->start(); // no choice made. Show discovery service page $idpList = $this->getIdPList(); diff --git a/modules/discopower/lib/PowerIdPDisco.php b/modules/discopower/lib/PowerIdPDisco.php index 26c4efd..5758149 100644 --- a/modules/discopower/lib/PowerIdPDisco.php +++ b/modules/discopower/lib/PowerIdPDisco.php @@ -185,34 +185,7 @@ class sspmod_discopower_PowerIdPDisco extends SimpleSAML_XHTML_IdPDisco { * The IdP disco parameters should be set before calling this function. */ public function handleRequest() { - - $idp = $this->getTargetIdp(); - if($idp !== NULL) { - - $extDiscoveryStorage = $this->config->getString('idpdisco.extDiscoveryStorage',NULL); - if ($extDiscoveryStorage !== NULL) { - $this->log('Choice made [' . $idp . '] (Forwarding to external discovery storage)'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($extDiscoveryStorage, array( - 'entityID' => $this->spEntityId, - 'IdPentityID' => $idp, - 'returnIDParam' => $this->returnIdParam, - 'isPassive' => 'true', - 'return' => $this->returnURL - )); - - } else { - $this->log('Choice made [' . $idp . '] (Redirecting the user back. returnIDParam=' . $this->returnIdParam . ')'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($this->returnURL, array($this->returnIdParam => $idp)); - } - - return; - } - - if ($this->isPassive) { - $this->log('Choice not made. (Redirecting the user back without answer)'); - \SimpleSAML\Utils\HTTP::redirectTrustedURL($this->returnURL); - return; - } + $this->start(); /* No choice made. Show discovery service page. */ $idpList = $this->getIdPList(); |