Test Setup Failed
Push — master ( de37f4...b19653 )
by Tomasz
05:59
created

MsPeapProfile::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
/* 
4
 * To change this license header, choose License Headers in Project Properties.
5
 * To change this template file, choose Tools | Templates
6
 * and open the template in the editor.
7
 */
8
9
namespace devices\ms;
10
11
class MsPeapProfile extends MsEapProfile
12
{
13
    const MS_MSCHAP_NS = 'http://www.microsoft.com/provisioning/MsChapV2ConnectionPropertiesV1';
14
    const MS_PEAP_NS1 = 'http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV1';
15
    const MS_PEAP_NS2 = 'http://www.microsoft.com/provisioning/MsPeapConnectionPropertiesV2';
16
17
    public function __construct() {
18
        $this->type = \core\common\EAP::PEAP;
19
        $this->authorId = 0;
20
    }
21
    
22
    protected function getConfig()
23
    {
24
        $element = new \core\DeviceXMLmain();
25
        $element->setChild('Eap', $this->getPeapEap(), self::MS_BASEEAPCONN_NS);
26
        return($element);
27
    }
28
    
29
    private function getPeapEap()
30
    {
31
        $element = new \core\DeviceXMLmain();
32
        $element->setChild('Type', \core\common\EAP::PEAP);
33
        $element->setChild('EapType', $this->getPeapEapType(), self::MS_PEAP_NS1);
34
        return($element);        
35
    }
36
    
37
    private function getPeapEapType()
38
    {
39
        $element = new \core\DeviceXMLmain();
40
        $element->setChild('ServerValidation', $this->getPeapServerValidation());
41
        $element->setChild('FastReconnect','true');
42
        $element->setChild('InnerEapOptional', 'false');
43
        $element->setChild('Eap', $this->getMsChapV2(), self::MS_BASEEAPCONN_NS);
44
        $element->setChild('EnableQuarantineChecks', $this->nea);
45
        $element->setChild('RequireCryptoBinding', 'false');
46
        if ($this->outerId !== NULL) {
47
            $element->setChild('PeapExtensions', $this->getPrivacyExtensions());
48
        }
49
        return($element);                
50
    }
51
    
52
    private function getPeapServerValidation()
53
    {
54
        $element = new \core\DeviceXMLmain();
55
        $element->setChild('DisableUserPromptForServerValidation', 'true');
56
        $element->setChild('ServerNames', $this->serverNames);
57
        foreach ($this->caList as $ca) {
58
            $element->setChild('TrustedRootCA', $ca['sha1']);
59
        }
60
        return($element);
61
    }
62
    
63
    private function getMsChapV2()
64
    {
65
        $element = new \core\DeviceXMLmain();
66
        $element->setChild('Type', \core\common\EAP::MSCHAP2);
67
        $element->setChild('EapType', $this->getWinLogonCred(), self::MS_MSCHAP_NS);
68
        return($element);
69
    }
70
    
71
    private function getPrivacyExtensions() {
72
        $element = new \core\DeviceXMLmain();
73
        $element->setChild('IdentityPrivacy', $this->getIdentityPrivacy(), self::MS_PEAP_NS2);
74
        return($element);
75
    }
76
    
77
    private function getIdentityPrivacy() {
78
        $element = new \core\DeviceXMLmain();
79
        preg_match('/^[^@]*/', $this->outerId, $matches);
80
        $outerUser = empty($matches[0]) ? '@' : $matches[0];
81
        $element->setChild('EnableIdentityPrivacy', 'true');
82
        $element->setChild('AnonymousUserName', $outerUser);
83
        return($element);
84
85
    }
86
    
87
    private function getWinLogonCred()
88
    {
89
        $element = new \core\DeviceXMLmain();
90
        $element->setChild('UseWinLogonCredentials', 'false');
91
        return($element);
92
    }
93
}
94