Code Duplication    Length = 53-56 lines in 2 locations

devices/ms/Device_W8.php 1 location

@@ 165-220 (lines=56) @@
162
</baseEap:Eap>
163
</Config>
164
';
165
        } elseif ($eap == \core\common\EAP::EAPTYPE_PEAP_MSCHAP2) {
166
            if (isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on') {
167
                $nea = 'true';
168
            } else {
169
                $nea = 'false';
170
            }
171
            $profileFileCont .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">0</AuthorId>
172
</EapMethod>
173
';
174
            $w8Ext = '<Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
175
<Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1">
176
<Type>25</Type>
177
<EapType xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1">
178
<ServerValidation>
179
<DisableUserPromptForServerValidation>true</DisableUserPromptForServerValidation>
180
<ServerNames>' . $servers . '</ServerNames>';
181
            if ($caArray) {
182
                foreach ($caArray as $certAuthority) {
183
                    if ($certAuthority['root']) {
184
                        $w8Ext .= "<TrustedRootCA>" . $certAuthority['sha1'] . "</TrustedRootCA>\n";
185
                    }
186
                }
187
            }
188
            $w8Ext .= '</ServerValidation>
189
<FastReconnect>true</FastReconnect> 
190
<InnerEapOptional>false</InnerEapOptional> 
191
<Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1">
192
<Type>26</Type>
193
<EapType xmlns="http://www.microsoft.com/provisioning/MsChapV2ConnectionPropertiesV1">
194
<UseWinLogonCredentials>false</UseWinLogonCredentials> 
195
</EapType>
196
</Eap>
197
<EnableQuarantineChecks>' . $nea . '</EnableQuarantineChecks>
198
<RequireCryptoBinding>false</RequireCryptoBinding>
199
';
200
            if ($useAnon == 1) {
201
                $w8Ext .= '<PeapExtensions>
202
<IdentityPrivacy xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2">
203
<EnableIdentityPrivacy>true</EnableIdentityPrivacy>
204
';
205
                if (isset($outerUser) && $outerUser) {
206
                    $w8Ext .= '<AnonymousUserName>' . $outerUser . '</AnonymousUserName>
207
                ';
208
                } else {
209
                    $w8Ext .= '<AnonymousUserName/>
210
                ';
211
                }
212
                $w8Ext .= '</IdentityPrivacy>
213
</PeapExtensions>
214
';
215
            }
216
            $w8Ext .= '</EapType>
217
</Eap>
218
</Config>
219
';
220
        } elseif ($eap == \core\common\EAP::EAPTYPE_TTLS_PAP || $eap == \core\common\EAP::EAPTYPE_TTLS_MSCHAP2) {
221
            $profileFileCont .= '<AuthorId xmlns="http://www.microsoft.com/provisioning/EapCommon">311</AuthorId>
222
</EapMethod>
223
';

devices/ms/Device_W10.php 1 location

@@ 181-233 (lines=53) @@
178
</baseEap:Eap>
179
</Config>
180
';
181
        } elseif ($eap == \core\common\EAP::EAPTYPE_PEAP_MSCHAP2) {
182
            if (isset($attr['eap:enable_nea']) && $attr['eap:enable_nea'][0] == 'on') {
183
                $nea = 'true';
184
            } else {
185
                $nea = 'false';
186
            }
187
            $w10Ext = '<Config xmlns="http://www.microsoft.com/provisioning/EapHostConfig">
188
<Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1">
189
<Type>25</Type>
190
<EapType xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1">
191
<ServerValidation>
192
<DisableUserPromptForServerValidation>true</DisableUserPromptForServerValidation>
193
<ServerNames>' . $servers . '</ServerNames>';
194
            if ($caArray) {
195
                foreach ($caArray as $certAuthority) {
196
                    if ($certAuthority['root']) {
197
                        $w10Ext .= "<TrustedRootCA>" . $certAuthority['sha1'] . "</TrustedRootCA>\n";
198
                    }
199
                }
200
            }
201
            $w10Ext .= '</ServerValidation>
202
<FastReconnect>true</FastReconnect> 
203
<InnerEapOptional>false</InnerEapOptional>
204
<Eap xmlns="http://www.microsoft.com/provisioning/BaseEapConnectionPropertiesV1">
205
<Type>26</Type>
206
<EapType xmlns="http://www.microsoft.com/provisioning/MsChapV2ConnectionPropertiesV1">
207
<UseWinLogonCredentials>false</UseWinLogonCredentials> 
208
</EapType>
209
</Eap>
210
<EnableQuarantineChecks>' . $nea . '</EnableQuarantineChecks>
211
<RequireCryptoBinding>false</RequireCryptoBinding>
212
';
213
            if ($useAnon == 1) {
214
                $w10Ext .= '<PeapExtensions>
215
<IdentityPrivacy xmlns="http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2">
216
<EnableIdentityPrivacy>true</EnableIdentityPrivacy>
217
';
218
                if (isset($outerUser) && $outerUser) {
219
                    $w10Ext .= '<AnonymousUserName>' . $outerUser . '</AnonymousUserName>
220
                ';
221
                } else {
222
                    $w10Ext .= '<AnonymousUserName/>
223
                ';
224
                }
225
                $w10Ext .= '</IdentityPrivacy>
226
</PeapExtensions>
227
';
228
            }
229
            $w10Ext .= '</EapType>
230
</Eap>
231
</Config>
232
';
233
        } elseif ($eap == \core\common\EAP::EAPTYPE_TTLS_PAP || $eap == \core\common\EAP::EAPTYPE_TTLS_MSCHAP2) {
234
            if ($this->useGeantLink) {
235
                $innerMethod = 'MSCHAPv2';
236
                if ($eap == \core\common\EAP::EAPTYPE_TTLS_PAP) {