Conditions | 9 |
Paths | 17 |
Total Lines | 69 |
Code Lines | 35 |
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 |
||
91 | public function receive() |
||
92 | { |
||
93 | if (array_key_exists('SAMLart', $_REQUEST)) { |
||
94 | $artifact = base64_decode($_REQUEST['SAMLart']); |
||
95 | $endpointIndex = bin2hex(substr($artifact, 2, 2)); |
||
96 | $sourceId = bin2hex(substr($artifact, 4, 20)); |
||
97 | } else { |
||
98 | throw new \Exception('Missing SAMLart parameter.'); |
||
99 | } |
||
100 | |||
101 | $metadataHandler = MetaDataStorageHandler::getMetadataHandler(); |
||
102 | |||
103 | $idpMetadata = $metadataHandler->getMetaDataConfigForSha1($sourceId, 'saml20-idp-remote'); |
||
104 | |||
105 | if ($idpMetadata === null) { |
||
106 | throw new \Exception('No metadata found for remote provider with SHA1 ID: '.var_export($sourceId, true)); |
||
107 | } |
||
108 | |||
109 | $endpoint = null; |
||
110 | foreach ($idpMetadata->getEndpoints('ArtifactResolutionService') as $ep) { |
||
111 | if ($ep['index'] === hexdec($endpointIndex)) { |
||
112 | $endpoint = $ep; |
||
113 | break; |
||
114 | } |
||
115 | } |
||
116 | |||
117 | if ($endpoint === null) { |
||
118 | throw new \Exception('No ArtifactResolutionService with the correct index.'); |
||
119 | } |
||
120 | |||
121 | Utils::getContainer()->getLogger()->debug("ArtifactResolutionService endpoint being used is := ".$endpoint['Location']); |
||
122 | |||
123 | //Construct the ArtifactResolve Request |
||
124 | $ar = new ArtifactResolve(); |
||
125 | |||
126 | /* Set the request attributes */ |
||
127 | |||
128 | $ar->setIssuer($this->spMetadata->getString('entityid')); |
||
129 | $ar->setArtifact($_REQUEST['SAMLart']); |
||
130 | $ar->setDestination($endpoint['Location']); |
||
131 | |||
132 | /* Sign the request */ |
||
133 | \SimpleSAML\Module\saml\Message::addSign($this->spMetadata, $idpMetadata, $ar); // Shoaib - moved from the SOAPClient. |
||
1 ignored issue
–
show
|
|||
134 | |||
135 | $soap = new SOAPClient(); |
||
136 | |||
137 | // Send message through SoapClient |
||
138 | /** @var \SAML2\ArtifactResponse $artifactResponse */ |
||
139 | $artifactResponse = $soap->send($ar, $this->spMetadata); |
||
140 | |||
141 | if (!$artifactResponse->isSuccess()) { |
||
142 | throw new \Exception('Received error from ArtifactResolutionService.'); |
||
143 | } |
||
144 | |||
145 | $xml = $artifactResponse->getAny(); |
||
146 | if ($xml === null) { |
||
147 | /* Empty ArtifactResponse - possibly because of Artifact replay? */ |
||
148 | |||
149 | throw new \Exception('Empty ArtifactResponse received, maybe a replay?'); |
||
150 | } |
||
151 | |||
152 | $samlResponse = Message::fromXML($xml); |
||
153 | $samlResponse->addValidator([get_class($this), 'validateSignature'], $artifactResponse); |
||
154 | |||
155 | if (isset($_REQUEST['RelayState'])) { |
||
156 | $samlResponse->setRelayState($_REQUEST['RelayState']); |
||
157 | } |
||
158 | |||
159 | return $samlResponse; |
||
160 | } |
||
185 |
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