diff --git a/lib/SimpleSAML/Auth/LDAP.php b/lib/SimpleSAML/Auth/LDAP.php index f7dbebd3e3f23464a252834f6bc59c43aa5f4430..50cd5da528cbe439be0e8fa9f87bacbef9ff4ab8 100644 --- a/lib/SimpleSAML/Auth/LDAP.php +++ b/lib/SimpleSAML/Auth/LDAP.php @@ -261,7 +261,7 @@ class SimpleSAML_Auth_LDAP { public function searchfordn($base, $attribute, $value, $allowZeroHits = FALSE) { // Traverse all search bases, returning DN if found. - $bases = SimpleSAML_Utils_Arrays::arrayize($base); + $bases = SimpleSAML\Utils\Arrays::arrayize($base); $result = NULL; foreach ($bases AS $current) { try { diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index a2108ee156e3d8636106f83642058ccb2536e138..88faf027663a98d817bc67675bf52bc5279ae2d6 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -111,7 +111,7 @@ class SimpleSAML_Configuration { $host = $_SERVER['HTTP_HOST']; if (array_key_exists($host, $config['override.host'])) { $ofs = $config['override.host'][$host]; - foreach (SimpleSAML_Utils_Arrays::arrayize($ofs) AS $of) { + foreach (SimpleSAML\Utils\Arrays::arrayize($ofs) AS $of) { $overrideFile = dirname($filename) . '/' . $of; if (!file_exists($overrideFile)) { throw new Exception('Config file [' . $filename . '] requests override for host ' . $host . ' but file does not exists [' . $of . ']'); diff --git a/lib/SimpleSAML/Memcache.php b/lib/SimpleSAML/Memcache.php index d420c33c00bd2e249b9493499b908ac8678bc228..791f43abbf55ef9db9e8006072c8a364d8d1668c 100644 --- a/lib/SimpleSAML/Memcache.php +++ b/lib/SimpleSAML/Memcache.php @@ -403,7 +403,7 @@ class SimpleSAML_Memcache { throw new Exception('Failed to get memcache server status.'); } - $stats = SimpleSAML_Utils_Arrays::transpose($stats); + $stats = SimpleSAML\Utils\Arrays::transpose($stats); $ret = array_merge_recursive($ret, $stats); } diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php index d79619f4b9912c2e2ebdc2b7538a42b23920e7e6..d43d05f2435f8e31361741d68a447ddaa205fa4e 100644 --- a/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -277,9 +277,9 @@ class SimpleSAML_Metadata_SAMLBuilder { return; } - $orgName = SimpleSAML_Utils_Arrays::arrayize($metadata['OrganizationName'], 'en'); - $orgDisplayName = SimpleSAML_Utils_Arrays::arrayize($metadata['OrganizationDisplayName'], 'en'); - $orgURL = SimpleSAML_Utils_Arrays::arrayize($metadata['OrganizationURL'], 'en'); + $orgName = SimpleSAML\Utils\Arrays::arrayize($metadata['OrganizationName'], 'en'); + $orgDisplayName = SimpleSAML\Utils\Arrays::arrayize($metadata['OrganizationDisplayName'], 'en'); + $orgURL = SimpleSAML\Utils\Arrays::arrayize($metadata['OrganizationURL'], 'en'); $this->addOrganization($orgName, $orgDisplayName, $orgURL); } diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index e6a33a4e9231cf45cfd56e90ee7db57f21b54ab9..3d3306532575815790a6e224f95593520a88bd05 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -564,10 +564,10 @@ class SimpleSAML_Utilities { } /** - * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML_Utils_Arrays::transpose() instead. + * @deprecated This method will be removed in SSP 2.0. Please use SimpleSAML\Utils\Arrays::transpose() instead. */ public static function transposeArray($in) { - return SimpleSAML_Utils_Arrays::transpose($in); + return SimpleSAML\Utils\Arrays::transpose($in); } @@ -971,10 +971,10 @@ class SimpleSAML_Utilities { /** * @deprecated This method will be removed in SSP 2.0. Please use - * SimpleSAML_Utils_Arrays::normalizeAttributesArray() instead. + * SimpleSAML\Utils\Arrays::normalizeAttributesArray() instead. */ public static function parseAttributes($attributes) { - return SimpleSAML_Utils_Arrays::normalizeAttributesArray($attributes); + return SimpleSAML\Utils\Arrays::normalizeAttributesArray($attributes); } @@ -1051,10 +1051,10 @@ class SimpleSAML_Utilities { } /** - * @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML_Utils_Arrays::arrayize() instead. + * @deprecated This function will be removed in SSP 2.0. Please use SimpleSAML\Utils\Arrays::arrayize() instead. */ public static function arrayize($data, $index = 0) { - return SimpleSAML_Utils_Arrays::arrayize($data, $index); + return SimpleSAML\Utils\Arrays::arrayize($data, $index); } diff --git a/lib/SimpleSAML/Utils/Arrays.php b/lib/SimpleSAML/Utils/Arrays.php index 029ee8923229b8d5156960e9402fac1a360dd19b..ec552bfb19bea18bec64fab40f0f0e0d1e1919a3 100644 --- a/lib/SimpleSAML/Utils/Arrays.php +++ b/lib/SimpleSAML/Utils/Arrays.php @@ -1,12 +1,12 @@ <?php - +namespace SimpleSAML\Utils; /** * Array-related utility methods. * * @package SimpleSAMLphp */ -class SimpleSAML_Utils_Arrays +class Arrays { /** @@ -37,7 +37,7 @@ class SimpleSAML_Utils_Arrays * @param array $attributes The array containing attributes that we should validate and normalize. * * @return array The normalized attributes array. - * @throws SimpleSAML_Error_Exception If input is not an array, array keys are not strings or attribute values are + * @throws \SimpleSAML_Error_Exception If input is not an array, array keys are not strings or attribute values are * not strings. * * @author Olav Morken, UNINETT AS <olav.morken@uninett.no> @@ -47,20 +47,20 @@ class SimpleSAML_Utils_Arrays { if (!is_array($attributes)) { - throw new SimpleSAML_Error_Exception('Attributes was not an array. Was: '.print_r($attributes, true).'".'); + throw new \SimpleSAML_Error_Exception('Attributes was not an array. Was: '.print_r($attributes, true).'".'); } $newAttrs = array(); foreach ($attributes as $name => $values) { if (!is_string($name)) { - throw new SimpleSAML_Error_Exception('Invalid attribute name: "'.print_r($name, true).'".'); + throw new \SimpleSAML_Error_Exception('Invalid attribute name: "'.print_r($name, true).'".'); } $values = self::arrayize($values); foreach ($values as $value) { if (!is_string($value)) { - throw new SimpleSAML_Error_Exception('Invalid attribute value for attribute '.$name. + throw new \SimpleSAML_Error_Exception('Invalid attribute value for attribute '.$name. ': "'.print_r($value, true).'".'); } } diff --git a/modules/authcrypt/lib/Auth/Source/Hash.php b/modules/authcrypt/lib/Auth/Source/Hash.php index 45d7d521399f59c22b9d286659dd9b5a2a6c256a..9bc061580e8e493457b5d0e9dd614454aaf6bdaf 100644 --- a/modules/authcrypt/lib/Auth/Source/Hash.php +++ b/modules/authcrypt/lib/Auth/Source/Hash.php @@ -50,7 +50,7 @@ class sspmod_authcrypt_Auth_Source_Hash extends sspmod_core_Auth_UserPassBase { $passwordhash = $userpass[1]; try { - $attributes = SimpleSAML_Utils_Arrays::normalizeAttributesArray($attributes); + $attributes = SimpleSAML\Utils\Arrays::normalizeAttributesArray($attributes); } catch(Exception $e) { throw new Exception('Invalid attributes for user ' . $username . ' in authentication source ' . $this->authId . ': ' . diff --git a/modules/authcrypt/lib/Auth/Source/Htpasswd.php b/modules/authcrypt/lib/Auth/Source/Htpasswd.php index fb116ec10a29aac823c13b95d67a38cd19a2bf88..0ffa5ac28de8c09bbbc6db0a48c3766ea5d01e6d 100644 --- a/modules/authcrypt/lib/Auth/Source/Htpasswd.php +++ b/modules/authcrypt/lib/Auth/Source/Htpasswd.php @@ -39,7 +39,7 @@ class sspmod_authcrypt_Auth_Source_Htpasswd extends sspmod_core_Auth_UserPassBas $this->users = explode("\n", trim($htpasswd)); try { - $this->attributes = SimpleSAML_Utils_Arrays::normalizeAttributesArray($config['static_attributes']); + $this->attributes = SimpleSAML\Utils\Arrays::normalizeAttributesArray($config['static_attributes']); } catch(Exception $e) { throw new Exception('Invalid static_attributes in authentication source ' . $this->authId . ': ' . $e->getMessage()); diff --git a/modules/consent/templates/consentform.php b/modules/consent/templates/consentform.php index 210fd46aa3ebae87b16ac17e1469a0016236c06a..e1ed91f2d3486171562216054a858b02f40c1b81 100644 --- a/modules/consent/templates/consentform.php +++ b/modules/consent/templates/consentform.php @@ -74,7 +74,7 @@ if (array_key_exists('descr_purpose', $this->data['dstMetadata'])) { array( 'SPNAME' => $dstName, 'SPDESC' => $this->getTranslation( - SimpleSAML_Utils_Arrays::arrayize( + SimpleSAML\Utils\Arrays::arrayize( $this->data['dstMetadata']['descr_purpose'], 'en' ) diff --git a/modules/core/templates/frontpage_federation.tpl.php b/modules/core/templates/frontpage_federation.tpl.php index eb8795ac6016ec00521d250578d38bb2b2523697..2be7e075502b36fb0f8cbe1f71e9e906359649db 100644 --- a/modules/core/templates/frontpage_federation.tpl.php +++ b/modules/core/templates/frontpage_federation.tpl.php @@ -61,9 +61,9 @@ foreach ($this->data['metaentries']['hosted'] AS $hm) { if ($hm['entityid'] !== $hm['metadata-index']) echo '<br />Index: ' . $hm['metadata-index']; if (!empty($hm['name'])) - echo '<br /><strong>' . $this->getTranslation(SimpleSAML_Utils_Arrays::arrayize($hm['name'], 'en')) . '</strong>'; + echo '<br /><strong>' . $this->getTranslation(SimpleSAML\Utils\Arrays::arrayize($hm['name'], 'en')) . '</strong>'; if (!empty($hm['descr'])) - echo '<br /><strong>' . $this->getTranslation(SimpleSAML_Utils_Arrays::arrayize($hm['descr'], 'en')) . '</strong>'; + echo '<br /><strong>' . $this->getTranslation(SimpleSAML\Utils\Arrays::arrayize($hm['descr'], 'en')) . '</strong>'; echo '<br />[ <a href="' . $hm['metadata-url'] . '">' . $this->t('{core:frontpage:show_metadata}') . '</a> ]'; @@ -82,9 +82,9 @@ foreach($this->data['metaentries']['remote'] AS $setkey => $set) { htmlspecialchars(SimpleSAML_Module::getModuleURL('core/show_metadata.php', array('entityid' => $entry['entityid'], 'set' => $setkey ))) . '">'); if (!empty($entry['name'])) { - echo htmlspecialchars($this->getTranslation(SimpleSAML_Utils_Arrays::arrayize($entry['name'], 'en'))); + echo htmlspecialchars($this->getTranslation(SimpleSAML\Utils\Arrays::arrayize($entry['name'], 'en'))); } elseif (!empty($entry['OrganizationDisplayName'])) { - echo htmlspecialchars($this->getTranslation(SimpleSAML_Utils_Arrays::arrayize($entry['OrganizationDisplayName'], 'en'))); + echo htmlspecialchars($this->getTranslation(SimpleSAML\Utils\Arrays::arrayize($entry['OrganizationDisplayName'], 'en'))); } else { echo htmlspecialchars($entry['entityid']); } diff --git a/modules/exampleauth/lib/Auth/Source/Static.php b/modules/exampleauth/lib/Auth/Source/Static.php index e6520ca4010804d5a22ccacf584ceefc1f4db79a..835544214347dfb67283e9e36b08621078464020 100644 --- a/modules/exampleauth/lib/Auth/Source/Static.php +++ b/modules/exampleauth/lib/Auth/Source/Static.php @@ -34,7 +34,7 @@ class sspmod_exampleauth_Auth_Source_Static extends SimpleSAML_Auth_Source { /* Parse attributes. */ try { - $this->attributes = SimpleSAML_Utils_Arrays::normalizeAttributesArray($config); + $this->attributes = SimpleSAML\Utils\Arrays::normalizeAttributesArray($config); } catch(Exception $e) { throw new Exception('Invalid attributes for authentication source ' . $this->authId . ': ' . $e->getMessage()); diff --git a/modules/exampleauth/lib/Auth/Source/UserPass.php b/modules/exampleauth/lib/Auth/Source/UserPass.php index 543cc1b4f72fb34b92d6a3ed4f576874d955e7d3..1b380de5953c343d40800885bf6bc87ce3c78186 100644 --- a/modules/exampleauth/lib/Auth/Source/UserPass.php +++ b/modules/exampleauth/lib/Auth/Source/UserPass.php @@ -50,7 +50,7 @@ class sspmod_exampleauth_Auth_Source_UserPass extends sspmod_core_Auth_UserPassB $password = $userpass[1]; try { - $attributes = SimpleSAML_Utils_Arrays::normalizeAttributesArray($attributes); + $attributes = SimpleSAML\Utils\Arrays::normalizeAttributesArray($attributes); } catch(Exception $e) { throw new Exception('Invalid attributes for user ' . $username . ' in authentication source ' . $this->authId . ': ' . diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php index a1779a127fe43a4279218692e8f938e0dcd78d4b..0823d5bbe037d9e6f0683585d4c61b229618ec09 100644 --- a/modules/saml/lib/Auth/Source/SP.php +++ b/modules/saml/lib/Auth/Source/SP.php @@ -193,7 +193,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source { } if (isset($state['saml:AuthnContextClassRef'])) { - $accr = SimpleSAML_Utils_Arrays::arrayize($state['saml:AuthnContextClassRef']); + $accr = SimpleSAML\Utils\Arrays::arrayize($state['saml:AuthnContextClassRef']); $ar->setRequestedAuthnContext(array('AuthnContextClassRef' => $accr)); } diff --git a/modules/statistics/lib/StatDataset.php b/modules/statistics/lib/StatDataset.php index 0533a2211557057d0ee0692118fdd3f1ca5ee672..916c502ab0a2e7886b763c8624ede9cc432509af 100644 --- a/modules/statistics/lib/StatDataset.php +++ b/modules/statistics/lib/StatDataset.php @@ -294,7 +294,7 @@ class sspmod_statistics_StatDataset { $statdir = $this->statconfig->getValue('statdir'); $resarray = array(); - $rules = SimpleSAML_Utils_Arrays::arrayize($this->ruleid); + $rules = SimpleSAML\Utils\Arrays::arrayize($this->ruleid); foreach($rules AS $rule) { // Get file and extract results. $resultFileName = $statdir . '/' . $rule . '-' . $this->timeres . '-'. $this->fileslot . '.stat'; diff --git a/tests/Utils/ArraysTest.php b/tests/Utils/ArraysTest.php index e43f5c28b95743c21c1106d34651fb4a0414d43d..1aa6ad43193168037a0a983e2c671d019ba35385 100644 --- a/tests/Utils/ArraysTest.php +++ b/tests/Utils/ArraysTest.php @@ -2,7 +2,7 @@ /** - * Tests for SimpleSAML_Utils_Arrays. + * Tests for SimpleSAML\Utils\Arrays. */ class Utils_ArraysTest extends PHPUnit_Framework_TestCase { @@ -14,23 +14,23 @@ class Utils_ArraysTest extends PHPUnit_Framework_TestCase { // check with empty array as input $array = array(); - $this->assertEquals($array, SimpleSAML_Utils_Arrays::arrayize($array)); + $this->assertEquals($array, SimpleSAML\Utils\Arrays::arrayize($array)); // check non-empty array as input $array = array('key' => 'value'); - $this->assertEquals($array, SimpleSAML_Utils_Arrays::arrayize($array)); + $this->assertEquals($array, SimpleSAML\Utils\Arrays::arrayize($array)); // check indexes are ignored when input is an array - $this->assertArrayNotHasKey('invalid', SimpleSAML_Utils_Arrays::arrayize($array, 'invalid')); + $this->assertArrayNotHasKey('invalid', SimpleSAML\Utils\Arrays::arrayize($array, 'invalid')); // check default index $expected = array('string'); - $this->assertEquals($expected, SimpleSAML_Utils_Arrays::arrayize($expected[0])); + $this->assertEquals($expected, SimpleSAML\Utils\Arrays::arrayize($expected[0])); // check string index $index = 'key'; $expected = array($index => 'string'); - $this->assertEquals($expected, SimpleSAML_Utils_Arrays::arrayize($expected[$index], $index)); + $this->assertEquals($expected, SimpleSAML\Utils\Arrays::arrayize($expected[$index], $index)); } /** @@ -40,7 +40,7 @@ class Utils_ArraysTest extends PHPUnit_Framework_TestCase */ public function testNormalizeAttributesArrayBadInput() { - SimpleSAML_Utils_Arrays::normalizeAttributesArray('string'); + SimpleSAML\Utils\Arrays::normalizeAttributesArray('string'); } /** @@ -50,7 +50,7 @@ class Utils_ArraysTest extends PHPUnit_Framework_TestCase */ public function testNormalizeAttributesArrayBadKeys() { - SimpleSAML_Utils_Arrays::normalizeAttributesArray(array('attr1' => 'value1', 1 => 'value2')); + SimpleSAML\Utils\Arrays::normalizeAttributesArray(array('attr1' => 'value1', 1 => 'value2')); } /** @@ -60,7 +60,7 @@ class Utils_ArraysTest extends PHPUnit_Framework_TestCase */ public function testNormalizeAttributesArrayBadValues() { - SimpleSAML_Utils_Arrays::normalizeAttributesArray(array('attr1' => 'value1', 'attr2' => 0)); + SimpleSAML\Utils\Arrays::normalizeAttributesArray(array('attr1' => 'value1', 'attr2' => 0)); } /** @@ -78,7 +78,7 @@ class Utils_ArraysTest extends PHPUnit_Framework_TestCase 'key2' => array('value2', 'value3'), 'key3' => array('value1') ); - $this->assertEquals($expected, SimpleSAML_Utils_Arrays::normalizeAttributesArray($attributes), + $this->assertEquals($expected, SimpleSAML\Utils\Arrays::normalizeAttributesArray($attributes), 'Attribute array normalization failed'); } @@ -89,9 +89,9 @@ class Utils_ArraysTest extends PHPUnit_Framework_TestCase public function testTranspose() { // check bad arrays - $this->assertFalse(SimpleSAML_Utils_Arrays::transpose(array('1', '2', '3')), + $this->assertFalse(SimpleSAML\Utils\Arrays::transpose(array('1', '2', '3')), 'Invalid two-dimensional array was accepted'); - $this->assertFalse(SimpleSAML_Utils_Arrays::transpose(array('1' => 0, '2' => '0', '3' => array(0))), + $this->assertFalse(SimpleSAML\Utils\Arrays::transpose(array('1' => 0, '2' => '0', '3' => array(0))), 'Invalid elements on a two-dimensional array were accepted'); // check array with numerical keys @@ -113,7 +113,7 @@ class Utils_ArraysTest extends PHPUnit_Framework_TestCase 'key2' => 'value2' ) ); - $this->assertEquals($transposed, SimpleSAML_Utils_Arrays::transpose($array), + $this->assertEquals($transposed, SimpleSAML\Utils\Arrays::transpose($array), 'Unexpected result of transpose()'); // check array with string keys @@ -135,7 +135,7 @@ class Utils_ArraysTest extends PHPUnit_Framework_TestCase 'key2' => 'value2' ) ); - $this->assertEquals($transposed, SimpleSAML_Utils_Arrays::transpose($array), + $this->assertEquals($transposed, SimpleSAML\Utils\Arrays::transpose($array), 'Unexpected result of transpose()'); // check array with no keys in common between sub arrays @@ -159,7 +159,7 @@ class Utils_ArraysTest extends PHPUnit_Framework_TestCase 'key2' => 'value2' ) ); - $this->assertEquals($transposed, SimpleSAML_Utils_Arrays::transpose($array), + $this->assertEquals($transposed, SimpleSAML\Utils\Arrays::transpose($array), 'Unexpected result of transpose()'); } } \ No newline at end of file diff --git a/www/admin/metadata-converter.php b/www/admin/metadata-converter.php index 2a6f075c88a23543f9fb5ba1c42053062c26889d..3cea4c6290f582064e59ad3b3e86e11878ea684d 100644 --- a/www/admin/metadata-converter.php +++ b/www/admin/metadata-converter.php @@ -25,7 +25,7 @@ if(array_key_exists('xmldata', $_POST)) { } /* Transpose from $entities[entityid][type] to $output[type][entityid]. */ - $output = SimpleSAML_Utils_Arrays::transpose($entities); + $output = SimpleSAML\Utils\Arrays::transpose($entities); /* Merge all metadata of each type to a single string which should be * added to the corresponding file.