diff options
author | Jaime Perez Crespo <jaime.perez@uninett.no> | 2015-04-20 16:42:49 +0200 |
---|---|---|
committer | Jaime Perez Crespo <jaime.perez@uninett.no> | 2015-04-20 16:42:49 +0200 |
commit | 2548d57bbeed95989d3d0a3997995224e516a817 (patch) | |
tree | 78ad4367faf071ca689c0a831324d53fa2cf0685 | |
parent | 4de6890754c2fe73056ea517eedd6dc2844068bd (diff) | |
download | simplesamlphp-2548d57bbeed95989d3d0a3997995224e516a817.zip simplesamlphp-2548d57bbeed95989d3d0a3997995224e516a817.tar.gz simplesamlphp-2548d57bbeed95989d3d0a3997995224e516a817.tar.bz2 |
Move SimpleSAML_Utils_Arrays to SimpleSAML\Utils\Arrays.
-rw-r--r-- | lib/SimpleSAML/Auth/LDAP.php | 2 | ||||
-rw-r--r-- | lib/SimpleSAML/Configuration.php | 2 | ||||
-rw-r--r-- | lib/SimpleSAML/Memcache.php | 2 | ||||
-rw-r--r-- | lib/SimpleSAML/Metadata/SAMLBuilder.php | 6 | ||||
-rw-r--r-- | lib/SimpleSAML/Utilities.php | 12 | ||||
-rw-r--r-- | lib/SimpleSAML/Utils/Arrays.php | 12 | ||||
-rw-r--r-- | modules/authcrypt/lib/Auth/Source/Hash.php | 2 | ||||
-rw-r--r-- | modules/authcrypt/lib/Auth/Source/Htpasswd.php | 2 | ||||
-rw-r--r-- | modules/consent/templates/consentform.php | 2 | ||||
-rw-r--r-- | modules/core/templates/frontpage_federation.tpl.php | 8 | ||||
-rw-r--r-- | modules/exampleauth/lib/Auth/Source/Static.php | 2 | ||||
-rw-r--r-- | modules/exampleauth/lib/Auth/Source/UserPass.php | 2 | ||||
-rw-r--r-- | modules/saml/lib/Auth/Source/SP.php | 2 | ||||
-rw-r--r-- | modules/statistics/lib/StatDataset.php | 2 | ||||
-rw-r--r-- | tests/Utils/ArraysTest.php | 30 | ||||
-rw-r--r-- | www/admin/metadata-converter.php | 2 |
16 files changed, 45 insertions, 45 deletions
diff --git a/lib/SimpleSAML/Auth/LDAP.php b/lib/SimpleSAML/Auth/LDAP.php index f7dbebd..50cd5da 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 a2108ee..88faf02 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 d420c33..791f43a 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 d79619f..d43d05f 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 e6a33a4..3d33065 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 029ee89..ec552bf 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 45d7d52..9bc0615 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 fb116ec..0ffa5ac 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 210fd46..e1ed91f 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 eb8795a..2be7e07 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 e6520ca..8355442 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 543cc1b..1b380de 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 a1779a1..0823d5b 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 0533a22..916c502 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 e43f5c2..1aa6ad4 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 2a6f075..3cea4c6 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. |