summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/SimpleSAML/Module.php2
-rw-r--r--lib/SimpleSAML/Utilities.php46
-rw-r--r--lib/SimpleSAML/Utils/HTTP.php42
-rw-r--r--modules/aselect/lib/Auth/Source/aselect.php4
-rw-r--r--modules/authtwitter/lib/Auth/Source/Twitter.php2
-rw-r--r--modules/cas/lib/Auth/Source/CAS.php4
-rw-r--r--modules/casserver/www/login.php2
-rw-r--r--modules/cdc/lib/Server.php2
-rw-r--r--modules/discojuice/www/central.php2
-rw-r--r--modules/oauth/lib/Consumer.php2
-rw-r--r--modules/oauth/lib/OAuthStore.php2
-rw-r--r--modules/oauth/www/authorize.php2
-rw-r--r--modules/saml/lib/IdP/SAML1.php2
-rw-r--r--modules/saml/lib/IdP/SAML2.php2
-rw-r--r--templates/includes/header.php2
-rw-r--r--www/shib13/idp/metadata.php2
16 files changed, 61 insertions, 59 deletions
diff --git a/lib/SimpleSAML/Module.php b/lib/SimpleSAML/Module.php
index b5d8f02..829fa7b 100644
--- a/lib/SimpleSAML/Module.php
+++ b/lib/SimpleSAML/Module.php
@@ -157,7 +157,7 @@ class SimpleSAML_Module {
$url = SimpleSAML_Utilities::getBaseURL() . 'module.php/' . $resource;
if (!empty($parameters)) {
- $url = SimpleSAML_Utilities::addURLparameter($url, $parameters);
+ $url = \SimpleSAML\Utils\HTTP::addURLParameters($url, $parameters);
}
return $url;
}
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index a0dab57..334f584 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -252,48 +252,10 @@ class SimpleSAML_Utilities {
/**
- * Add one or more query parameters to the given URL.
- *
- * @param $url The URL the query parameters should be added to.
- * @param $parameter The query parameters which should be added to the url. This should be
- * an associative array. For backwards comaptibility, it can also be a
- * query string representing the new parameters. This will write a warning
- * to the log.
- * @return The URL with the new query parameters.
- */
- public static function addURLparameter($url, $parameter) {
-
- /* For backwards compatibility - allow $parameter to be a string. */
- if(is_string($parameter)) {
- /* Print warning to log. */
- $backtrace = debug_backtrace();
- $where = $backtrace[0]['file'] . ':' . $backtrace[0]['line'];
- SimpleSAML_Logger::warning(
- 'Deprecated use of SimpleSAML_Utilities::addURLparameter at ' . $where .
- '. The parameter "$parameter" should now be an array, but a string was passed.');
-
- $parameter = self::parseQueryString($parameter);
- }
- assert('is_array($parameter)');
-
- $queryStart = strpos($url, '?');
- if($queryStart === FALSE) {
- $oldQuery = array();
- $url .= '?';
- } else {
- $oldQuery = substr($url, $queryStart + 1);
- if($oldQuery === FALSE) {
- $oldQuery = array();
- } else {
- $oldQuery = self::parseQueryString($oldQuery);
- }
- $url = substr($url, 0, $queryStart + 1);
- }
-
- $query = array_merge($oldQuery, $parameter);
- $url .= http_build_query($query, '', '&');
-
- return $url;
+ * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\HTTP::addURLParameters() instead.
+ */
+ public static function addURLparameter($url, $parameters) {
+ return \SimpleSAML\Utils\HTTP::addURLParameter($url, $parameters);
}
diff --git a/lib/SimpleSAML/Utils/HTTP.php b/lib/SimpleSAML/Utils/HTTP.php
index d501162..bf7ac0c 100644
--- a/lib/SimpleSAML/Utils/HTTP.php
+++ b/lib/SimpleSAML/Utils/HTTP.php
@@ -66,6 +66,46 @@ class HTTP
/**
+ * Add one or more query parameters to the given URL.
+ *
+ * @param string $url The URL the query parameters should be added to.
+ * @param array $parameters The query parameters which should be added to the url. This should be an associative
+ * array.
+ *
+ * @return string The URL with the new query parameters.
+ * @throws \SimpleSAML_Error_Exception If $url is not a string or $parameters is not an array.
+ *
+ * @author Andreas Solberg, UNINETT AS <andreas.solberg@uninett.no>
+ * @author Olav Morken, UNINETT AS <olav.morken@uninett.no>
+ */
+ public static function addURLParameters($url, $parameters)
+ {
+ if (!is_string($url) || !is_array($parameters)) {
+ throw new \SimpleSAML_Error_Exception('Invalid input parameters.');
+ }
+
+ $queryStart = strpos($url, '?');
+ if ($queryStart === false) {
+ $oldQuery = array();
+ $url .= '?';
+ } else {
+ $oldQuery = substr($url, $queryStart + 1);
+ if ($oldQuery === false) {
+ $oldQuery = array();
+ } else {
+ $oldQuery = self::parseQueryString($oldQuery);
+ }
+ $url = substr($url, 0, $queryStart + 1);
+ }
+
+ $query = array_merge($oldQuery, $parameters);
+ $url .= http_build_query($query, '', '&');
+
+ return $url;
+ }
+
+
+ /**
* Retrieve the port number from $_SERVER environment variables.
*
* @return string The port number prepended by a colon, if it is different than the default port for the protocol
@@ -107,7 +147,7 @@ class HTTP
public static function parseQueryString($query_string)
{
if (!is_string($query_string)) {
- throw new \SimpleSAML_Error_Exception('Invalid input parameters');
+ throw new \SimpleSAML_Error_Exception('Invalid input parameters.');
}
$res = array();
diff --git a/modules/aselect/lib/Auth/Source/aselect.php b/modules/aselect/lib/Auth/Source/aselect.php
index 874b5ca..fca9896 100644
--- a/modules/aselect/lib/Auth/Source/aselect.php
+++ b/modules/aselect/lib/Auth/Source/aselect.php
@@ -125,7 +125,7 @@ class sspmod_aselect_Auth_Source_aselect extends SimpleSAML_Auth_Source {
$signable .= $parameters[$p];
$parameters['signature'] = $this->base64_signature($signable);
}
- return SimpleSAML_Utilities::addURLparameter($this->server_url, $parameters);
+ return \SimpleSAML\Utils\HTTP::addURLParameters($this->server_url, $parameters);
}
/**
@@ -177,7 +177,7 @@ class sspmod_aselect_Auth_Source_aselect extends SimpleSAML_Auth_Source {
$as_url = $res['as_url'];
unset($res['as_url']);
- return SimpleSAML_Utilities::addURLparameter($as_url, $res);
+ return \SimpleSAML\Utils\HTTP::addURLParameters($as_url, $res);
}
/**
diff --git a/modules/authtwitter/lib/Auth/Source/Twitter.php b/modules/authtwitter/lib/Auth/Source/Twitter.php
index c071066..58e7ba6 100644
--- a/modules/authtwitter/lib/Auth/Source/Twitter.php
+++ b/modules/authtwitter/lib/Auth/Source/Twitter.php
@@ -72,7 +72,7 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source {
// Authorize the request token
$url = 'https://api.twitter.com/oauth/authenticate';
if ($this->force_login) {
- $url = SimpleSAML_Utilities::addURLparameter($url, array('force_login' => 'true'));
+ $url = \SimpleSAML\Utils\HTTP::addURLParameters($url, array('force_login' => 'true'));
}
$consumer->getAuthorizeRequest($url, $requestToken);
}
diff --git a/modules/cas/lib/Auth/Source/CAS.php b/modules/cas/lib/Auth/Source/CAS.php
index 611fd85..81ae59e 100644
--- a/modules/cas/lib/Auth/Source/CAS.php
+++ b/modules/cas/lib/Auth/Source/CAS.php
@@ -89,7 +89,7 @@ class sspmod_cas_Auth_Source_CAS extends SimpleSAML_Auth_Source {
* @return list username and attributes
*/
private function casValidate($ticket, $service){
- $url = SimpleSAML_Utilities::addURLparameter($this->_casConfig['validate'], array(
+ $url = \SimpleSAML\Utils\HTTP::addURLParameters($this->_casConfig['validate'], array(
'ticket' => $ticket,
'service' => $service,
));
@@ -112,7 +112,7 @@ class sspmod_cas_Auth_Source_CAS extends SimpleSAML_Auth_Source {
* @return list username and attributes
*/
private function casServiceValidate($ticket, $service){
- $url = SimpleSAML_Utilities::addURLparameter($this->_casConfig['serviceValidate'], array(
+ $url = \SimpleSAML\Utils\HTTP::addURLParameters($this->_casConfig['serviceValidate'], array(
'ticket' => $ticket,
'service' => $service,
));
diff --git a/modules/casserver/www/login.php b/modules/casserver/www/login.php
index 43e08fb..f660a98 100644
--- a/modules/casserver/www/login.php
+++ b/modules/casserver/www/login.php
@@ -49,7 +49,7 @@ storeTicket($ticket, $path, array('service' => $service,
'validbefore' => time() + 5));
SimpleSAML_Utilities::redirectTrustedURL(
- SimpleSAML_Utilities::addURLparameter($service,
+ \SimpleSAML\Utils\HTTP::addURLParameters($service,
array('ticket' => $ticket)
)
); \ No newline at end of file
diff --git a/modules/cdc/lib/Server.php b/modules/cdc/lib/Server.php
index 2aa8850..8c2798f 100644
--- a/modules/cdc/lib/Server.php
+++ b/modules/cdc/lib/Server.php
@@ -324,7 +324,7 @@ class sspmod_cdc_Server {
'Signature' => $signature,
);
- $url = SimpleSAML_Utilities::addURLparameter($to, $params);
+ $url = \SimpleSAML\Utils\HTTP::addURLParameters($to, $params);
if (strlen($url) < 2048) {
SimpleSAML_Utilities::redirectTrustedURL($url);
} else {
diff --git a/modules/discojuice/www/central.php b/modules/discojuice/www/central.php
index 6f1a7ea..9404fd5 100644
--- a/modules/discojuice/www/central.php
+++ b/modules/discojuice/www/central.php
@@ -12,7 +12,7 @@ $entityid = $_REQUEST['entityID'];
// Return to...
$returnidparam = !empty($_REQUEST['returnIDParam']) ? $_REQUEST['returnIDParam'] : 'entityID';
-$href = SimpleSAML_Utilities::addURLparameter(
+$href = \SimpleSAML\Utils\HTTP::addURLParameters(
$_REQUEST['return'],
array($returnidparam => '')
);
diff --git a/modules/oauth/lib/Consumer.php b/modules/oauth/lib/Consumer.php
index 8e3e5ae..265b1ca 100644
--- a/modules/oauth/lib/Consumer.php
+++ b/modules/oauth/lib/Consumer.php
@@ -91,7 +91,7 @@ class sspmod_oauth_Consumer {
if ($callback) {
$params['oauth_callback'] = $callback;
}
- $authorizeURL = SimpleSAML_Utilities::addURLparameter($url, $params);
+ $authorizeURL = \SimpleSAML\Utils\HTTP::addURLParameters($url, $params);
if ($redirect) {
SimpleSAML_Utilities::redirectTrustedURL($authorizeURL);
exit;
diff --git a/modules/oauth/lib/OAuthStore.php b/modules/oauth/lib/OAuthStore.php
index 6a239a6..974387a 100644
--- a/modules/oauth/lib/OAuthStore.php
+++ b/modules/oauth/lib/OAuthStore.php
@@ -63,7 +63,7 @@ class sspmod_oauth_OAuthStore extends OAuthDataStore {
if ($oConsumer && ($oConsumer->callback_url)) $url = $oConsumer->callback_url;
$verifier = SimpleSAML\Utils\Random::generateID();
- $url = SimpleSAML_Utilities::addURLparameter($url, array("oauth_verifier"=>$verifier));
+ $url = \SimpleSAML\Utils\HTTP::addURLParameters($url, array("oauth_verifier"=>$verifier));
$this->store->set('authorized', $requestTokenKey, $verifier, $data, $this->config->getValue('requestTokenDuration', 60*30) );
diff --git a/modules/oauth/www/authorize.php b/modules/oauth/www/authorize.php
index afcc395..523670e 100644
--- a/modules/oauth/www/authorize.php
+++ b/modules/oauth/www/authorize.php
@@ -40,7 +40,7 @@ try {
$t = new SimpleSAML_XHTML_Template($config, 'oauth:consent.php');
$t->data['header'] = '{status:header_saml20_sp}';
$t->data['consumer'] = $consumer; // array containint {name, description, key, secret, owner} keys
- $t->data['urlAgree'] = SimpleSAML_Utilities::addURLparameter( SimpleSAML_Utilities::selfURL(), array("consent" => "yes") );
+ $t->data['urlAgree'] = \SimpleSAML\Utils\HTTP::addURLParameters(SimpleSAML_Utilities::selfURL(), array("consent" => "yes"));
$t->data['logouturl'] = SimpleSAML_Utilities::selfURLNoQuery() . '?logout';
$t->show();
diff --git a/modules/saml/lib/IdP/SAML1.php b/modules/saml/lib/IdP/SAML1.php
index 9ef95b7..79c8617 100644
--- a/modules/saml/lib/IdP/SAML1.php
+++ b/modules/saml/lib/IdP/SAML1.php
@@ -115,7 +115,7 @@ class sspmod_saml_IdP_SAML1 {
'protocol' => 'saml1',
));
- $sessionLostURL = SimpleSAML_Utilities::addURLparameter(
+ $sessionLostURL = \SimpleSAML\Utils\HTTP::addURLParameters(
SimpleSAML_Utilities::selfURL(),
array('cookieTime' => time()));
diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php
index ae9a6d4..a6bf33a 100644
--- a/modules/saml/lib/IdP/SAML2.php
+++ b/modules/saml/lib/IdP/SAML2.php
@@ -361,7 +361,7 @@ class sspmod_saml_IdP_SAML2 {
$sessionLostParams['RelayState'] = $relayState;
}
- $sessionLostURL = SimpleSAML_Utilities::addURLparameter(
+ $sessionLostURL = \SimpleSAML\Utils\HTTP::addURLParameters(
SimpleSAML_Utilities::selfURLNoQuery(),
$sessionLostParams);
diff --git a/templates/includes/header.php b/templates/includes/header.php
index cb59059..10f7576 100644
--- a/templates/includes/header.php
+++ b/templates/includes/header.php
@@ -186,7 +186,7 @@ if($onLoad !== '') {
if ($current) {
$textarray[] = $langnames[$lang];
} else {
- $textarray[] = '<a href="' . htmlspecialchars(SimpleSAML_Utilities::addURLparameter(SimpleSAML_Utilities::selfURL(), array($this->languageParameterName => $lang))) . '">' .
+ $textarray[] = '<a href="' . htmlspecialchars(\SimpleSAML\Utils\HTTP::addURLParameters(SimpleSAML_Utilities::selfURL(), array($this->languageParameterName => $lang))) . '">' .
$langnames[$lang] . '</a>';
}
}
diff --git a/www/shib13/idp/metadata.php b/www/shib13/idp/metadata.php
index fc0a358..92eb4ec 100644
--- a/www/shib13/idp/metadata.php
+++ b/www/shib13/idp/metadata.php
@@ -87,7 +87,7 @@ try {
$t->data['header'] = 'shib13-idp';
- $t->data['metaurl'] = SimpleSAML_Utilities::addURLparameter(SimpleSAML_Utilities::selfURLNoQuery(), array('output' => 'xml'));
+ $t->data['metaurl'] = \SimpleSAML\Utils\HTTP::addURLParameters(SimpleSAML_Utilities::selfURLNoQuery(), array('output' => 'xml'));
$t->data['metadata'] = htmlspecialchars($metaxml);
$t->data['metadataflat'] = htmlspecialchars($metaflat);