|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* ***************************************************************************** |
|
4
|
|
|
* Contributions to this work were made on behalf of the GÉANT project, a |
|
5
|
|
|
* project that has received funding from the European Union’s Framework |
|
6
|
|
|
* Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus), |
|
7
|
|
|
* Horizon 2020 research and innovation programme under Grant Agreements No. |
|
8
|
|
|
* 691567 (GN4-1) and No. 731122 (GN4-2). |
|
9
|
|
|
* On behalf of the aforementioned projects, GEANT Association is the sole owner |
|
10
|
|
|
* of the copyright in all material which was developed by a member of the GÉANT |
|
11
|
|
|
* project. GÉANT Vereniging (Association) is registered with the Chamber of |
|
12
|
|
|
* Commerce in Amsterdam with registration number 40535155 and operates in the |
|
13
|
|
|
* UK as a branch of GÉANT Vereniging. |
|
14
|
|
|
* |
|
15
|
|
|
* Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. |
|
16
|
|
|
* UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK |
|
17
|
|
|
* |
|
18
|
|
|
* License: see the web/copyright.inc.php file in the file structure or |
|
19
|
|
|
* <base_url>/copyright.php after deploying the software |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* This file contains the AbstractProfile class. It contains common methods for |
|
24
|
|
|
* both RADIUS/EAP profiles and SilverBullet profiles |
|
25
|
|
|
* |
|
26
|
|
|
* @author Stefan Winter <[email protected]> |
|
27
|
|
|
* @author Tomasz Wolniewicz <[email protected]> |
|
28
|
|
|
* |
|
29
|
|
|
* @package Developer |
|
30
|
|
|
* |
|
31
|
|
|
*/ |
|
32
|
|
|
|
|
33
|
|
|
namespace core; |
|
34
|
|
|
|
|
35
|
|
|
use \Exception; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* This class represents an EAP Profile. |
|
39
|
|
|
* Profiles can inherit attributes from their IdP, if the IdP has some. Otherwise, |
|
40
|
|
|
* one can set attribute in the Profile directly. If there is a conflict between |
|
41
|
|
|
* IdP-wide and Profile-wide attributes, the more specific ones (i.e. Profile) win. |
|
42
|
|
|
* |
|
43
|
|
|
* @author Stefan Winter <[email protected]> |
|
44
|
|
|
* @author Tomasz Wolniewicz <[email protected]> |
|
45
|
|
|
* |
|
46
|
|
|
* @license see LICENSE file in root directory |
|
47
|
|
|
* |
|
48
|
|
|
* @package Developer |
|
49
|
|
|
*/ |
|
50
|
|
|
abstract class AbstractDeployment extends EntityWithDBProperties { |
|
51
|
|
|
|
|
52
|
|
|
const INACTIVE = 0; |
|
53
|
|
|
const ACTIVE = 1; |
|
54
|
|
|
|
|
55
|
|
|
const DEPLOYMENTTYPE_CLASSIC = "RADIUS-SP"; |
|
56
|
|
|
const DEPLOYMENTTYPE_MANAGED = "MANAGED-SP"; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* status of this deployment. Defaults to INACTIVE. |
|
60
|
|
|
* |
|
61
|
|
|
* @var int |
|
62
|
|
|
*/ |
|
63
|
|
|
public $status = AbstractDeployment::INACTIVE; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* which type of deployment is this. Not initialised, done by sub-classes. |
|
67
|
|
|
* |
|
68
|
|
|
* @var string |
|
69
|
|
|
*/ |
|
70
|
|
|
public $type; |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* DB identifier of the parent institution of this profile |
|
74
|
|
|
* @var int |
|
75
|
|
|
*/ |
|
76
|
|
|
public $institution; |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* name of the parent institution of this profile in the current language |
|
80
|
|
|
* @var string |
|
81
|
|
|
*/ |
|
82
|
|
|
public $instName; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* number of deployments the IdP this profile is attached to has |
|
86
|
|
|
* |
|
87
|
|
|
* @var int |
|
88
|
|
|
*/ |
|
89
|
|
|
protected $idpNumberOfDeployments; |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* IdP-wide attributes of the IdP this profile is attached to |
|
93
|
|
|
* |
|
94
|
|
|
* @var array |
|
95
|
|
|
*/ |
|
96
|
|
|
protected $idpAttributes; |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Federation level attributes that this profile is attached to via its IdP |
|
100
|
|
|
* |
|
101
|
|
|
* @var array |
|
102
|
|
|
*/ |
|
103
|
|
|
protected $fedAttributes; |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* This class also needs to handle frontend operations, so needs its own |
|
107
|
|
|
* access to the FRONTEND datbase. This member stores the corresponding |
|
108
|
|
|
* handle. |
|
109
|
|
|
* |
|
110
|
|
|
* @var DBConnection |
|
111
|
|
|
*/ |
|
112
|
|
|
protected $frontendHandle; |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Class constructor for existing deployments (use |
|
116
|
|
|
* IdP::newDeployment() to actually create one). Retrieves all |
|
117
|
|
|
* attributes from the DB and stores them in the priv_ arrays. |
|
118
|
|
|
* |
|
119
|
|
|
* @param IdP $idpObject optionally, the institution to which this Profile belongs. Saves the construction of the IdP instance. If omitted, an extra query and instantiation is executed to find out. |
|
|
|
|
|
|
120
|
|
|
* @param string|int $deploymentIdRaw identifier of the deployment in the DB, or |
|
121
|
|
|
*/ |
|
122
|
|
|
public function __construct($idpObject,$deploymentIdRaw = NULL) { |
|
123
|
|
|
$this->databaseType = "INST"; |
|
124
|
|
|
parent::__construct(); // we now have access to our INST database handle and logging |
|
125
|
|
|
$this->frontendHandle = DBConnection::handle("FRONTEND"); |
|
126
|
|
|
if (!($idpObject instanceof IdP)) { |
|
|
|
|
|
|
127
|
|
|
throw new Exception("Always provide an IdP object when constructing Deployment."); |
|
128
|
|
|
} else { |
|
129
|
|
|
$idp = $idpObject; |
|
130
|
|
|
$this->institution = $idp->identifier; |
|
131
|
|
|
} |
|
132
|
|
|
if ($deploymentIdRaw !== NULL) { |
|
133
|
|
|
$this->identifier = $deploymentIdRaw; |
|
|
|
|
|
|
134
|
|
|
} |
|
135
|
|
|
$this->instName = $idp->name; |
|
136
|
|
|
$this->idpNumberOfDeployments = $idp->deploymentCount(); |
|
137
|
|
|
$this->idpAttributes = $idp->getAttributes(); |
|
138
|
|
|
$fedObject = new Federation($idp->federation); |
|
139
|
|
|
$this->fedAttributes = $fedObject->getAttributes(); |
|
140
|
|
|
$this->loggerInstance->debug(3, "--- END Constructing new AbstractDeployment object ... ---\n"); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* update the last_changed timestamp for this deployment |
|
145
|
|
|
* |
|
146
|
|
|
* @return void |
|
147
|
|
|
*/ |
|
148
|
|
|
abstract public function updateFreshness(); |
|
149
|
|
|
|
|
150
|
|
|
/** |
|
151
|
|
|
* gets the last-modified timestamp (useful for caching "dirty" check) |
|
152
|
|
|
* |
|
153
|
|
|
* @return string the date in string form, as returned by SQL |
|
154
|
|
|
*/ |
|
155
|
|
|
abstract public function getFreshness(); |
|
156
|
|
|
|
|
157
|
|
|
/** |
|
158
|
|
|
* Deletes the deployment from database |
|
159
|
|
|
* |
|
160
|
|
|
* @return void |
|
161
|
|
|
*/ |
|
162
|
|
|
abstract public function destroy(); |
|
163
|
|
|
} |
|
164
|
|
|
|