Completed
Pull Request — master (#4098)
by Georg
24:00 queued 10:27
created
apps/user_ldap/lib/Helper.php 1 patch
Indentation   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -34,126 +34,126 @@  discard block
 block discarded – undo
34 34
 
35 35
 class Helper {
36 36
 
37
-	/** @var IConfig */
38
-	private $config;
39
-
40
-	/**
41
-	 * Helper constructor.
42
-	 *
43
-	 * @param IConfig $config
44
-	 */
45
-	public function __construct(IConfig $config) {
46
-		$this->config = $config;
47
-	}
48
-
49
-	/**
50
-	 * returns prefixes for each saved LDAP/AD server configuration.
51
-	 * @param bool $activeConfigurations optional, whether only active configuration shall be
52
-	 * retrieved, defaults to false
53
-	 * @return array with a list of the available prefixes
54
-	 *
55
-	 * Configuration prefixes are used to set up configurations for n LDAP or
56
-	 * AD servers. Since configuration is stored in the database, table
57
-	 * appconfig under appid user_ldap, the common identifiers in column
58
-	 * 'configkey' have a prefix. The prefix for the very first server
59
-	 * configuration is empty.
60
-	 * Configkey Examples:
61
-	 * Server 1: ldap_login_filter
62
-	 * Server 2: s1_ldap_login_filter
63
-	 * Server 3: s2_ldap_login_filter
64
-	 *
65
-	 * The prefix needs to be passed to the constructor of Connection class,
66
-	 * except the default (first) server shall be connected to.
67
-	 *
68
-	 */
69
-	public function getServerConfigurationPrefixes($activeConfigurations = false) {
70
-		$referenceConfigkey = 'ldap_configuration_active';
71
-
72
-		$keys = $this->getServersConfig($referenceConfigkey);
73
-
74
-		$prefixes = [];
75
-		foreach ($keys as $key) {
76
-			if ($activeConfigurations && $this->config->getAppValue('user_ldap', $key, '0') !== '1') {
77
-				continue;
78
-			}
79
-
80
-			$len = strlen($key) - strlen($referenceConfigkey);
81
-			$prefixes[] = substr($key, 0, $len);
82
-		}
83
-
84
-		return $prefixes;
85
-	}
86
-
87
-	/**
88
-	 *
89
-	 * determines the host for every configured connection
90
-	 * @return array an array with configprefix as keys
91
-	 *
92
-	 */
93
-	public function getServerConfigurationHosts() {
94
-		$referenceConfigkey = 'ldap_host';
95
-
96
-		$keys = $this->getServersConfig($referenceConfigkey);
97
-
98
-		$result = array();
99
-		foreach($keys as $key) {
100
-			$len = strlen($key) - strlen($referenceConfigkey);
101
-			$prefix = substr($key, 0, $len);
102
-			$result[$prefix] = $this->config->getAppValue('user_ldap', $key);
103
-		}
104
-
105
-		return $result;
106
-	}
107
-
108
-	/**
109
-	 * return the next available configuration prefix
110
-	 *
111
-	 * @return string
112
-	 */
113
-	public function getNextServerConfigurationPrefix() {
114
-		$serverConnections = $this->getServerConfigurationPrefixes();
115
-
116
-		if(count($serverConnections) === 0) {
117
-			return 's01';
118
-		}
119
-
120
-		sort($serverConnections);
121
-		$lastKey = array_pop($serverConnections);
122
-		$lastNumber = intval(str_replace('s', '', $lastKey));
123
-		$nextPrefix = 's' . str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT);
124
-		return $nextPrefix;
125
-	}
126
-
127
-	private function getServersConfig($value) {
128
-		$regex = '/' . $value . '$/S';
129
-
130
-		$keys = $this->config->getAppKeys('user_ldap');
131
-		$result = [];
132
-		foreach ($keys as $key) {
133
-			if (preg_match($regex, $key) === 1) {
134
-				$result[] = $key;
135
-			}
136
-		}
137
-
138
-		return $result;
139
-	}
140
-
141
-	/**
142
-	 * deletes a given saved LDAP/AD server configuration.
143
-	 * @param string $prefix the configuration prefix of the config to delete
144
-	 * @return bool true on success, false otherwise
145
-	 */
146
-	public function deleteServerConfiguration($prefix) {
147
-		if(!in_array($prefix, self::getServerConfigurationPrefixes())) {
148
-			return false;
149
-		}
150
-
151
-		$saveOtherConfigurations = '';
152
-		if(empty($prefix)) {
153
-			$saveOtherConfigurations = 'AND `configkey` NOT LIKE \'s%\'';
154
-		}
155
-
156
-		$query = \OCP\DB::prepare('
37
+    /** @var IConfig */
38
+    private $config;
39
+
40
+    /**
41
+     * Helper constructor.
42
+     *
43
+     * @param IConfig $config
44
+     */
45
+    public function __construct(IConfig $config) {
46
+        $this->config = $config;
47
+    }
48
+
49
+    /**
50
+     * returns prefixes for each saved LDAP/AD server configuration.
51
+     * @param bool $activeConfigurations optional, whether only active configuration shall be
52
+     * retrieved, defaults to false
53
+     * @return array with a list of the available prefixes
54
+     *
55
+     * Configuration prefixes are used to set up configurations for n LDAP or
56
+     * AD servers. Since configuration is stored in the database, table
57
+     * appconfig under appid user_ldap, the common identifiers in column
58
+     * 'configkey' have a prefix. The prefix for the very first server
59
+     * configuration is empty.
60
+     * Configkey Examples:
61
+     * Server 1: ldap_login_filter
62
+     * Server 2: s1_ldap_login_filter
63
+     * Server 3: s2_ldap_login_filter
64
+     *
65
+     * The prefix needs to be passed to the constructor of Connection class,
66
+     * except the default (first) server shall be connected to.
67
+     *
68
+     */
69
+    public function getServerConfigurationPrefixes($activeConfigurations = false) {
70
+        $referenceConfigkey = 'ldap_configuration_active';
71
+
72
+        $keys = $this->getServersConfig($referenceConfigkey);
73
+
74
+        $prefixes = [];
75
+        foreach ($keys as $key) {
76
+            if ($activeConfigurations && $this->config->getAppValue('user_ldap', $key, '0') !== '1') {
77
+                continue;
78
+            }
79
+
80
+            $len = strlen($key) - strlen($referenceConfigkey);
81
+            $prefixes[] = substr($key, 0, $len);
82
+        }
83
+
84
+        return $prefixes;
85
+    }
86
+
87
+    /**
88
+     *
89
+     * determines the host for every configured connection
90
+     * @return array an array with configprefix as keys
91
+     *
92
+     */
93
+    public function getServerConfigurationHosts() {
94
+        $referenceConfigkey = 'ldap_host';
95
+
96
+        $keys = $this->getServersConfig($referenceConfigkey);
97
+
98
+        $result = array();
99
+        foreach($keys as $key) {
100
+            $len = strlen($key) - strlen($referenceConfigkey);
101
+            $prefix = substr($key, 0, $len);
102
+            $result[$prefix] = $this->config->getAppValue('user_ldap', $key);
103
+        }
104
+
105
+        return $result;
106
+    }
107
+
108
+    /**
109
+     * return the next available configuration prefix
110
+     *
111
+     * @return string
112
+     */
113
+    public function getNextServerConfigurationPrefix() {
114
+        $serverConnections = $this->getServerConfigurationPrefixes();
115
+
116
+        if(count($serverConnections) === 0) {
117
+            return 's01';
118
+        }
119
+
120
+        sort($serverConnections);
121
+        $lastKey = array_pop($serverConnections);
122
+        $lastNumber = intval(str_replace('s', '', $lastKey));
123
+        $nextPrefix = 's' . str_pad($lastNumber + 1, 2, '0', STR_PAD_LEFT);
124
+        return $nextPrefix;
125
+    }
126
+
127
+    private function getServersConfig($value) {
128
+        $regex = '/' . $value . '$/S';
129
+
130
+        $keys = $this->config->getAppKeys('user_ldap');
131
+        $result = [];
132
+        foreach ($keys as $key) {
133
+            if (preg_match($regex, $key) === 1) {
134
+                $result[] = $key;
135
+            }
136
+        }
137
+
138
+        return $result;
139
+    }
140
+
141
+    /**
142
+     * deletes a given saved LDAP/AD server configuration.
143
+     * @param string $prefix the configuration prefix of the config to delete
144
+     * @return bool true on success, false otherwise
145
+     */
146
+    public function deleteServerConfiguration($prefix) {
147
+        if(!in_array($prefix, self::getServerConfigurationPrefixes())) {
148
+            return false;
149
+        }
150
+
151
+        $saveOtherConfigurations = '';
152
+        if(empty($prefix)) {
153
+            $saveOtherConfigurations = 'AND `configkey` NOT LIKE \'s%\'';
154
+        }
155
+
156
+        $query = \OCP\DB::prepare('
157 157
 			DELETE
158 158
 			FROM `*PREFIX*appconfig`
159 159
 			WHERE `configkey` LIKE ?
@@ -161,145 +161,145 @@  discard block
 block discarded – undo
161 161
 				AND `appid` = \'user_ldap\'
162 162
 				AND `configkey` NOT IN (\'enabled\', \'installed_version\', \'types\', \'bgjUpdateGroupsLastRun\')
163 163
 		');
164
-		$delRows = $query->execute(array($prefix.'%'));
165
-
166
-		if(\OCP\DB::isError($delRows)) {
167
-			return false;
168
-		}
169
-
170
-		if($delRows === 0) {
171
-			return false;
172
-		}
173
-
174
-		return true;
175
-	}
176
-
177
-	/**
178
-	 * checks whether there is one or more disabled LDAP configurations
179
-	 * @throws \Exception
180
-	 * @return bool
181
-	 */
182
-	public function haveDisabledConfigurations() {
183
-		$all = $this->getServerConfigurationPrefixes(false);
184
-		$active = $this->getServerConfigurationPrefixes(true);
185
-
186
-		if(!is_array($all) || !is_array($active)) {
187
-			throw new \Exception('Unexpected Return Value');
188
-		}
189
-
190
-		return count($all) !== count($active) || count($all) === 0;
191
-	}
192
-
193
-	/**
194
-	 * extracts the domain from a given URL
195
-	 * @param string $url the URL
196
-	 * @return string|false domain as string on success, false otherwise
197
-	 */
198
-	public function getDomainFromURL($url) {
199
-		$uinfo = parse_url($url);
200
-		if(!is_array($uinfo)) {
201
-			return false;
202
-		}
203
-
204
-		$domain = false;
205
-		if(isset($uinfo['host'])) {
206
-			$domain = $uinfo['host'];
207
-		} else if(isset($uinfo['path'])) {
208
-			$domain = $uinfo['path'];
209
-		}
210
-
211
-		return $domain;
212
-	}
164
+        $delRows = $query->execute(array($prefix.'%'));
165
+
166
+        if(\OCP\DB::isError($delRows)) {
167
+            return false;
168
+        }
169
+
170
+        if($delRows === 0) {
171
+            return false;
172
+        }
173
+
174
+        return true;
175
+    }
176
+
177
+    /**
178
+     * checks whether there is one or more disabled LDAP configurations
179
+     * @throws \Exception
180
+     * @return bool
181
+     */
182
+    public function haveDisabledConfigurations() {
183
+        $all = $this->getServerConfigurationPrefixes(false);
184
+        $active = $this->getServerConfigurationPrefixes(true);
185
+
186
+        if(!is_array($all) || !is_array($active)) {
187
+            throw new \Exception('Unexpected Return Value');
188
+        }
189
+
190
+        return count($all) !== count($active) || count($all) === 0;
191
+    }
192
+
193
+    /**
194
+     * extracts the domain from a given URL
195
+     * @param string $url the URL
196
+     * @return string|false domain as string on success, false otherwise
197
+     */
198
+    public function getDomainFromURL($url) {
199
+        $uinfo = parse_url($url);
200
+        if(!is_array($uinfo)) {
201
+            return false;
202
+        }
203
+
204
+        $domain = false;
205
+        if(isset($uinfo['host'])) {
206
+            $domain = $uinfo['host'];
207
+        } else if(isset($uinfo['path'])) {
208
+            $domain = $uinfo['path'];
209
+        }
210
+
211
+        return $domain;
212
+    }
213 213
 	
214
-	/**
215
-	 *
216
-	 * Set the LDAPProvider in the config
217
-	 *
218
-	 */
219
-	public function setLDAPProvider() {
220
-		$current = \OC::$server->getConfig()->getSystemValue('ldapProviderFactory', null);
221
-		if(is_null($current)) {
222
-			\OC::$server->getConfig()->setSystemValue('ldapProviderFactory', '\\OCA\\User_LDAP\\LDAPProviderFactory');
223
-		}
224
-	}
214
+    /**
215
+     *
216
+     * Set the LDAPProvider in the config
217
+     *
218
+     */
219
+    public function setLDAPProvider() {
220
+        $current = \OC::$server->getConfig()->getSystemValue('ldapProviderFactory', null);
221
+        if(is_null($current)) {
222
+            \OC::$server->getConfig()->setSystemValue('ldapProviderFactory', '\\OCA\\User_LDAP\\LDAPProviderFactory');
223
+        }
224
+    }
225 225
 	
226
-	/**
227
-	 * sanitizes a DN received from the LDAP server
228
-	 * @param array $dn the DN in question
229
-	 * @return array the sanitized DN
230
-	 */
231
-	public function sanitizeDN($dn) {
232
-		//treating multiple base DNs
233
-		if(is_array($dn)) {
234
-			$result = array();
235
-			foreach($dn as $singleDN) {
236
-				$result[] = $this->sanitizeDN($singleDN);
237
-			}
238
-			return $result;
239
-		}
240
-
241
-		//OID sometimes gives back DNs with whitespace after the comma
242
-		// a la "uid=foo, cn=bar, dn=..." We need to tackle this!
243
-		$dn = preg_replace('/([^\\\]),(\s+)/u', '\1,', $dn);
244
-
245
-		//make comparisons and everything work
246
-		$dn = mb_strtolower($dn, 'UTF-8');
247
-
248
-		//escape DN values according to RFC 2253 – this is already done by ldap_explode_dn
249
-		//to use the DN in search filters, \ needs to be escaped to \5c additionally
250
-		//to use them in bases, we convert them back to simple backslashes in readAttribute()
251
-		$replacements = array(
252
-			'\,' => '\5c2C',
253
-			'\=' => '\5c3D',
254
-			'\+' => '\5c2B',
255
-			'\<' => '\5c3C',
256
-			'\>' => '\5c3E',
257
-			'\;' => '\5c3B',
258
-			'\"' => '\5c22',
259
-			'\#' => '\5c23',
260
-			'('  => '\28',
261
-			')'  => '\29',
262
-			'*'  => '\2A',
263
-		);
264
-		$dn = str_replace(array_keys($replacements), array_values($replacements), $dn);
265
-
266
-		return $dn;
267
-	}
226
+    /**
227
+     * sanitizes a DN received from the LDAP server
228
+     * @param array $dn the DN in question
229
+     * @return array the sanitized DN
230
+     */
231
+    public function sanitizeDN($dn) {
232
+        //treating multiple base DNs
233
+        if(is_array($dn)) {
234
+            $result = array();
235
+            foreach($dn as $singleDN) {
236
+                $result[] = $this->sanitizeDN($singleDN);
237
+            }
238
+            return $result;
239
+        }
240
+
241
+        //OID sometimes gives back DNs with whitespace after the comma
242
+        // a la "uid=foo, cn=bar, dn=..." We need to tackle this!
243
+        $dn = preg_replace('/([^\\\]),(\s+)/u', '\1,', $dn);
244
+
245
+        //make comparisons and everything work
246
+        $dn = mb_strtolower($dn, 'UTF-8');
247
+
248
+        //escape DN values according to RFC 2253 – this is already done by ldap_explode_dn
249
+        //to use the DN in search filters, \ needs to be escaped to \5c additionally
250
+        //to use them in bases, we convert them back to simple backslashes in readAttribute()
251
+        $replacements = array(
252
+            '\,' => '\5c2C',
253
+            '\=' => '\5c3D',
254
+            '\+' => '\5c2B',
255
+            '\<' => '\5c3C',
256
+            '\>' => '\5c3E',
257
+            '\;' => '\5c3B',
258
+            '\"' => '\5c22',
259
+            '\#' => '\5c23',
260
+            '('  => '\28',
261
+            ')'  => '\29',
262
+            '*'  => '\2A',
263
+        );
264
+        $dn = str_replace(array_keys($replacements), array_values($replacements), $dn);
265
+
266
+        return $dn;
267
+    }
268 268
 	
269
-	/**
270
-	 * converts a stored DN so it can be used as base parameter for LDAP queries, internally we store them for usage in LDAP filters
271
-	 * @param string $dn the DN
272
-	 * @return string
273
-	 */
274
-	public function DNasBaseParameter($dn) {
275
-		return str_ireplace('\\5c', '\\', $dn);
276
-	}
277
-
278
-	/**
279
-	 * listens to a hook thrown by server2server sharing and replaces the given
280
-	 * login name by a username, if it matches an LDAP user.
281
-	 *
282
-	 * @param array $param
283
-	 * @throws \Exception
284
-	 */
285
-	public static function loginName2UserName($param) {
286
-		if(!isset($param['uid'])) {
287
-			throw new \Exception('key uid is expected to be set in $param');
288
-		}
289
-
290
-		//ain't it ironic?
291
-		$helper = new Helper(\OC::$server->getConfig());
292
-
293
-		$configPrefixes = $helper->getServerConfigurationPrefixes(true);
294
-		$ldapWrapper = new LDAP();
295
-		$ocConfig = \OC::$server->getConfig();
296
-
297
-		$userBackend  = new User_Proxy(
298
-			$configPrefixes, $ldapWrapper, $ocConfig
299
-		);
300
-		$uid = $userBackend->loginName2UserName($param['uid'] );
301
-		if($uid !== false) {
302
-			$param['uid'] = $uid;
303
-		}
304
-	}
269
+    /**
270
+     * converts a stored DN so it can be used as base parameter for LDAP queries, internally we store them for usage in LDAP filters
271
+     * @param string $dn the DN
272
+     * @return string
273
+     */
274
+    public function DNasBaseParameter($dn) {
275
+        return str_ireplace('\\5c', '\\', $dn);
276
+    }
277
+
278
+    /**
279
+     * listens to a hook thrown by server2server sharing and replaces the given
280
+     * login name by a username, if it matches an LDAP user.
281
+     *
282
+     * @param array $param
283
+     * @throws \Exception
284
+     */
285
+    public static function loginName2UserName($param) {
286
+        if(!isset($param['uid'])) {
287
+            throw new \Exception('key uid is expected to be set in $param');
288
+        }
289
+
290
+        //ain't it ironic?
291
+        $helper = new Helper(\OC::$server->getConfig());
292
+
293
+        $configPrefixes = $helper->getServerConfigurationPrefixes(true);
294
+        $ldapWrapper = new LDAP();
295
+        $ocConfig = \OC::$server->getConfig();
296
+
297
+        $userBackend  = new User_Proxy(
298
+            $configPrefixes, $ldapWrapper, $ocConfig
299
+        );
300
+        $uid = $userBackend->loginName2UserName($param['uid'] );
301
+        if($uid !== false) {
302
+            $param['uid'] = $uid;
303
+        }
304
+    }
305 305
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Proxy.php 1 patch
Indentation   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -35,174 +35,174 @@
 block discarded – undo
35 35
 use OCA\User_LDAP\User\Manager;
36 36
 
37 37
 abstract class Proxy {
38
-	static private $accesses = array();
39
-	private $ldap = null;
40
-
41
-	/** @var \OCP\ICache|null */
42
-	private $cache;
43
-
44
-	/**
45
-	 * @param ILDAPWrapper $ldap
46
-	 */
47
-	public function __construct(ILDAPWrapper $ldap) {
48
-		$this->ldap = $ldap;
49
-		$memcache = \OC::$server->getMemCacheFactory();
50
-		if($memcache->isAvailable()) {
51
-			$this->cache = $memcache->create();
52
-		}
53
-	}
54
-
55
-	/**
56
-	 * @param string $configPrefix
57
-	 */
58
-	private function addAccess($configPrefix) {
59
-		static $ocConfig;
60
-		static $fs;
61
-		static $log;
62
-		static $avatarM;
63
-		static $userMap;
64
-		static $groupMap;
65
-		static $db;
66
-		static $coreUserManager;
67
-		if(is_null($fs)) {
68
-			$ocConfig = \OC::$server->getConfig();
69
-			$fs       = new FilesystemHelper();
70
-			$log      = new LogWrapper();
71
-			$avatarM  = \OC::$server->getAvatarManager();
72
-			$db       = \OC::$server->getDatabaseConnection();
73
-			$userMap  = new UserMapping($db);
74
-			$groupMap = new GroupMapping($db);
75
-			$coreUserManager = \OC::$server->getUserManager();
76
-		}
77
-		$userManager =
78
-			new Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(), $db, $coreUserManager);
79
-		$connector = new Connection($this->ldap, $configPrefix);
80
-		$access = new Access($connector, $this->ldap, $userManager, new Helper(\OC::$server->getConfig()));
81
-		$access->setUserMapper($userMap);
82
-		$access->setGroupMapper($groupMap);
83
-		self::$accesses[$configPrefix] = $access;
84
-	}
85
-
86
-	/**
87
-	 * @param string $configPrefix
88
-	 * @return mixed
89
-	 */
90
-	protected function getAccess($configPrefix) {
91
-		if(!isset(self::$accesses[$configPrefix])) {
92
-			$this->addAccess($configPrefix);
93
-		}
94
-		return self::$accesses[$configPrefix];
95
-	}
96
-
97
-	/**
98
-	 * @param string $uid
99
-	 * @return string
100
-	 */
101
-	protected function getUserCacheKey($uid) {
102
-		return 'user-'.$uid.'-lastSeenOn';
103
-	}
104
-
105
-	/**
106
-	 * @param string $gid
107
-	 * @return string
108
-	 */
109
-	protected function getGroupCacheKey($gid) {
110
-		return 'group-'.$gid.'-lastSeenOn';
111
-	}
112
-
113
-	/**
114
-	 * @param string $id
115
-	 * @param string $method
116
-	 * @param array $parameters
117
-	 * @param bool $passOnWhen
118
-	 * @return mixed
119
-	 */
120
-	abstract protected function callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
121
-
122
-	/**
123
-	 * @param string $id
124
-	 * @param string $method
125
-	 * @param array $parameters
126
-	 * @return mixed
127
-	 */
128
-	abstract protected function walkBackends($id, $method, $parameters);
129
-
130
-	/**
131
-	 * @param string $id
132
-	 * @return Access
133
-	 */
134
-	abstract public function getLDAPAccess($id);
135
-
136
-	/**
137
-	 * Takes care of the request to the User backend
138
-	 * @param string $id
139
-	 * @param string $method string, the method of the user backend that shall be called
140
-	 * @param array $parameters an array of parameters to be passed
141
-	 * @param bool $passOnWhen
142
-	 * @return mixed, the result of the specified method
143
-	 */
144
-	protected function handleRequest($id, $method, $parameters, $passOnWhen = false) {
145
-		$result = $this->callOnLastSeenOn($id,  $method, $parameters, $passOnWhen);
146
-		if($result === $passOnWhen) {
147
-			$result = $this->walkBackends($id, $method, $parameters);
148
-		}
149
-		return $result;
150
-	}
151
-
152
-	/**
153
-	 * @param string|null $key
154
-	 * @return string
155
-	 */
156
-	private function getCacheKey($key) {
157
-		$prefix = 'LDAP-Proxy-';
158
-		if(is_null($key)) {
159
-			return $prefix;
160
-		}
161
-		return $prefix.md5($key);
162
-	}
163
-
164
-	/**
165
-	 * @param string $key
166
-	 * @return mixed|null
167
-	 */
168
-	public function getFromCache($key) {
169
-		if(is_null($this->cache) || !$this->isCached($key)) {
170
-			return null;
171
-		}
172
-		$key = $this->getCacheKey($key);
173
-
174
-		return json_decode(base64_decode($this->cache->get($key)));
175
-	}
176
-
177
-	/**
178
-	 * @param string $key
179
-	 * @return bool
180
-	 */
181
-	public function isCached($key) {
182
-		if(is_null($this->cache)) {
183
-			return false;
184
-		}
185
-		$key = $this->getCacheKey($key);
186
-		return $this->cache->hasKey($key);
187
-	}
188
-
189
-	/**
190
-	 * @param string $key
191
-	 * @param mixed $value
192
-	 */
193
-	public function writeToCache($key, $value) {
194
-		if(is_null($this->cache)) {
195
-			return;
196
-		}
197
-		$key   = $this->getCacheKey($key);
198
-		$value = base64_encode(json_encode($value));
199
-		$this->cache->set($key, $value, '2592000');
200
-	}
201
-
202
-	public function clearCache() {
203
-		if(is_null($this->cache)) {
204
-			return;
205
-		}
206
-		$this->cache->clear($this->getCacheKey(null));
207
-	}
38
+    static private $accesses = array();
39
+    private $ldap = null;
40
+
41
+    /** @var \OCP\ICache|null */
42
+    private $cache;
43
+
44
+    /**
45
+     * @param ILDAPWrapper $ldap
46
+     */
47
+    public function __construct(ILDAPWrapper $ldap) {
48
+        $this->ldap = $ldap;
49
+        $memcache = \OC::$server->getMemCacheFactory();
50
+        if($memcache->isAvailable()) {
51
+            $this->cache = $memcache->create();
52
+        }
53
+    }
54
+
55
+    /**
56
+     * @param string $configPrefix
57
+     */
58
+    private function addAccess($configPrefix) {
59
+        static $ocConfig;
60
+        static $fs;
61
+        static $log;
62
+        static $avatarM;
63
+        static $userMap;
64
+        static $groupMap;
65
+        static $db;
66
+        static $coreUserManager;
67
+        if(is_null($fs)) {
68
+            $ocConfig = \OC::$server->getConfig();
69
+            $fs       = new FilesystemHelper();
70
+            $log      = new LogWrapper();
71
+            $avatarM  = \OC::$server->getAvatarManager();
72
+            $db       = \OC::$server->getDatabaseConnection();
73
+            $userMap  = new UserMapping($db);
74
+            $groupMap = new GroupMapping($db);
75
+            $coreUserManager = \OC::$server->getUserManager();
76
+        }
77
+        $userManager =
78
+            new Manager($ocConfig, $fs, $log, $avatarM, new \OCP\Image(), $db, $coreUserManager);
79
+        $connector = new Connection($this->ldap, $configPrefix);
80
+        $access = new Access($connector, $this->ldap, $userManager, new Helper(\OC::$server->getConfig()));
81
+        $access->setUserMapper($userMap);
82
+        $access->setGroupMapper($groupMap);
83
+        self::$accesses[$configPrefix] = $access;
84
+    }
85
+
86
+    /**
87
+     * @param string $configPrefix
88
+     * @return mixed
89
+     */
90
+    protected function getAccess($configPrefix) {
91
+        if(!isset(self::$accesses[$configPrefix])) {
92
+            $this->addAccess($configPrefix);
93
+        }
94
+        return self::$accesses[$configPrefix];
95
+    }
96
+
97
+    /**
98
+     * @param string $uid
99
+     * @return string
100
+     */
101
+    protected function getUserCacheKey($uid) {
102
+        return 'user-'.$uid.'-lastSeenOn';
103
+    }
104
+
105
+    /**
106
+     * @param string $gid
107
+     * @return string
108
+     */
109
+    protected function getGroupCacheKey($gid) {
110
+        return 'group-'.$gid.'-lastSeenOn';
111
+    }
112
+
113
+    /**
114
+     * @param string $id
115
+     * @param string $method
116
+     * @param array $parameters
117
+     * @param bool $passOnWhen
118
+     * @return mixed
119
+     */
120
+    abstract protected function callOnLastSeenOn($id, $method, $parameters, $passOnWhen);
121
+
122
+    /**
123
+     * @param string $id
124
+     * @param string $method
125
+     * @param array $parameters
126
+     * @return mixed
127
+     */
128
+    abstract protected function walkBackends($id, $method, $parameters);
129
+
130
+    /**
131
+     * @param string $id
132
+     * @return Access
133
+     */
134
+    abstract public function getLDAPAccess($id);
135
+
136
+    /**
137
+     * Takes care of the request to the User backend
138
+     * @param string $id
139
+     * @param string $method string, the method of the user backend that shall be called
140
+     * @param array $parameters an array of parameters to be passed
141
+     * @param bool $passOnWhen
142
+     * @return mixed, the result of the specified method
143
+     */
144
+    protected function handleRequest($id, $method, $parameters, $passOnWhen = false) {
145
+        $result = $this->callOnLastSeenOn($id,  $method, $parameters, $passOnWhen);
146
+        if($result === $passOnWhen) {
147
+            $result = $this->walkBackends($id, $method, $parameters);
148
+        }
149
+        return $result;
150
+    }
151
+
152
+    /**
153
+     * @param string|null $key
154
+     * @return string
155
+     */
156
+    private function getCacheKey($key) {
157
+        $prefix = 'LDAP-Proxy-';
158
+        if(is_null($key)) {
159
+            return $prefix;
160
+        }
161
+        return $prefix.md5($key);
162
+    }
163
+
164
+    /**
165
+     * @param string $key
166
+     * @return mixed|null
167
+     */
168
+    public function getFromCache($key) {
169
+        if(is_null($this->cache) || !$this->isCached($key)) {
170
+            return null;
171
+        }
172
+        $key = $this->getCacheKey($key);
173
+
174
+        return json_decode(base64_decode($this->cache->get($key)));
175
+    }
176
+
177
+    /**
178
+     * @param string $key
179
+     * @return bool
180
+     */
181
+    public function isCached($key) {
182
+        if(is_null($this->cache)) {
183
+            return false;
184
+        }
185
+        $key = $this->getCacheKey($key);
186
+        return $this->cache->hasKey($key);
187
+    }
188
+
189
+    /**
190
+     * @param string $key
191
+     * @param mixed $value
192
+     */
193
+    public function writeToCache($key, $value) {
194
+        if(is_null($this->cache)) {
195
+            return;
196
+        }
197
+        $key   = $this->getCacheKey($key);
198
+        $value = base64_encode(json_encode($value));
199
+        $this->cache->set($key, $value, '2592000');
200
+    }
201
+
202
+    public function clearCache() {
203
+        if(is_null($this->cache)) {
204
+            return;
205
+        }
206
+        $this->cache->clear($this->getCacheKey(null));
207
+    }
208 208
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Migration/UUIDFixInsert.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -32,70 +32,70 @@
 block discarded – undo
32 32
 
33 33
 class UUIDFixInsert implements IRepairStep {
34 34
 
35
-	/** @var IConfig */
36
-	protected $config;
35
+    /** @var IConfig */
36
+    protected $config;
37 37
 
38
-	/** @var UserMapping */
39
-	protected $userMapper;
38
+    /** @var UserMapping */
39
+    protected $userMapper;
40 40
 
41
-	/** @var GroupMapping */
42
-	protected $groupMapper;
41
+    /** @var GroupMapping */
42
+    protected $groupMapper;
43 43
 
44
-	/** @var IJobList */
45
-	protected $jobList;
44
+    /** @var IJobList */
45
+    protected $jobList;
46 46
 
47
-	public function __construct(IConfig $config, UserMapping $userMapper, GroupMapping $groupMapper, IJobList $jobList) {
48
-		$this->config = $config;
49
-		$this->userMapper = $userMapper;
50
-		$this->groupMapper = $groupMapper;
51
-		$this->jobList = $jobList;
52
-	}
47
+    public function __construct(IConfig $config, UserMapping $userMapper, GroupMapping $groupMapper, IJobList $jobList) {
48
+        $this->config = $config;
49
+        $this->userMapper = $userMapper;
50
+        $this->groupMapper = $groupMapper;
51
+        $this->jobList = $jobList;
52
+    }
53 53
 
54
-	/**
55
-	 * Returns the step's name
56
-	 *
57
-	 * @return string
58
-	 * @since 9.1.0
59
-	 */
60
-	public function getName() {
61
-		return 'Insert UUIDFix background job for user and group in batches';
62
-	}
54
+    /**
55
+     * Returns the step's name
56
+     *
57
+     * @return string
58
+     * @since 9.1.0
59
+     */
60
+    public function getName() {
61
+        return 'Insert UUIDFix background job for user and group in batches';
62
+    }
63 63
 
64
-	/**
65
-	 * Run repair step.
66
-	 * Must throw exception on error.
67
-	 *
68
-	 * @param IOutput $output
69
-	 * @throws \Exception in case of failure
70
-	 * @since 9.1.0
71
-	 */
72
-	public function run(IOutput $output) {
73
-		$installedVersion = $this->config->getAppValue('user_ldap', 'installed_version', '1.2.1');
74
-		if(version_compare($installedVersion, '1.2.1') !== -1) {
75
-			return;
76
-		}
64
+    /**
65
+     * Run repair step.
66
+     * Must throw exception on error.
67
+     *
68
+     * @param IOutput $output
69
+     * @throws \Exception in case of failure
70
+     * @since 9.1.0
71
+     */
72
+    public function run(IOutput $output) {
73
+        $installedVersion = $this->config->getAppValue('user_ldap', 'installed_version', '1.2.1');
74
+        if(version_compare($installedVersion, '1.2.1') !== -1) {
75
+            return;
76
+        }
77 77
 
78
-		foreach ([$this->userMapper, $this->groupMapper] as $mapper) {
79
-			$offset = 0;
80
-			$batchSize = 50;
81
-			$jobClass = $mapper instanceof UserMapping ? UUIDFixUser::class : UUIDFixGroup::class;
82
-			do {
83
-				$retry = false;
84
-				$records = $mapper->getList($offset, $batchSize);
85
-				if(count($records) === 0){
86
-					continue;
87
-				}
88
-				try {
89
-					$this->jobList->add($jobClass, ['records' => $records]);
90
-					$offset += $batchSize;
91
-				} catch (\InvalidArgumentException $e) {
92
-					if(strpos($e->getMessage(), 'Background job arguments can\'t exceed 4000') !== false) {
93
-						$batchSize = intval(floor(count($records) * 0.8));
94
-						$retry = true;
95
-					}
96
-				}
97
-			} while (count($records) === $batchSize || $retry);
98
-		}
78
+        foreach ([$this->userMapper, $this->groupMapper] as $mapper) {
79
+            $offset = 0;
80
+            $batchSize = 50;
81
+            $jobClass = $mapper instanceof UserMapping ? UUIDFixUser::class : UUIDFixGroup::class;
82
+            do {
83
+                $retry = false;
84
+                $records = $mapper->getList($offset, $batchSize);
85
+                if(count($records) === 0){
86
+                    continue;
87
+                }
88
+                try {
89
+                    $this->jobList->add($jobClass, ['records' => $records]);
90
+                    $offset += $batchSize;
91
+                } catch (\InvalidArgumentException $e) {
92
+                    if(strpos($e->getMessage(), 'Background job arguments can\'t exceed 4000') !== false) {
93
+                        $batchSize = intval(floor(count($records) * 0.8));
94
+                        $retry = true;
95
+                    }
96
+                }
97
+            } while (count($records) === $batchSize || $retry);
98
+        }
99 99
 
100
-	}
100
+    }
101 101
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Migration/UUIDFixGroup.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@
 block discarded – undo
30 30
 use OCP\IConfig;
31 31
 
32 32
 class UUIDFixGroup extends UUIDFix {
33
-	public function __construct(GroupMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) {
34
-		$this->mapper = $mapper;
35
-		$this->proxy = new User_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config);
36
-	}
33
+    public function __construct(GroupMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) {
34
+        $this->mapper = $mapper;
35
+        $this->proxy = new User_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config);
36
+    }
37 37
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Migration/UUIDFixUser.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -30,8 +30,8 @@
 block discarded – undo
30 30
 use OCP\IConfig;
31 31
 
32 32
 class UUIDFixUser extends UUIDFix {
33
-	public function __construct(UserMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) {
34
-		$this->mapper = $mapper;
35
-		$this->proxy = new Group_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config);
36
-	}
33
+    public function __construct(UserMapping $mapper, LDAP $ldap, IConfig $config, Helper $helper) {
34
+        $this->mapper = $mapper;
35
+        $this->proxy = new Group_Proxy($helper->getServerConfigurationPrefixes(true), $ldap, $config);
36
+    }
37 37
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Migration/UUIDFix.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -30,31 +30,31 @@
 block discarded – undo
30 30
 use OCA\User_LDAP\User_Proxy;
31 31
 
32 32
 abstract class UUIDFix extends QueuedJob {
33
-	/** @var  AbstractMapping */
34
-	protected $mapper;
33
+    /** @var  AbstractMapping */
34
+    protected $mapper;
35 35
 
36
-	/** @var  Proxy */
37
-	protected $proxy;
36
+    /** @var  Proxy */
37
+    protected $proxy;
38 38
 
39
-	public function run($argument) {
40
-		$isUser = $this->proxy instanceof User_Proxy;
41
-		foreach($argument['records'] as $record) {
42
-			$access = $this->proxy->getLDAPAccess($record['name']);
43
-			$uuid = $access->getUUID($record['dn'], $isUser);
44
-			if($uuid === false) {
45
-				// record not found, no prob, continue with the next
46
-				continue;
47
-			}
48
-			if($uuid !== $record['uuid']) {
49
-				$this->mapper->setUUIDbyDN($uuid, $record['dn']);
50
-			}
51
-		}
52
-	}
39
+    public function run($argument) {
40
+        $isUser = $this->proxy instanceof User_Proxy;
41
+        foreach($argument['records'] as $record) {
42
+            $access = $this->proxy->getLDAPAccess($record['name']);
43
+            $uuid = $access->getUUID($record['dn'], $isUser);
44
+            if($uuid === false) {
45
+                // record not found, no prob, continue with the next
46
+                continue;
47
+            }
48
+            if($uuid !== $record['uuid']) {
49
+                $this->mapper->setUUIDbyDN($uuid, $record['dn']);
50
+            }
51
+        }
52
+    }
53 53
 
54
-	/**
55
-	 * @param Proxy $proxy
56
-	 */
57
-	public function overrideProxy(Proxy $proxy) {
58
-		$this->proxy = $proxy;
59
-	}
54
+    /**
55
+     * @param Proxy $proxy
56
+     */
57
+    public function overrideProxy(Proxy $proxy) {
58
+        $this->proxy = $proxy;
59
+    }
60 60
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Command/DeleteConfig.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -33,39 +33,39 @@
 block discarded – undo
33 33
 use Symfony\Component\Console\Output\OutputInterface;
34 34
 
35 35
 class DeleteConfig extends Command {
36
-	/** @var \OCA\User_LDAP\Helper */
37
-	protected $helper;
36
+    /** @var \OCA\User_LDAP\Helper */
37
+    protected $helper;
38 38
 
39
-	/**
40
-	 * @param Helper $helper
41
-	 */
42
-	public function __construct(Helper $helper) {
43
-		$this->helper = $helper;
44
-		parent::__construct();
45
-	}
39
+    /**
40
+     * @param Helper $helper
41
+     */
42
+    public function __construct(Helper $helper) {
43
+        $this->helper = $helper;
44
+        parent::__construct();
45
+    }
46 46
 
47
-	protected function configure() {
48
-		$this
49
-			->setName('ldap:delete-config')
50
-			->setDescription('deletes an existing LDAP configuration')
51
-			->addArgument(
52
-					'configID',
53
-					InputArgument::REQUIRED,
54
-					'the configuration ID'
55
-				     )
56
-		;
57
-	}
47
+    protected function configure() {
48
+        $this
49
+            ->setName('ldap:delete-config')
50
+            ->setDescription('deletes an existing LDAP configuration')
51
+            ->addArgument(
52
+                    'configID',
53
+                    InputArgument::REQUIRED,
54
+                    'the configuration ID'
55
+                        )
56
+        ;
57
+    }
58 58
 
59 59
 
60
-	protected function execute(InputInterface $input, OutputInterface $output) {
61
-		$configPrefix = $input->getArgument('configID');
60
+    protected function execute(InputInterface $input, OutputInterface $output) {
61
+        $configPrefix = $input->getArgument('configID');
62 62
 
63
-		$success = $this->helper->deleteServerConfiguration($configPrefix);
63
+        $success = $this->helper->deleteServerConfiguration($configPrefix);
64 64
 
65
-		if($success) {
66
-			$output->writeln("Deleted configuration with configID '{$configPrefix}'");
67
-		} else {
68
-			$output->writeln("Cannot delete configuration with configID '{$configPrefix}'");
69
-		}
70
-	}
65
+        if($success) {
66
+            $output->writeln("Deleted configuration with configID '{$configPrefix}'");
67
+        } else {
68
+            $output->writeln("Cannot delete configuration with configID '{$configPrefix}'");
69
+        }
70
+    }
71 71
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Command/TestConfig.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -34,59 +34,59 @@
 block discarded – undo
34 34
 
35 35
 class TestConfig extends Command {
36 36
 
37
-	protected function configure() {
38
-		$this
39
-			->setName('ldap:test-config')
40
-			->setDescription('tests an LDAP configuration')
41
-			->addArgument(
42
-					'configID',
43
-					InputArgument::REQUIRED,
44
-					'the configuration ID'
45
-				     )
46
-		;
47
-	}
37
+    protected function configure() {
38
+        $this
39
+            ->setName('ldap:test-config')
40
+            ->setDescription('tests an LDAP configuration')
41
+            ->addArgument(
42
+                    'configID',
43
+                    InputArgument::REQUIRED,
44
+                    'the configuration ID'
45
+                        )
46
+        ;
47
+    }
48 48
 
49
-	protected function execute(InputInterface $input, OutputInterface $output) {
50
-		$helper = new Helper(\OC::$server->getConfig());
51
-		$availableConfigs = $helper->getServerConfigurationPrefixes();
52
-		$configID = $input->getArgument('configID');
53
-		if(!in_array($configID, $availableConfigs)) {
54
-			$output->writeln("Invalid configID");
55
-			return;
56
-		}
49
+    protected function execute(InputInterface $input, OutputInterface $output) {
50
+        $helper = new Helper(\OC::$server->getConfig());
51
+        $availableConfigs = $helper->getServerConfigurationPrefixes();
52
+        $configID = $input->getArgument('configID');
53
+        if(!in_array($configID, $availableConfigs)) {
54
+            $output->writeln("Invalid configID");
55
+            return;
56
+        }
57 57
 
58
-		$result = $this->testConfig($configID);
59
-		if($result === 0) {
60
-			$output->writeln('The configuration is valid and the connection could be established!');
61
-		} else if($result === 1) {
62
-			$output->writeln('The configuration is invalid. Please have a look at the logs for further details.');
63
-		} else if($result === 2) {
64
-			$output->writeln('The configuration is valid, but the Bind failed. Please check the server settings and credentials.');
65
-		} else {
66
-			$output->writeln('Your LDAP server was kidnapped by aliens.');
67
-		}
68
-	}
58
+        $result = $this->testConfig($configID);
59
+        if($result === 0) {
60
+            $output->writeln('The configuration is valid and the connection could be established!');
61
+        } else if($result === 1) {
62
+            $output->writeln('The configuration is invalid. Please have a look at the logs for further details.');
63
+        } else if($result === 2) {
64
+            $output->writeln('The configuration is valid, but the Bind failed. Please check the server settings and credentials.');
65
+        } else {
66
+            $output->writeln('Your LDAP server was kidnapped by aliens.');
67
+        }
68
+    }
69 69
 
70
-	/**
71
-	 * tests the specified connection
72
-	 * @param string $configID
73
-	 * @return int
74
-	 */
75
-	protected function testConfig($configID) {
76
-		$lw = new \OCA\User_LDAP\LDAP();
77
-		$connection = new Connection($lw, $configID);
70
+    /**
71
+     * tests the specified connection
72
+     * @param string $configID
73
+     * @return int
74
+     */
75
+    protected function testConfig($configID) {
76
+        $lw = new \OCA\User_LDAP\LDAP();
77
+        $connection = new Connection($lw, $configID);
78 78
 
79
-		//ensure validation is run before we attempt the bind
80
-		$connection->getConfiguration();
79
+        //ensure validation is run before we attempt the bind
80
+        $connection->getConfiguration();
81 81
 
82
-		if(!$connection->setConfiguration(array(
83
-			'ldap_configuration_active' => 1,
84
-		))) {
85
-			return 1;
86
-		}
87
-		if($connection->bind()) {
88
-			return 0;
89
-		}
90
-		return 2;
91
-	}
82
+        if(!$connection->setConfiguration(array(
83
+            'ldap_configuration_active' => 1,
84
+        ))) {
85
+            return 1;
86
+        }
87
+        if($connection->bind()) {
88
+            return 0;
89
+        }
90
+        return 2;
91
+    }
92 92
 }
Please login to merge, or discard this patch.
apps/user_ldap/lib/Command/SetConfig.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -34,53 +34,53 @@
 block discarded – undo
34 34
 
35 35
 class SetConfig extends Command {
36 36
 
37
-	protected function configure() {
38
-		$this
39
-			->setName('ldap:set-config')
40
-			->setDescription('modifies an LDAP configuration')
41
-			->addArgument(
42
-					'configID',
43
-					InputArgument::REQUIRED,
44
-					'the configuration ID'
45
-				     )
46
-			->addArgument(
47
-					'configKey',
48
-					InputArgument::REQUIRED,
49
-					'the configuration key'
50
-				     )
51
-			->addArgument(
52
-					'configValue',
53
-					InputArgument::REQUIRED,
54
-					'the new configuration value'
55
-				     )
56
-		;
57
-	}
37
+    protected function configure() {
38
+        $this
39
+            ->setName('ldap:set-config')
40
+            ->setDescription('modifies an LDAP configuration')
41
+            ->addArgument(
42
+                    'configID',
43
+                    InputArgument::REQUIRED,
44
+                    'the configuration ID'
45
+                        )
46
+            ->addArgument(
47
+                    'configKey',
48
+                    InputArgument::REQUIRED,
49
+                    'the configuration key'
50
+                        )
51
+            ->addArgument(
52
+                    'configValue',
53
+                    InputArgument::REQUIRED,
54
+                    'the new configuration value'
55
+                        )
56
+        ;
57
+    }
58 58
 
59
-	protected function execute(InputInterface $input, OutputInterface $output) {
60
-		$helper = new Helper(\OC::$server->getConfig());
61
-		$availableConfigs = $helper->getServerConfigurationPrefixes();
62
-		$configID = $input->getArgument('configID');
63
-		if(!in_array($configID, $availableConfigs)) {
64
-			$output->writeln("Invalid configID");
65
-			return;
66
-		}
59
+    protected function execute(InputInterface $input, OutputInterface $output) {
60
+        $helper = new Helper(\OC::$server->getConfig());
61
+        $availableConfigs = $helper->getServerConfigurationPrefixes();
62
+        $configID = $input->getArgument('configID');
63
+        if(!in_array($configID, $availableConfigs)) {
64
+            $output->writeln("Invalid configID");
65
+            return;
66
+        }
67 67
 
68
-		$this->setValue(
69
-			$configID,
70
-			$input->getArgument('configKey'),
71
-			$input->getArgument('configValue')
72
-		);
73
-	}
68
+        $this->setValue(
69
+            $configID,
70
+            $input->getArgument('configKey'),
71
+            $input->getArgument('configValue')
72
+        );
73
+    }
74 74
 
75
-	/**
76
-	 * save the configuration value as provided
77
-	 * @param string $configID
78
-	 * @param string $configKey
79
-	 * @param string $configValue
80
-	 */
81
-	protected function setValue($configID, $key, $value) {
82
-		$configHolder = new Configuration($configID);
83
-		$configHolder->$key = $value;
84
-		$configHolder->saveConfiguration();
85
-	}
75
+    /**
76
+     * save the configuration value as provided
77
+     * @param string $configID
78
+     * @param string $configKey
79
+     * @param string $configValue
80
+     */
81
+    protected function setValue($configID, $key, $value) {
82
+        $configHolder = new Configuration($configID);
83
+        $configHolder->$key = $value;
84
+        $configHolder->saveConfiguration();
85
+    }
86 86
 }
Please login to merge, or discard this patch.