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 |
||
129 | public function receive(ServerRequestInterface $request): AbstractMessage |
||
130 | { |
||
131 | $query = $request->getQueryParams(); |
||
132 | if (array_key_exists('SAMLart', $query)) { |
||
133 | $artifact = base64_decode($query['SAMLart'], true); |
||
134 | $endpointIndex = bin2hex(substr($artifact, 2, 2)); |
||
135 | $sourceId = bin2hex(substr($artifact, 4, 20)); |
||
136 | } else { |
||
137 | throw new Exception('Missing SAMLart parameter.'); |
||
138 | } |
||
139 | |||
140 | /** @psalm-suppress UndefinedClass */ |
||
141 | $metadataHandler = MetaDataStorageHandler::getMetadataHandler(Configuration::getInstance()); |
||
142 | |||
143 | $idpMetadata = $metadataHandler->getMetaDataConfigForSha1($sourceId, 'saml20-idp-remote'); |
||
144 | |||
145 | if ($idpMetadata === null) { |
||
146 | throw new Exception('No metadata found for remote provider with SHA1 ID: ' . var_export($sourceId, true)); |
||
147 | } |
||
148 | |||
149 | $endpoint = null; |
||
150 | foreach ($idpMetadata->getEndpoints('ArtifactResolutionService') as $ep) { |
||
151 | if ($ep['index'] === hexdec($endpointIndex)) { |
||
152 | $endpoint = $ep; |
||
153 | break; |
||
154 | } |
||
155 | } |
||
156 | |||
157 | if ($endpoint === null) { |
||
158 | throw new Exception('No ArtifactResolutionService with the correct index.'); |
||
159 | } |
||
160 | |||
161 | Utils::getContainer()->getLogger()->debug( |
||
162 | "ArtifactResolutionService endpoint being used is := " . $endpoint['Location'], |
||
163 | ); |
||
164 | |||
165 | /** |
||
166 | * @psalm-suppress UndefinedClass |
||
167 | * @psalm-suppress DocblockTypeContradiction |
||
168 | */ |
||
169 | Assert::notEmpty($this->spMetadata, 'Cannot process received message without SP metadata.'); |
||
170 | |||
171 | /** |
||
172 | * Set the request attributes |
||
173 | */ |
||
174 | $issuer = new Issuer($this->spMetadata->getString('entityid')); |
||
175 | |||
176 | // Construct the ArtifactResolve Request |
||
177 | $ar = new ArtifactResolve(new Artifact($artifact), null, $issuer, null, '2.0', $endpoint['Location']); |
||
178 | |||
179 | // sign the request |
||
180 | /** @psalm-suppress UndefinedClass */ |
||
181 | MSG::addSign($this->spMetadata, $idpMetadata, $ar); // Shoaib - moved from the SOAPClient. |
||
182 | |||
183 | $soap = new SOAPClient(); |
||
184 | |||
185 | // Send message through SoapClient |
||
186 | /** @var \SimpleSAML\SAML2\XML\samlp\ArtifactResponse $artifactResponse */ |
||
187 | $artifactResponse = $soap->send($ar, $this->spMetadata, $idpMetadata); |
||
188 | |||
189 | if (!$artifactResponse->isSuccess()) { |
||
190 | throw new Exception('Received error from ArtifactResolutionService.'); |
||
191 | } |
||
192 | |||
193 | $samlResponse = $artifactResponse->getMessage(); |
||
194 | if ($samlResponse === null) { |
||
195 | /* Empty ArtifactResponse - possibly because of Artifact replay? */ |
||
196 | |||
197 | throw new Exception('Empty ArtifactResponse received, maybe a replay?'); |
||
198 | } |
||
199 | |||
200 | $samlResponse->addValidator([get_class($this), 'validateSignature'], $artifactResponse); |
||
201 | |||
202 | $query = $request->getQueryParams(); |
||
203 | if (isset($query['RelayState'])) { |
||
204 | $this->setRelayState($query['RelayState']); |
||
205 | } |
||
206 | |||
207 | return $samlResponse; |
||
208 | } |
||
235 |
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