From 1b3fa6711f705728f62810e79b5927ea9a5f957b Mon Sep 17 00:00:00 2001 From: Tim van Dijen <tvdijen@gmail.com> Date: Sun, 26 Aug 2018 11:58:14 +0200 Subject: [PATCH] libs: PSR-2 --- lib/SimpleSAML/Auth/LDAP.php | 116 +++++++++++++----- lib/SimpleSAML/Auth/ProcessingChain.php | 18 +-- lib/SimpleSAML/Auth/Source.php | 6 +- lib/SimpleSAML/AuthMemCookie.php | 4 +- lib/SimpleSAML/Bindings/Shib13/Artifact.php | 5 +- lib/SimpleSAML/Configuration.php | 7 +- lib/SimpleSAML/Memcache.php | 4 +- .../Metadata/MetaDataStorageHandlerPdo.php | 9 +- .../MetaDataStorageHandlerSerialize.php | 4 +- .../Metadata/MetaDataStorageSource.php | 4 +- lib/SimpleSAML/Metadata/SAMLBuilder.php | 3 +- lib/SimpleSAML/Metadata/Signer.php | 4 +- lib/SimpleSAML/Utilities.php | 4 +- lib/SimpleSAML/Utils/Config/Metadata.php | 2 +- lib/SimpleSAML/XHTML/TemplateLoader.php | 3 +- lib/SimpleSAML/XML/Parser.php | 8 +- lib/SimpleSAML/XML/Shib13/AuthnRequest.php | 5 +- lib/SimpleSAML/XML/Shib13/AuthnResponse.php | 16 ++- 18 files changed, 157 insertions(+), 65 deletions(-) diff --git a/lib/SimpleSAML/Auth/LDAP.php b/lib/SimpleSAML/Auth/LDAP.php index 2e7bae494..575b23b9c 100644 --- a/lib/SimpleSAML/Auth/LDAP.php +++ b/lib/SimpleSAML/Auth/LDAP.php @@ -60,15 +60,21 @@ class LDAP * @param int $port * @param bool $referrals */ - public function __construct($hostname, $enable_tls = true, $debug = false, $timeout = 0, $port = 389, $referrals = true) - { + public function __construct( + $hostname, + $enable_tls = true, + $debug = false, + $timeout = 0, + $port = 389, + $referrals = true + ) { // Debug Logger::debug('Library - LDAP __construct(): Setup LDAP with '. - 'host=\''.$hostname. - '\', tls='.var_export($enable_tls, true). - ', debug='.var_export($debug, true). - ', timeout='.var_export($timeout, true). - ', referrals='.var_export($referrals, true)); + 'host=\''.$hostname. + '\', tls='.var_export($enable_tls, true). + ', debug='.var_export($debug, true). + ', timeout='.var_export($timeout, true). + ', referrals='.var_export($referrals, true)); /* * Set debug level before calling connect. Note that this passes @@ -77,7 +83,7 @@ class LDAP * OpenLDAP 2.x.x or Netscape Directory SDK x.x needed for this option. */ if ($debug && !ldap_set_option(null, LDAP_OPT_DEBUG_LEVEL, 7)) { - Logger::warning('Library - LDAP __construct(): Unable to set debug level (LDAP_OPT_DEBUG_LEVEL) to 7'); + Logger::warning('Library - LDAP __construct(): Unable to set debug level (LDAP_OPT_DEBUG_LEVEL) to 7'); } /* @@ -86,18 +92,27 @@ class LDAP */ $resource = @ldap_connect($hostname, $port); if ($resource === false) { - throw $this->makeException('Library - LDAP __construct(): Unable to connect to \''.$hostname.'\'', ERR_INTERNAL); + throw $this->makeException( + 'Library - LDAP __construct(): Unable to connect to \''.$hostname.'\'', + ERR_INTERNAL + ); } $this->ldap = $resource; // Enable LDAP protocol version 3 if (!@ldap_set_option($this->ldap, LDAP_OPT_PROTOCOL_VERSION, 3)) { - throw $this->makeException('Library - LDAP __construct(): Failed to set LDAP Protocol version (LDAP_OPT_PROTOCOL_VERSION) to 3', ERR_INTERNAL); + throw $this->makeException( + 'Library - LDAP __construct(): Failed to set LDAP Protocol version (LDAP_OPT_PROTOCOL_VERSION) to 3', + ERR_INTERNAL + ); } // Set referral option if (!@ldap_set_option($this->ldap, LDAP_OPT_REFERRALS, $referrals)) { - throw $this->makeException('Library - LDAP __construct(): Failed to set LDAP Referrals (LDAP_OPT_REFERRALS) to '.$referrals, ERR_INTERNAL); + throw $this->makeException( + 'Library - LDAP __construct(): Failed to set LDAP Referrals (LDAP_OPT_REFERRALS) to '.$referrals, + ERR_INTERNAL + ); } // Set timeouts, if supported @@ -105,10 +120,14 @@ class LDAP $this->timeout = $timeout; if ($timeout > 0) { if (!@ldap_set_option($this->ldap, LDAP_OPT_NETWORK_TIMEOUT, $timeout)) { - Logger::warning('Library - LDAP __construct(): Unable to set timeouts (LDAP_OPT_NETWORK_TIMEOUT) to '.$timeout); + Logger::warning( + 'Library - LDAP __construct(): Unable to set timeouts (LDAP_OPT_NETWORK_TIMEOUT) to '.$timeout + ); } if (!@ldap_set_option($this->ldap, LDAP_OPT_TIMELIMIT, $timeout)) { - Logger::warning('Library - LDAP __construct(): Unable to set timeouts (LDAP_OPT_TIMELIMIT) to '.$timeout); + Logger::warning( + 'Library - LDAP __construct(): Unable to set timeouts (LDAP_OPT_TIMELIMIT) to '.$timeout + ); } } @@ -164,7 +183,9 @@ class LDAP } else { if ($errNo !== 0) { $description .= '; cause: \''.ldap_error($this->ldap).'\' (0x'.dechex($errNo).')'; - if (@ldap_get_option($this->ldap, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extendedError) && !empty($extendedError)) { + if (@ldap_get_option($this->ldap, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extendedError) + && !empty($extendedError) + ) { $description .= '; additional: \''.$extendedError.'\''; } } @@ -233,14 +254,16 @@ class LDAP Logger::debug('Library - LDAP search(): Searching base ('.$scope.') \''.$base.'\' for \''.$filter.'\''); if ($scope === 'base') { $result = @ldap_read($this->ldap, $base, $filter, array(), 0, 0, $this->timeout, LDAP_DEREF_NEVER); - } else if ($scope === 'onelevel') { + } elseif ($scope === 'onelevel') { $result = @ldap_list($this->ldap, $base, $filter, array(), 0, 0, $this->timeout, LDAP_DEREF_NEVER); } else { $result = @ldap_search($this->ldap, $base, $filter, array(), 0, 0, $this->timeout, LDAP_DEREF_NEVER); } if ($result === false) { - throw $this->makeException('Library - LDAP search(): Failed search on base \''.$base.'\' for \''.$filter.'\''); + throw $this->makeException( + 'Library - LDAP search(): Failed search on base \''.$base.'\' for \''.$filter.'\'' + ); } // Sanity checks on search results @@ -249,21 +272,32 @@ class LDAP throw $this->makeException('Library - LDAP search(): Failed to get number of entries returned'); } elseif ($count > 1) { // More than one entry is found. External error - throw $this->makeException('Library - LDAP search(): Found '.$count.' entries searching base \''.$base.'\' for \''.$filter.'\'', ERR_AS_DATA_INCONSIST); + throw $this->makeException( + 'Library - LDAP search(): Found '.$count.' entries searching base \''.$base.'\' for \''.$filter.'\'', + ERR_AS_DATA_INCONSIST + ); } elseif ($count === 0) { // No entry is fond => wrong username is given (or not registered in the catalogue). User error - throw $this->makeException('Library - LDAP search(): Found no entries searching base \''.$base.'\' for \''.$filter.'\'', ERR_NO_USER); + throw $this->makeException( + 'Library - LDAP search(): Found no entries searching base \''.$base.'\' for \''.$filter.'\'', + ERR_NO_USER + ); } // Resolve the DN from the search result $entry = @ldap_first_entry($this->ldap, $result); if ($entry === false) { - throw $this->makeException('Library - LDAP search(): Unable to retrieve result after searching base \''.$base.'\' for \''.$filter.'\''); + throw $this->makeException( + 'Library - LDAP search(): Unable to retrieve result after searching base \''. + $base.'\' for \''.$filter.'\'' + ); } $dn = @ldap_get_dn($this->ldap, $entry); if ($dn === false) { - throw $this->makeException('Library - LDAP search(): Unable to get DN after searching base \''.$base.'\' for \''.$filter.'\''); + throw $this->makeException( + 'Library - LDAP search(): Unable to get DN after searching base \''.$base.'\' for \''.$filter.'\'' + ); } return $dn; } @@ -296,8 +330,14 @@ class LDAP * - $allowZeroHits is FALSE and no result is found * */ - public function searchfordn($base, $attribute, $value, $allowZeroHits = false, $searchFilter = null, $scope = 'subtree') - { + public function searchfordn( + $base, + $attribute, + $value, + $allowZeroHits = false, + $searchFilter = null, + $scope = 'subtree' + ) { // Traverse all search bases, returning DN if found $bases = \SimpleSAML\Utils\Arrays::arrayize($base); foreach ($bases as $current) { @@ -333,15 +373,22 @@ class LDAP * * @throws \Exception * @param string|array $bases - * @param string|array $filters Array of 'attribute' => 'values' to be combined into the filter, or a raw filter string + * @param string|array $filters Array of 'attribute' => 'values' to be combined into the filter, + * or a raw filter string * @param string|array $attributes Array of attributes requested from LDAP * @param bool $and If multiple filters defined, then either bind them with & or | * @param bool $escape Weather to escape the filter values or not * @param string $scope The scope of the search * @return array */ - public function searchformultiple($bases, $filters, $attributes = array(), $and = true, $escape = true, $scope = 'subtree') - { + public function searchformultiple( + $bases, + $filters, + $attributes = array(), + $and = true, + $escape = true, + $scope = 'subtree' + ) { // Escape the filter values, if requested if ($escape) { $filters = $this->escape_filter_value($filters, false); @@ -376,7 +423,7 @@ class LDAP foreach ($bases as $base) { if ($scope === 'base') { $result = @ldap_read($this->ldap, $base, $filter, $attributes, 0, 0, $this->timeout); - } else if ($scope === 'onelevel') { + } elseif ($scope === 'onelevel') { $result = @ldap_list($this->ldap, $base, $filter, $attributes, 0, 0, $this->timeout); } else { $result = @ldap_search($this->ldap, $base, $filter, $attributes, 0, 0, $this->timeout); @@ -575,7 +622,9 @@ class LDAP } $attributes = @ldap_get_attributes($this->ldap, $entry); // Recycling $attributes... Possibly bad practice. if ($attributes === false) { - throw $this->makeException('Library - LDAP getAttributes(): Could not get attributes of first entry from DN \''.$dn.'\''); + throw $this->makeException( + 'Library - LDAP getAttributes(): Could not get attributes of first entry from DN \''.$dn.'\'' + ); } // Parsing each found attribute into our result set @@ -598,7 +647,10 @@ class LDAP } // Base64 encode binary attributes - if (strtolower($name) === 'jpegphoto' || strtolower($name) === 'objectguid' || strtolower($name) === 'ms-ds-consistencyguid') { + if (strtolower($name) === 'jpegphoto' + || strtolower($name) === 'objectguid' + || strtolower($name) === 'ms-ds-consistencyguid' + ) { $values[] = base64_encode($value); } else { $values[] = $value; @@ -646,7 +698,9 @@ class LDAP // escape characters with a special meaning, also in the password $password = addcslashes($password, ',+"\\<>;*'); if (!$this->bind($dn, $password)) { - Logger::info('Library - LDAP validate(): Failed to authenticate \''.$username.'\' using DN \''.$dn.'\''); + Logger::info( + 'Library - LDAP validate(): Failed to authenticate \''.$username.'\' using DN \''.$dn.'\'' + ); return false; } } @@ -728,7 +782,7 @@ class LDAP /** * Convert SASL authz_id into a DN */ - private function authzid_to_dn($searchBase, $searchAttributes, $authz_id) + private function authzidToDn($searchBase, $searchAttributes, $authz_id) { if (preg_match("/^dn:/", $authz_id)) { return preg_replace("/^dn:/", "", $authz_id); @@ -773,7 +827,7 @@ class LDAP $authz_id = $this->authz_id; } - $dn = $this->authzid_to_dn($searchBase, $searchAttributes, $authz_id); + $dn = $this->authzidToDn($searchBase, $searchAttributes, $authz_id); if (!isset($dn) || ($dn == '')) { throw $this->makeException('Cannot figure userID'); diff --git a/lib/SimpleSAML/Auth/ProcessingChain.php b/lib/SimpleSAML/Auth/ProcessingChain.php index 2b1aa72d2..b265ccd08 100644 --- a/lib/SimpleSAML/Auth/ProcessingChain.php +++ b/lib/SimpleSAML/Auth/ProcessingChain.php @@ -151,7 +151,11 @@ class ProcessingChain throw new \Exception('Authentication processing filter without name given.'); } - $className = \SimpleSAML\Module::resolveClass($config['class'], 'Auth_Process', '\SimpleSAML\Auth\ProcessingFilter'); + $className = \SimpleSAML\Module::resolveClass( + $config['class'], + 'Auth_Process', + '\SimpleSAML\Auth\ProcessingFilter' + ); $config['%priority'] = $priority; unset($config['class']); return new $className($config, null); @@ -202,9 +206,9 @@ class ProcessingChain throw $e; } catch (\Exception $e) { /* - * To be consistent with the exception we return after an redirect, - * we convert this exception before returning it. - */ + * To be consistent with the exception we return after an redirect, + * we convert this exception before returning it. + */ throw new \SimpleSAML\Error\UnserializableException($e); } @@ -247,9 +251,9 @@ class ProcessingChain if (array_key_exists('ReturnURL', $state)) { /* - * Save state information, and redirect to the URL specified - * in $state['ReturnURL']. - */ + * Save state information, and redirect to the URL specified + * in $state['ReturnURL']. + */ $id = State::saveState($state, self::COMPLETED_STAGE); \SimpleSAML\Utils\HTTP::redirectTrustedURL($state['ReturnURL'], array(self::AUTHPARAM => $id)); } else { diff --git a/lib/SimpleSAML/Auth/Source.php b/lib/SimpleSAML/Auth/Source.php index 4569eae3c..a7dc11633 100644 --- a/lib/SimpleSAML/Auth/Source.php +++ b/lib/SimpleSAML/Auth/Source.php @@ -304,7 +304,11 @@ abstract class Source try { // Check whether or not there's a factory responsible for instantiating our Auth Source instance - $factoryClass = \SimpleSAML\Module::resolveClass($id, 'Auth_Source_Factory', '\SimpleSAML\Auth\SourceFactory'); + $factoryClass = \SimpleSAML\Module::resolveClass( + $id, + 'Auth_Source_Factory', + '\SimpleSAML\Auth\SourceFactory' + ); /** @var SourceFactory $factory */ $factory = new $factoryClass; diff --git a/lib/SimpleSAML/AuthMemCookie.php b/lib/SimpleSAML/AuthMemCookie.php index 1c5fb7c96..6b4455400 100644 --- a/lib/SimpleSAML/AuthMemCookie.php +++ b/lib/SimpleSAML/AuthMemCookie.php @@ -120,7 +120,9 @@ class AuthMemCookie $class = class_exists('Memcache') ? '\Memcache' : (class_exists('Memcached') ? '\Memcached' : false); if (!$class) { - throw new \Exception('Missing Memcached implementation. You must install either the Memcache or Memcached extension.'); + throw new \Exception( + 'Missing Memcached implementation. You must install either the Memcache or Memcached extension.' + ); } // Create the Memcache(d) object. diff --git a/lib/SimpleSAML/Bindings/Shib13/Artifact.php b/lib/SimpleSAML/Bindings/Shib13/Artifact.php index de15f364d..83df98925 100644 --- a/lib/SimpleSAML/Bindings/Shib13/Artifact.php +++ b/lib/SimpleSAML/Bindings/Shib13/Artifact.php @@ -140,7 +140,10 @@ class Artifact XML::debugSAMLMessage($request, 'out'); - $url = $idpMetadata->getDefaultEndpoint('ArtifactResolutionService', array('urn:oasis:names:tc:SAML:1.0:bindings:SOAP-binding')); + $url = $idpMetadata->getDefaultEndpoint( + 'ArtifactResolutionService', + array('urn:oasis:names:tc:SAML:1.0:bindings:SOAP-binding') + ); $url = $url['Location']; $peerPublicKeys = $idpMetadata->getPublicKeys('signing', true); diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index 7b0ad4543..48dc325c5 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -207,8 +207,11 @@ class Configuration implements Utils\ClearableState * @param string $filename The name of the configuration file. * @param string $configSet The configuration set. Optional, defaults to 'simplesaml'. */ - public static function setPreLoadedConfig(Configuration $config, $filename = 'config.php', $configSet = 'simplesaml') - { + public static function setPreLoadedConfig( + Configuration $config, + $filename = 'config.php', + $configSet = 'simplesaml' + ) { assert(is_string($filename)); assert(is_string($configSet)); diff --git a/lib/SimpleSAML/Memcache.php b/lib/SimpleSAML/Memcache.php index 1752e149e..0d82d5e32 100644 --- a/lib/SimpleSAML/Memcache.php +++ b/lib/SimpleSAML/Memcache.php @@ -306,7 +306,9 @@ class Memcache { $class = class_exists('\Memcache') ? '\Memcache' : (class_exists('\Memcached') ? '\Memcached' : false); if (!$class) { - throw new \Exception('Missing Memcached implementation. You must install either the Memcache or Memcached extension.'); + throw new \Exception( + 'Missing Memcached implementation. You must install either the Memcache or Memcached extension.' + ); } self::$extension = strtolower($class); diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php index f6f5cdb46..e5d182764 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerPdo.php @@ -142,9 +142,9 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource return $metadataSet; } - /** + /** * Retrieve a metadata entry. - * + * * @param string $entityId The entityId we are looking up. * @param string $set The set we are looking for metadata in. * @@ -162,7 +162,10 @@ class MetaDataStorageHandlerPdo extends MetaDataStorageSource return null; } - $stmt = $this->db->read("SELECT entity_id, entity_data FROM $tableName WHERE entity_id=:entityId", array('entityId' => $entityId)); + $stmt = $this->db->read( + "SELECT entity_id, entity_data FROM $tableName WHERE entity_id=:entityId", + array('entityId' => $entityId) + ); if ($stmt->execute()) { $rowCount = 0; $data = null; diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php index 7b9d478f5..9adae2f0b 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageHandlerSerialize.php @@ -130,7 +130,9 @@ class MetaDataStorageHandlerSerialize extends MetaDataStorageSource $dh = @opendir($dir); if ($dh === false) { - \SimpleSAML\Logger::warning('Serialize metadata handler: Unable to open directory: '.var_export($dir, true)); + \SimpleSAML\Logger::warning( + 'Serialize metadata handler: Unable to open directory: '.var_export($dir, true) + ); return $ret; } diff --git a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php index 360b619ce..c692b4a70 100644 --- a/lib/SimpleSAML/Metadata/MetaDataStorageSource.php +++ b/lib/SimpleSAML/Metadata/MetaDataStorageSource.php @@ -184,8 +184,8 @@ abstract class MetaDataStorageSource } // support discohints in idp metadata for idp discovery - if (array_key_exists('DiscoHints', $entry) - && array_key_exists('IPHint', $entry['DiscoHints']) + if (array_key_exists('DiscoHints', $entry) + && array_key_exists('IPHint', $entry['DiscoHints']) && is_array($entry['DiscoHints']['IPHint'])) { // merge with hints derived from discohints, but prioritize hint.cidr in case it is used $cidrHints = array_merge($entry['DiscoHints']['IPHint'], $cidrHints); diff --git a/lib/SimpleSAML/Metadata/SAMLBuilder.php b/lib/SimpleSAML/Metadata/SAMLBuilder.php index 0c6c7869b..4bb4c5b92 100644 --- a/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -321,7 +321,8 @@ class SAMLBuilder * @param array $endpoints The endpoints. * @param bool $indexed Whether the endpoints should be indexed. * - * @return array An array of endpoint objects, either \SAML2\XML\md\EndpointType or \SAML2\XML\md\IndexedEndpointType. + * @return array An array of endpoint objects, + * either \SAML2\XML\md\EndpointType or \SAML2\XML\md\IndexedEndpointType. */ private static function createEndpoints(array $endpoints, $indexed) { diff --git a/lib/SimpleSAML/Metadata/Signer.php b/lib/SimpleSAML/Metadata/Signer.php index eb87586ac..1cb042017 100644 --- a/lib/SimpleSAML/Metadata/Signer.php +++ b/lib/SimpleSAML/Metadata/Signer.php @@ -229,7 +229,9 @@ class Signer $keyFile = \SimpleSAML\Utils\Config::getCertPath($keyCertFiles['privatekey']); if (!file_exists($keyFile)) { - throw new \Exception('Could not find private key file ['.$keyFile.'], which is needed to sign the metadata'); + throw new \Exception( + 'Could not find private key file ['.$keyFile.'], which is needed to sign the metadata' + ); } $keyData = file_get_contents($keyFile); diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index d253408f1..0a830bb44 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -191,7 +191,7 @@ class Utilities } - private static function _doRedirect($url, $parameters = array()) + private static function doRedirect($url, $parameters = array()) { assert(is_string($url)); assert(!empty($url)); @@ -264,7 +264,7 @@ class Utilities } else { $url = self::normalizeURL($url); } - self::_doRedirect($url, $parameters); + self::doRedirect($url, $parameters); } diff --git a/lib/SimpleSAML/Utils/Config/Metadata.php b/lib/SimpleSAML/Utils/Config/Metadata.php index 88704151d..5cecde300 100644 --- a/lib/SimpleSAML/Utils/Config/Metadata.php +++ b/lib/SimpleSAML/Utils/Config/Metadata.php @@ -106,7 +106,7 @@ class Metadata // check the type if (!isset($contact['contactType']) || !in_array($contact['contactType'], self::$VALID_CONTACT_TYPES, true)) { $types = join(', ', array_map( - function($t) { + function ($t) { return '"'.$t.'"'; }, self::$VALID_CONTACT_TYPES diff --git a/lib/SimpleSAML/XHTML/TemplateLoader.php b/lib/SimpleSAML/XHTML/TemplateLoader.php index d3a9f853c..1d21966c4 100644 --- a/lib/SimpleSAML/XHTML/TemplateLoader.php +++ b/lib/SimpleSAML/XHTML/TemplateLoader.php @@ -58,8 +58,7 @@ class TemplateLoader extends \Twig\Loader\FilesystemLoader $templatedir = $moduledir.'/templates'; if (!is_dir($templatedir)) { throw new \InvalidArgumentException('The module \''.$module.'\' has no templates directory.'); - } return $templatedir; } -} \ No newline at end of file +} diff --git a/lib/SimpleSAML/XML/Parser.php b/lib/SimpleSAML/XML/Parser.php index b71a87362..39287b2cb 100644 --- a/lib/SimpleSAML/XML/Parser.php +++ b/lib/SimpleSAML/XML/Parser.php @@ -52,7 +52,9 @@ class Parser $result = $this->simplexml->xpath($xpath); if (!is_array($result) || empty($result)) { if ($required) { - throw new \Exception('Could not get value from XML document using the following XPath expression: '.$xpath); + throw new \Exception( + 'Could not get value from XML document using the following XPath expression: '.$xpath + ); } else { return null; } @@ -69,7 +71,9 @@ class Parser } } if ($required) { - throw new \Exception('Could not get value from XML document using multiple alternative XPath expressions.'); + throw new \Exception( + 'Could not get value from XML document using multiple alternative XPath expressions.' + ); } else { return null; } diff --git a/lib/SimpleSAML/XML/Shib13/AuthnRequest.php b/lib/SimpleSAML/XML/Shib13/AuthnRequest.php index 717e2ff6a..6c4fe7c7b 100644 --- a/lib/SimpleSAML/XML/Shib13/AuthnRequest.php +++ b/lib/SimpleSAML/XML/Shib13/AuthnRequest.php @@ -39,7 +39,10 @@ class AuthnRequest $metadata = \SimpleSAML\Metadata\MetaDataStorageHandler::getMetadataHandler(); $idpmetadata = $metadata->getMetaDataConfig($destination, 'shib13-idp-remote'); - $desturl = $idpmetadata->getDefaultEndpoint('SingleSignOnService', array('urn:mace:shibboleth:1.0:profiles:AuthnRequest')); + $desturl = $idpmetadata->getDefaultEndpoint( + 'SingleSignOnService', + array('urn:mace:shibboleth:1.0:profiles:AuthnRequest') + ); $desturl = $desturl['Location']; $target = $this->getRelayState(); diff --git a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php index d10c91fc9..e6d1a20ad 100644 --- a/lib/SimpleSAML/XML/Shib13/AuthnResponse.php +++ b/lib/SimpleSAML/XML/Shib13/AuthnResponse.php @@ -119,7 +119,9 @@ class AuthnResponse // Validate against CA $this->validator->validateCA(Config::getCertPath($md->getString('caFile'))); } else { - throw new \SimpleSAML\Error\Exception('Missing certificate in Shibboleth 1.3 IdP Remote metadata for identity provider ['.$issuer.'].'); + throw new \SimpleSAML\Error\Exception( + 'Missing certificate in Shibboleth 1.3 IdP Remote metadata for identity provider ['.$issuer.'].' + ); } return true; @@ -233,7 +235,10 @@ class AuthnResponse } } - $attribute_nodes = $this->doXPathQuery('shib:AttributeStatement/shib:Attribute/shib:AttributeValue', $assertion); + $attribute_nodes = $this->doXPathQuery( + 'shib:AttributeStatement/shib:Attribute/shib:AttributeValue', + $assertion + ); /** @var \DOMElement $attribute */ foreach ($attribute_nodes as $attribute) { $value = $attribute->textContent; @@ -358,7 +363,7 @@ class AuthnResponse $encodedattributes .= $subjectNode; foreach ($attributes as $name => $value) { - $encodedattributes .= $this->enc_attribute($name, $value, $base64, $scopedAttributes); + $encodedattributes .= $this->encAttribute($name, $value, $base64, $scopedAttributes); } $encodedattributes .= '</AttributeStatement>'; @@ -405,7 +410,7 @@ class AuthnResponse * @param array $scopedAttributes Array of attributes names which are scoped. * @return string The attribute encoded as an XML-string. */ - private function enc_attribute($name, $values, $base64, $scopedAttributes) + private function encAttribute($name, $values, $base64, $scopedAttributes) { assert(is_string($name)); assert(is_array($values)); @@ -418,7 +423,8 @@ class AuthnResponse $scoped = false; } - $attr = '<Attribute AttributeName="'.htmlspecialchars($name).'" AttributeNamespace="urn:mace:shibboleth:1.0:attributeNamespace:uri">'; + $attr = '<Attribute AttributeName="'.htmlspecialchars($name). + '" AttributeNamespace="urn:mace:shibboleth:1.0:attributeNamespace:uri">'; foreach ($values as $value) { $scopePart = ''; if ($scoped) { -- GitLab