| Conditions | 9 |
| Paths | 17 |
| Total Lines | 79 |
| Code Lines | 36 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 126 | public function receive(ServerRequestInterface $request): AbstractMessage |
||
| 127 | { |
||
| 128 | $query = $request->getQueryParams(); |
||
| 129 | if (array_key_exists('SAMLart', $query)) { |
||
| 130 | $artifact = base64_decode($query['SAMLart'], true); |
||
| 131 | $endpointIndex = bin2hex(substr($artifact, 2, 2)); |
||
| 132 | $sourceId = bin2hex(substr($artifact, 4, 20)); |
||
| 133 | } else { |
||
| 134 | throw new Exception('Missing SAMLart parameter.'); |
||
| 135 | } |
||
| 136 | |||
| 137 | /** @psalm-suppress UndefinedClass */ |
||
| 138 | $metadataHandler = MetaDataStorageHandler::getMetadataHandler(Configuration::getInstance()); |
||
| 139 | |||
| 140 | $idpMetadata = $metadataHandler->getMetaDataConfigForSha1($sourceId, 'saml20-idp-remote'); |
||
| 141 | |||
| 142 | if ($idpMetadata === null) { |
||
| 143 | throw new Exception('No metadata found for remote provider with SHA1 ID: ' . var_export($sourceId, true)); |
||
| 144 | } |
||
| 145 | |||
| 146 | $endpoint = null; |
||
| 147 | foreach ($idpMetadata->getEndpoints('ArtifactResolutionService') as $ep) { |
||
| 148 | if ($ep['index'] === hexdec($endpointIndex)) { |
||
| 149 | $endpoint = $ep; |
||
| 150 | break; |
||
| 151 | } |
||
| 152 | } |
||
| 153 | |||
| 154 | if ($endpoint === null) { |
||
| 155 | throw new Exception('No ArtifactResolutionService with the correct index.'); |
||
| 156 | } |
||
| 157 | |||
| 158 | Utils::getContainer()->getLogger()->debug( |
||
| 159 | "ArtifactResolutionService endpoint being used is := " . $endpoint['Location'], |
||
| 160 | ); |
||
| 161 | |||
| 162 | /** |
||
| 163 | * @psalm-suppress UndefinedClass |
||
| 164 | * @psalm-suppress DocblockTypeContradiction |
||
| 165 | */ |
||
| 166 | Assert::notEmpty($this->spMetadata, 'Cannot process received message without SP metadata.'); |
||
| 167 | |||
| 168 | /** |
||
| 169 | * Set the request attributes |
||
| 170 | */ |
||
| 171 | $issuer = new Issuer($this->spMetadata->getString('entityid')); |
||
| 172 | |||
| 173 | // Construct the ArtifactResolve Request |
||
| 174 | $ar = new ArtifactResolve(new Artifact($artifact), null, $issuer, null, '2.0', $endpoint['Location']); |
||
| 175 | |||
| 176 | // sign the request |
||
| 177 | /** @psalm-suppress UndefinedClass */ |
||
| 178 | MSG::addSign($this->spMetadata, $idpMetadata, $ar); // Shoaib - moved from the SOAPClient. |
||
| 179 | |||
| 180 | $soap = new SOAPClient(); |
||
| 181 | |||
| 182 | // Send message through SoapClient |
||
| 183 | /** @var \SimpleSAML\SAML2\XML\samlp\ArtifactResponse $artifactResponse */ |
||
| 184 | $artifactResponse = $soap->send($ar, $this->spMetadata, $idpMetadata); |
||
| 185 | |||
| 186 | if (!$artifactResponse->isSuccess()) { |
||
| 187 | throw new Exception('Received error from ArtifactResolutionService.'); |
||
| 188 | } |
||
| 189 | |||
| 190 | $samlResponse = $artifactResponse->getMessage(); |
||
| 191 | if ($samlResponse === null) { |
||
| 192 | /* Empty ArtifactResponse - possibly because of Artifact replay? */ |
||
| 193 | |||
| 194 | throw new Exception('Empty ArtifactResponse received, maybe a replay?'); |
||
| 195 | } |
||
| 196 | |||
| 197 | $samlResponse->addValidator([get_class($this), 'validateSignature'], $artifactResponse); |
||
| 198 | |||
| 199 | $query = $request->getQueryParams(); |
||
| 200 | if (isset($query['RelayState'])) { |
||
| 201 | $this->setRelayState($query['RelayState']); |
||
| 202 | } |
||
| 203 | |||
| 204 | return $samlResponse; |
||
| 205 | } |
||
| 232 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths