| Conditions | 31 |
| Paths | 672 |
| Total Lines | 206 |
| Code Lines | 83 |
| 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 |
||
| 128 | private function prepareEapConfig($attr) |
||
| 129 | { |
||
| 130 | $outerUser = ''; |
||
| 131 | $vistaExt = ''; |
||
| 132 | $w7Ext = ''; |
||
| 133 | $useAnon = isset($attr['internal:use_anon_outer']) && $attr['internal:use_anon_outer'][0] == "1" && isset($attr['internal:realm']) ? true : false; |
||
| 134 | $useAnon = $attr['internal:use_anon_outer'] [0]; |
||
| 135 | $realm = $attr['internal:realm'] [0]; |
||
| 136 | if ($useAnon) { |
||
| 137 | $outerUser = $attr['internal:anon_local_value'][0]; |
||
| 138 | } |
||
| 139 | // $servers = preg_quote(implode(';',$attr['eap:server_name'])); |
||
| 140 | $servers = implode(';', $attr['eap:server_name']); |
||
| 141 | $caArray = $attr['internal:CAs'][0]; |
||
| 142 | $authorId = "0"; |
||
| 143 | if ($this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_PAP || $this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_MSCHAP2) { |
||
| 144 | $authorId = "67532"; |
||
| 145 | $servers = implode('</ServerName><ServerName>', $attr['eap:server_name']); |
||
| 146 | } |
||
| 147 | |||
| 148 | $profileFileCont = '<EAPConfig><EapHostConfig xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
||
| 149 | <EapMethod> |
||
| 150 | <Type xmlns="http://www.microsoft.com/provisioning/EapCommon">' . |
||
| 151 | $this->selectedEap["OUTER"] . '</Type> |
||
| 152 | <VendorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorId> |
||
| 153 | <VendorType xmlns="http://www.microsoft.com/provisioning/EapCommon">0</VendorType> |
||
| 154 | <AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">' . $authorId . '</AuthorId> |
||
| 155 | </EapMethod> |
||
| 156 | '; |
||
| 157 | |||
| 158 | |||
| 159 | if ($this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_PAP || $this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_MSCHAP2) { |
||
| 160 | $innerMethod = 'MSCHAPv2'; |
||
| 161 | if ($this->selectedEap == \core\common\EAP::EAPTYPE_TTLS_PAP) { |
||
| 162 | $innerMethod = 'PAP'; |
||
| 163 | } |
||
| 164 | $profileFileCont .= ' |
||
| 165 | <Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
||
| 166 | <EAPIdentityProviderList xmlns="urn:ietf:params:xml:ns:yang:ietf-eap-metadata"> |
||
| 167 | <EAPIdentityProvider ID="' . $this->deviceUUID . '" namespace="urn:UUID"> |
||
| 168 | <ProviderInfo> |
||
| 169 | <DisplayName>' . $this->translateString($attr['general:instname'][0]) . '</DisplayName> |
||
| 170 | </ProviderInfo> |
||
| 171 | <AuthenticationMethods> |
||
| 172 | <AuthenticationMethod> |
||
| 173 | <EAPMethod>21</EAPMethod> |
||
| 174 | <ClientSideCredential> |
||
| 175 | <allow-save>true</allow-save> |
||
| 176 | '; |
||
| 177 | if ($useAnon) { |
||
| 178 | if ($outerUser == '') { |
||
| 179 | $profileFileCont .= '<AnonymousIdentity>@</AnonymousIdentity>'; |
||
| 180 | } else { |
||
| 181 | $profileFileCont .= '<AnonymousIdentity>' . $outerUser . '@' . $realm . '</AnonymousIdentity>'; |
||
| 182 | } |
||
| 183 | } |
||
| 184 | $profileFileCont .= '</ClientSideCredential> |
||
| 185 | <ServerSideCredential> |
||
| 186 | '; |
||
| 187 | |||
| 188 | foreach ($caArray as $ca) { |
||
| 189 | $profileFileCont .= '<CA><format>PEM</format><cert-data>'; |
||
| 190 | $profileFileCont .= base64_encode($ca['der']); |
||
| 191 | $profileFileCont .= '</cert-data></CA> |
||
| 192 | '; |
||
| 193 | } |
||
| 194 | $profileFileCont .= "<ServerName>$servers</ServerName>\n"; |
||
| 195 | |||
| 196 | $profileFileCont .= ' |
||
| 197 | </ServerSideCredential> |
||
| 198 | <InnerAuthenticationMethod> |
||
| 199 | <NonEAPAuthMethod>' .$innerMethod. '</NonEAPAuthMethod> |
||
| 200 | </InnerAuthenticationMethod> |
||
| 201 | <VendorSpecific> |
||
| 202 | <SessionResumption>false</SessionResumption> |
||
| 203 | </VendorSpecific> |
||
| 204 | </AuthenticationMethod> |
||
| 205 | </AuthenticationMethods> |
||
| 206 | </EAPIdentityProvider> |
||
| 207 | </EAPIdentityProviderList> |
||
| 208 | </Config> |
||
| 209 | '; |
||
| 210 | } elseif ($this->selectedEap == \core\common\EAP::EAPTYPE_TLS || $this->selectedEap == \core\common\EAP::EAPTYPE_SILVERBULLET) { |
||
| 211 | |||
| 212 | $profileFileCont .= ' |
||
| 213 | |||
| 214 | <Config xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" |
||
| 215 | xmlns:eapTls="http://www.microsoft.com/provisioning/EapTlsConnectionPropertiesV1"> |
||
| 216 | <baseEap:Eap> |
||
| 217 | <baseEap:Type>13</baseEap:Type> |
||
| 218 | <eapTls:EapType> |
||
| 219 | <eapTls:CredentialsSource> |
||
| 220 | <eapTls:CertificateStore /> |
||
| 221 | </eapTls:CredentialsSource> |
||
| 222 | <eapTls:ServerValidation> |
||
| 223 | <eapTls:DisableUserPromptForServerValidation>true</eapTls:DisableUserPromptForServerValidation> |
||
| 224 | <eapTls:ServerNames>' . $servers . '</eapTls:ServerNames>'; |
||
| 225 | if ($caArray) { |
||
| 226 | foreach ($caArray as $certAuthority) { |
||
| 227 | if ($certAuthority['root']) { |
||
| 228 | $profileFileCont .= "<eapTls:TrustedRootCA>" . $certAuthority['sha1'] . "</eapTls:TrustedRootCA>\n"; |
||
| 229 | } |
||
| 230 | } |
||
| 231 | } |
||
| 232 | $profileFileCont .= '</eapTls:ServerValidation> |
||
| 233 | '; |
||
| 234 | if (isset($attr['eap-specific:tls_use_other_id']) && $attr['eap-specific:tls_use_other_id'][0] == 'on') { |
||
| 235 | $profileFileCont .= '<eapTls:DifferentUsername>true</eapTls:DifferentUsername>'; |
||
| 236 | $this->tlsOtherUsername = true; |
||
| 237 | } else { |
||
| 238 | $profileFileCont .= '<eapTls:DifferentUsername>false</eapTls:DifferentUsername>'; |
||
| 239 | } |
||
| 240 | $profileFileCont .= ' |
||
| 241 | </eapTls:EapType> |
||
| 242 | </baseEap:Eap> |
||
| 243 | </Config> |
||
| 244 | '; |
||
| 245 | } elseif ($this->selectedEap == \core\common\EAP::EAPTYPE_PEAP_MSCHAP2) { |
||
| 246 | if (isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on') { |
||
| 247 | $nea = 'true'; |
||
| 248 | } else { |
||
| 249 | $nea = 'false'; |
||
| 250 | } |
||
| 251 | $vistaExt = '<Config xmlns:eapUser="http://www.microsoft.com/provisioning/EapUserPropertiesV1" |
||
| 252 | xmlns:baseEap="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1" |
||
| 253 | xmlns:msPeap="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1" |
||
| 254 | xmlns:msChapV2="http://www.microsoft.com/provisioning/MsChapV2ConnectionPropertiesV1"> |
||
| 255 | <baseEap:Eap> |
||
| 256 | <baseEap:Type>25</baseEap:Type> |
||
| 257 | <msPeap:EapType> |
||
| 258 | <msPeap:ServerValidation> |
||
| 259 | <msPeap:DisableUserPromptForServerValidation>true</msPeap:DisableUserPromptForServerValidation> |
||
| 260 | <msPeap:ServerNames>' . $servers . '</msPeap:ServerNames>'; |
||
| 261 | if ($caArray) { |
||
| 262 | foreach ($caArray as $certAuthority) { |
||
| 263 | if ($certAuthority['root']) { |
||
| 264 | $vistaExt .= "<msPeap:TrustedRootCA>" . $certAuthority['sha1'] . "</msPeap:TrustedRootCA>\n"; |
||
| 265 | } |
||
| 266 | } |
||
| 267 | } |
||
| 268 | $vistaExt .= '</msPeap:ServerValidation> |
||
| 269 | <msPeap:FastReconnect>true</msPeap:FastReconnect> |
||
| 270 | <msPeap:InnerEapOptional>0</msPeap:InnerEapOptional> |
||
| 271 | <baseEap:Eap> |
||
| 272 | <baseEap:Type>26</baseEap:Type> |
||
| 273 | <msChapV2:EapType> |
||
| 274 | <msChapV2:UseWinLogonCredentials>false</msChapV2:UseWinLogonCredentials> |
||
| 275 | </msChapV2:EapType> |
||
| 276 | </baseEap:Eap> |
||
| 277 | <msPeap:EnableQuarantineChecks>' . $nea . '</msPeap:EnableQuarantineChecks> |
||
| 278 | <msPeap:RequireCryptoBinding>false</msPeap:RequireCryptoBinding> |
||
| 279 | </msPeap:EapType> |
||
| 280 | </baseEap:Eap> |
||
| 281 | </Config> |
||
| 282 | '; |
||
| 283 | $w7Ext = '<Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig"> |
||
| 284 | <Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1"> |
||
| 285 | <Type>25</Type> |
||
| 286 | <EapType xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1"> |
||
| 287 | <ServerValidation> |
||
| 288 | <DisableUserPromptForServerValidation>true</DisableUserPromptForServerValidation> |
||
| 289 | <ServerNames>' . $servers . '</ServerNames>'; |
||
| 290 | if ($caArray) { |
||
| 291 | foreach ($caArray as $certAuthority) { |
||
| 292 | if ($certAuthority['root']) { |
||
| 293 | $w7Ext .= "<TrustedRootCA>" . $certAuthority['sha1'] . "</TrustedRootCA>\n"; |
||
| 294 | } |
||
| 295 | } |
||
| 296 | } |
||
| 297 | $w7Ext .= '</ServerValidation> |
||
| 298 | <FastReconnect>true</FastReconnect> |
||
| 299 | <InnerEapOptional>false</InnerEapOptional> |
||
| 300 | <Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1"> |
||
| 301 | <Type>26</Type> |
||
| 302 | <EapType xmlns="http://www.microsoft.com/provisioning/MsChapV2ConnectionPropertiesV1"> |
||
| 303 | <UseWinLogonCredentials>false</UseWinLogonCredentials> |
||
| 304 | </EapType> |
||
| 305 | </Eap> |
||
| 306 | <EnableQuarantineChecks>' . $nea . '</EnableQuarantineChecks> |
||
| 307 | <RequireCryptoBinding>false</RequireCryptoBinding> |
||
| 308 | '; |
||
| 309 | if ($useAnon) { |
||
| 310 | $w7Ext .= '<PeapExtensions> |
||
| 311 | <IdentityPrivacy xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2"> |
||
| 312 | <EnableIdentityPrivacy>true</EnableIdentityPrivacy> |
||
| 313 | <AnonymousUserName>' . $outerUser . '</AnonymousUserName> |
||
| 314 | </IdentityPrivacy> |
||
| 315 | </PeapExtensions> |
||
| 316 | '; |
||
| 317 | } |
||
| 318 | $w7Ext .= '</EapType> |
||
| 319 | </Eap> |
||
| 320 | </Config> |
||
| 321 | '; |
||
| 322 | } elseif ($this->selectedEap == \core\common\EAP::EAPTYPE_PWD) { |
||
| 323 | $profileFileCont .= '<ConfigBlob></ConfigBlob>'; |
||
| 324 | } |
||
| 325 | |||
| 326 | |||
| 327 | |||
| 328 | $profileFileContEnd = '</EapHostConfig></EAPConfig> |
||
| 329 | '; |
||
| 330 | $returnArray = []; |
||
| 331 | $returnArray['vista'] = $profileFileCont . $vistaExt . $profileFileContEnd; |
||
| 332 | $returnArray['w7'] = $profileFileCont . $w7Ext . $profileFileContEnd; |
||
| 333 | return $returnArray; |
||
| 334 | } |
||
| 552 |
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