Completed
Pull Request — master (#15)
by Semih Serhat
01:54
created
lib/Panels/AdminPanel.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -26,27 +26,27 @@
 block discarded – undo
26 26
 
27 27
 class AdminPanel implements ISettings {
28 28
 
29
-	/** @var SecurityConfig */
30
-	private $config;
31
-
32
-	public function __construct(SecurityConfig $config) {
33
-		$this->config = $config;
34
-	}
35
-
36
-	public function getPanel() {
37
-		$params = $this->config->getAllSecurityConfigs();
38
-		$tmpl = new Template('security', 'settings-admin');
39
-		foreach ($params as $key => $value) {
40
-			$tmpl->assign($key, $value);
41
-		}
42
-		return $tmpl;
43
-	}
44
-
45
-	public function getSectionID() {
46
-		return 'security';
47
-	}
48
-
49
-	public function getPriority() {
50
-		return 100;
51
-	}
29
+    /** @var SecurityConfig */
30
+    private $config;
31
+
32
+    public function __construct(SecurityConfig $config) {
33
+        $this->config = $config;
34
+    }
35
+
36
+    public function getPanel() {
37
+        $params = $this->config->getAllSecurityConfigs();
38
+        $tmpl = new Template('security', 'settings-admin');
39
+        foreach ($params as $key => $value) {
40
+            $tmpl->assign($key, $value);
41
+        }
42
+        return $tmpl;
43
+    }
44
+
45
+    public function getSectionID() {
46
+        return 'security';
47
+    }
48
+
49
+    public function getPriority() {
50
+        return 100;
51
+    }
52 52
 }
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
lib/PasswordValidator.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -24,115 +24,115 @@
 block discarded – undo
24 24
 
25 25
 class PasswordValidator  {
26 26
 
27
-	/** @var SecurityConfig */
28
-	protected $config;
27
+    /** @var SecurityConfig */
28
+    protected $config;
29 29
 
30
-	/** @var IL10N */
31
-	protected $l;
30
+    /** @var IL10N */
31
+    protected $l;
32 32
 
33
-	/**
34
-	 * PasswordValidator constructor.
35
-	 *
36
-	 * @param SecurityConfig $config
37
-	 * @param IL10N $l
38
-	 */
39
-	public function __construct(SecurityConfig $config, IL10N $l) {
40
-		$this->config = $config;
41
-		$this->l = $l;
42
-	}
33
+    /**
34
+     * PasswordValidator constructor.
35
+     *
36
+     * @param SecurityConfig $config
37
+     * @param IL10N $l
38
+     */
39
+    public function __construct(SecurityConfig $config, IL10N $l) {
40
+        $this->config = $config;
41
+        $this->l = $l;
42
+    }
43 43
 
44
-	/**
45
-	 * validate the given password satisfies defined password policy
46
-	 *
47
-	 * @param string $password
48
-	 * @throws HintException
49
-	 */
50
-	public function validate($password) {
51
-		$this->checkPasswordLength($password);
52
-		$this->checkNumericCharacters($password);
53
-		$this->checkUpperLowerCase($password);
54
-		$this->checkSpecialCharacters($password);
55
-	}
44
+    /**
45
+     * validate the given password satisfies defined password policy
46
+     *
47
+     * @param string $password
48
+     * @throws HintException
49
+     */
50
+    public function validate($password) {
51
+        $this->checkPasswordLength($password);
52
+        $this->checkNumericCharacters($password);
53
+        $this->checkUpperLowerCase($password);
54
+        $this->checkSpecialCharacters($password);
55
+    }
56 56
 
57
-	/**
58
-	 * validate the given password satisfies defined min length
59
-	 *
60
-	 * @param string $password
61
-	 * @throws HintException
62
-	 */
63
-	public function checkPasswordLength($password) {
64
-		$minPassLength = $this->config->getMinPasswordLength();
65
-		if(strlen($password) < $minPassLength) {
66
-			$message = 'Password needs to be at least ' . $minPassLength . ' characters long';
67
-			$hint = $this->l->t(
68
-				'Password needs to be at least %s characters long', [$minPassLength]
69
-			);
70
-			throw new HintException($message, $hint);
71
-		}
72
-	}
57
+    /**
58
+     * validate the given password satisfies defined min length
59
+     *
60
+     * @param string $password
61
+     * @throws HintException
62
+     */
63
+    public function checkPasswordLength($password) {
64
+        $minPassLength = $this->config->getMinPasswordLength();
65
+        if(strlen($password) < $minPassLength) {
66
+            $message = 'Password needs to be at least ' . $minPassLength . ' characters long';
67
+            $hint = $this->l->t(
68
+                'Password needs to be at least %s characters long', [$minPassLength]
69
+            );
70
+            throw new HintException($message, $hint);
71
+        }
72
+    }
73 73
 
74
-	/**
75
-	 * validate if password contains at least one upper and one lower case character
76
-	 *
77
-	 * @param string $password
78
-	 * @throws HintException
79
-	 */
80
-	public function checkUpperLowerCase($password) {
81
-		$enforceUpperLowerCase= $this->config->getIsUpperLowerCaseEnforced();
82
-		if($enforceUpperLowerCase === true && $this->hasUpperAndLowerCase($password) === false) {
83
-			$message = 'Password should contain at least one upper and one lower case character.';
84
-			$hint = $this->l->t(
85
-				'Password should contain at least one upper and one lower case character.'
86
-			);
87
-			throw new HintException($message, $hint);
88
-		}
89
-	}
74
+    /**
75
+     * validate if password contains at least one upper and one lower case character
76
+     *
77
+     * @param string $password
78
+     * @throws HintException
79
+     */
80
+    public function checkUpperLowerCase($password) {
81
+        $enforceUpperLowerCase= $this->config->getIsUpperLowerCaseEnforced();
82
+        if($enforceUpperLowerCase === true && $this->hasUpperAndLowerCase($password) === false) {
83
+            $message = 'Password should contain at least one upper and one lower case character.';
84
+            $hint = $this->l->t(
85
+                'Password should contain at least one upper and one lower case character.'
86
+            );
87
+            throw new HintException($message, $hint);
88
+        }
89
+    }
90 90
 
91
-	/**
92
-	 * validate the given password satisfies numeric character policy
93
-	 *
94
-	 * @param string $password
95
-	 * @throws HintException
96
-	 */
97
-	public function checkNumericCharacters($password) {
98
-		$enforceNumericCharacters = $this->config->getIsNumericCharactersEnforced();
99
-		if($enforceNumericCharacters === true && $this->hasNumericalCharacters($password) === false) {
100
-			$message = 'Password should contain at least one numerical character.';
101
-			$hint = $this->l->t(
102
-				'Password should contain at least one numerical character.'
103
-			);
104
-			throw new HintException($message, $hint);
105
-		}
106
-	}
91
+    /**
92
+     * validate the given password satisfies numeric character policy
93
+     *
94
+     * @param string $password
95
+     * @throws HintException
96
+     */
97
+    public function checkNumericCharacters($password) {
98
+        $enforceNumericCharacters = $this->config->getIsNumericCharactersEnforced();
99
+        if($enforceNumericCharacters === true && $this->hasNumericalCharacters($password) === false) {
100
+            $message = 'Password should contain at least one numerical character.';
101
+            $hint = $this->l->t(
102
+                'Password should contain at least one numerical character.'
103
+            );
104
+            throw new HintException($message, $hint);
105
+        }
106
+    }
107 107
 
108
-	/**
109
-	 * check if password contains at least one special character
110
-	 *
111
-	 * @param string $password
112
-	 * @throws HintException
113
-	 */
114
-	public function checkSpecialCharacters($password) {
115
-		$enforceSpecialCharacters = $this->config->getIsSpecialCharactersEnforced();
116
-		if($enforceSpecialCharacters === true && $this->hasSpecialCharacter($password) === false) {
117
-			$message = 'Password should contain at least one special character.';
118
-			$hint = $this->l->t(
119
-				'Password should contain at least one special character.'
120
-			);
121
-			throw new HintException($message, $hint);
122
-		}
123
-	}
108
+    /**
109
+     * check if password contains at least one special character
110
+     *
111
+     * @param string $password
112
+     * @throws HintException
113
+     */
114
+    public function checkSpecialCharacters($password) {
115
+        $enforceSpecialCharacters = $this->config->getIsSpecialCharactersEnforced();
116
+        if($enforceSpecialCharacters === true && $this->hasSpecialCharacter($password) === false) {
117
+            $message = 'Password should contain at least one special character.';
118
+            $hint = $this->l->t(
119
+                'Password should contain at least one special character.'
120
+            );
121
+            throw new HintException($message, $hint);
122
+        }
123
+    }
124 124
 
125
-	public function hasNumericalCharacters($password) {
126
-		return preg_match('/\d/', $password) === 1 ? true : false;
127
-	}
125
+    public function hasNumericalCharacters($password) {
126
+        return preg_match('/\d/', $password) === 1 ? true : false;
127
+    }
128 128
 
129
-	public function hasUpperAndLowerCase($password) {
130
-		$toLower = strtolower($password);
131
-		$toUpper = strtoupper($password);
132
-		return ($toLower !== $password && $toUpper !== $password) ? true : false;
133
-	}
129
+    public function hasUpperAndLowerCase($password) {
130
+        $toLower = strtolower($password);
131
+        $toUpper = strtoupper($password);
132
+        return ($toLower !== $password && $toUpper !== $password) ? true : false;
133
+    }
134 134
 
135
-	public function hasSpecialCharacter($password) {
136
-		return (!ctype_alnum($password));
137
-	}
135
+    public function hasSpecialCharacter($password) {
136
+        return (!ctype_alnum($password));
137
+    }
138 138
 }
139 139
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 use OC\HintException;
23 23
 use OCP\IL10N;
24 24
 
25
-class PasswordValidator  {
25
+class PasswordValidator {
26 26
 
27 27
 	/** @var SecurityConfig */
28 28
 	protected $config;
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function checkPasswordLength($password) {
64 64
 		$minPassLength = $this->config->getMinPasswordLength();
65
-		if(strlen($password) < $minPassLength) {
66
-			$message = 'Password needs to be at least ' . $minPassLength . ' characters long';
65
+		if (strlen($password) < $minPassLength) {
66
+			$message = 'Password needs to be at least '.$minPassLength.' characters long';
67 67
 			$hint = $this->l->t(
68 68
 				'Password needs to be at least %s characters long', [$minPassLength]
69 69
 			);
@@ -78,8 +78,8 @@  discard block
 block discarded – undo
78 78
 	 * @throws HintException
79 79
 	 */
80 80
 	public function checkUpperLowerCase($password) {
81
-		$enforceUpperLowerCase= $this->config->getIsUpperLowerCaseEnforced();
82
-		if($enforceUpperLowerCase === true && $this->hasUpperAndLowerCase($password) === false) {
81
+		$enforceUpperLowerCase = $this->config->getIsUpperLowerCaseEnforced();
82
+		if ($enforceUpperLowerCase === true && $this->hasUpperAndLowerCase($password) === false) {
83 83
 			$message = 'Password should contain at least one upper and one lower case character.';
84 84
 			$hint = $this->l->t(
85 85
 				'Password should contain at least one upper and one lower case character.'
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	 */
97 97
 	public function checkNumericCharacters($password) {
98 98
 		$enforceNumericCharacters = $this->config->getIsNumericCharactersEnforced();
99
-		if($enforceNumericCharacters === true && $this->hasNumericalCharacters($password) === false) {
99
+		if ($enforceNumericCharacters === true && $this->hasNumericalCharacters($password) === false) {
100 100
 			$message = 'Password should contain at least one numerical character.';
101 101
 			$hint = $this->l->t(
102 102
 				'Password should contain at least one numerical character.'
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 */
114 114
 	public function checkSpecialCharacters($password) {
115 115
 		$enforceSpecialCharacters = $this->config->getIsSpecialCharactersEnforced();
116
-		if($enforceSpecialCharacters === true && $this->hasSpecialCharacter($password) === false) {
116
+		if ($enforceSpecialCharacters === true && $this->hasSpecialCharacter($password) === false) {
117 117
 			$message = 'Password should contain at least one special character.';
118 118
 			$hint = $this->l->t(
119 119
 				'Password should contain at least one special character.'
Please login to merge, or discard this patch.
lib/Controller/SettingsController.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -26,23 +26,23 @@
 block discarded – undo
26 26
 
27 27
 class SettingsController extends Controller {
28 28
 
29
-	/** @var SecurityConfig */
30
-	private $config;
29
+    /** @var SecurityConfig */
30
+    private $config;
31 31
 
32
-	/**
33
-	 * @param string $appName
34
-	 * @param IRequest $request
35
-	 * @param SecurityConfig $config
36
-	 */
37
-	public function __construct($appName, IRequest $request, SecurityConfig $config) {
38
-		parent::__construct($appName, $request);
39
-		$this->config = $config;
40
-	}
32
+    /**
33
+     * @param string $appName
34
+     * @param IRequest $request
35
+     * @param SecurityConfig $config
36
+     */
37
+    public function __construct($appName, IRequest $request, SecurityConfig $config) {
38
+        parent::__construct($appName, $request);
39
+        $this->config = $config;
40
+    }
41 41
 
42
-	/**
43
-	 * @return array
44
-	 */
45
-	public function state() {
46
-		return $this->config->getAllSecurityConfigs();
47
-	}
42
+    /**
43
+     * @return array
44
+     */
45
+    public function state() {
46
+        return $this->config->getAllSecurityConfigs();
47
+    }
48 48
 }
Please login to merge, or discard this patch.
lib/AppInfo/Application.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
         $container->registerService('DbService', function($c) {
40 40
             return new DbService(
41 41
                 $c->query('ServerContainer')->getDb(),
42
-				$c->query('OCP\AppFramework\Utility\ITimeFactory')
42
+                $c->query('OCP\AppFramework\Utility\ITimeFactory')
43 43
             );
44 44
         });
45 45
 
@@ -49,26 +49,26 @@  discard block
 block discarded – undo
49 49
             );
50 50
         });
51 51
 
52
-		$container->registerService('SecurityConfig', function($c) {
53
-			return new SecurityConfig(
54
-				$c->query('OCP\IConfig')
55
-			);
56
-		});
52
+        $container->registerService('SecurityConfig', function($c) {
53
+            return new SecurityConfig(
54
+                $c->query('OCP\IConfig')
55
+            );
56
+        });
57 57
 
58
-		$container->registerService('PasswordValidator', function($c) {
59
-			return new PasswordValidator(
60
-				$c->query('SecurityConfig'),
61
-				$c->query('OCP\IL10N')
62
-			);
63
-		});
58
+        $container->registerService('PasswordValidator', function($c) {
59
+            return new PasswordValidator(
60
+                $c->query('SecurityConfig'),
61
+                $c->query('OCP\IL10N')
62
+            );
63
+        });
64 64
 
65 65
         $container->registerService('Hooks', function($c) {
66 66
             return new Hooks(
67 67
                 $c->query('ServerContainer')->getUserManager(),
68 68
                 $c->query('Throttle'),
69
-				$c->query('Request'),
70
-				$c->query('PasswordValidator'),
71
-				\OC::$server->getEventDispatcher()
69
+                $c->query('Request'),
70
+                $c->query('PasswordValidator'),
71
+                \OC::$server->getEventDispatcher()
72 72
             );
73 73
         });
74 74
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
 
32 32
 class Application extends App {
33 33
 
34
-    public function __construct(array $urlParams=array()){
34
+    public function __construct(array $urlParams = array()) {
35 35
         parent::__construct('security', $urlParams);
36 36
 
37 37
         $container = $this->getContainer();
Please login to merge, or discard this patch.
lib/SecurityConfig.php 1 patch
Indentation   +129 added lines, -129 removed lines patch added patch discarded remove patch
@@ -29,137 +29,137 @@
 block discarded – undo
29 29
  */
30 30
 class SecurityConfig {
31 31
 
32
-	/** @var IConfig */
33
-	private $config;
32
+    /** @var IConfig */
33
+    private $config;
34 34
 
35
-	/**
36
-	 * Config constructor.
37
-	 *
38
-	 * @param IConfig $config
39
-	 */
40
-	public function __construct(IConfig $config) {
41
-		$this->config = $config;
42
-	}
35
+    /**
36
+     * Config constructor.
37
+     *
38
+     * @param IConfig $config
39
+     */
40
+    public function __construct(IConfig $config) {
41
+        $this->config = $config;
42
+    }
43 43
 
44
-	/**
45
-	 * is brute force protection enabled
46
-	 *
47
-	 * @return array
48
-	 */
49
-	public function getAllSecurityConfigs() {
50
-		return [
51
-			'isBruteForceProtectionEnabled' => $this->getIsBruteForceProtectionEnabled(),
52
-			'minPasswordLength' => $this->getMinPasswordLength(),
53
-			'isUpperLowerCaseEnforced' => $this->getIsUpperLowerCaseEnforced(),
54
-			'isNumericalCharsEnforced' => $this->getIsNumericCharactersEnforced(),
55
-			'isSpecialCharsEnforced' => $this->getIsSpecialCharactersEnforced()
56
-		];
57
-	}
44
+    /**
45
+     * is brute force protection enabled
46
+     *
47
+     * @return array
48
+     */
49
+    public function getAllSecurityConfigs() {
50
+        return [
51
+            'isBruteForceProtectionEnabled' => $this->getIsBruteForceProtectionEnabled(),
52
+            'minPasswordLength' => $this->getMinPasswordLength(),
53
+            'isUpperLowerCaseEnforced' => $this->getIsUpperLowerCaseEnforced(),
54
+            'isNumericalCharsEnforced' => $this->getIsNumericCharactersEnforced(),
55
+            'isSpecialCharsEnforced' => $this->getIsSpecialCharactersEnforced()
56
+        ];
57
+    }
58 58
 
59
-	/**
60
-	 * is brute force protection enabled
61
-	 *
62
-	 * @return bool
63
-	 */
64
-	public function getIsBruteForceProtectionEnabled() {
65
-		$enableBruteForceProtection = $this->config->getAppValue(
66
-			'security',
67
-			'enable_brute_force_protection',
68
-			'0'
69
-		);
70
-		return boolval($enableBruteForceProtection);
71
-	}
59
+    /**
60
+     * is brute force protection enabled
61
+     *
62
+     * @return bool
63
+     */
64
+    public function getIsBruteForceProtectionEnabled() {
65
+        $enableBruteForceProtection = $this->config->getAppValue(
66
+            'security',
67
+            'enable_brute_force_protection',
68
+            '0'
69
+        );
70
+        return boolval($enableBruteForceProtection);
71
+    }
72 72
 
73
-	/**
74
-	 * get the enforced minimum length of passwords
75
-	 *
76
-	 * @return int
77
-	 */
78
-	public function getMinPasswordLength() {
79
-		$minLength = $this->config->getAppValue('security', 'min_password_length', '8');
80
-		return intval($minLength);
81
-	}
82
-	/**
83
-	 * does the password need to contain upper and lower case characters
84
-	 *
85
-	 * @return bool
86
-	 */
87
-	public function getIsUpperLowerCaseEnforced() {
88
-		$enforceUpperLowerCase = $this->config->getAppValue(
89
-			'security',
90
-			'enforce_upper_lower_case',
91
-			'0'
92
-		);
93
-		return boolval($enforceUpperLowerCase);
94
-	}
95
-	/**
96
-	 * does the password need to contain numeric characters
97
-	 *
98
-	 * @return bool
99
-	 */
100
-	public function getIsNumericCharactersEnforced() {
101
-		$enforceNumericCharacters = $this->config->getAppValue(
102
-			'security',
103
-			'enforce_numeric_characters',
104
-			'0'
105
-		);
106
-		return boolval($enforceNumericCharacters);
107
-	}
108
-	/**
109
-	 * does the password need to contain special characters
110
-	 *
111
-	 * @return bool
112
-	 */
113
-	public function getIsSpecialCharactersEnforced() {
114
-		$enforceSpecialCharacters = $this->config->getAppValue(
115
-			'security',
116
-			'enforce_special_characters',
117
-			'0'
118
-		);
119
-		return boolval($enforceSpecialCharacters);
120
-	}
121
-	/**
122
-	 * enable brute force protection
123
-	 *
124
-	 * @param bool $enableBruteForceProtection
125
-	 */
126
-	public function setIsBruteForceProtectionEnabled($enableBruteForceProtection) {
127
-		$value = $enableBruteForceProtection === true ? '1' : '0';
128
-		$this->config->setAppValue('security', 'enable_brute_force_protection', $value);
129
-	}
130
-	/**
131
-	 * set minimal length of passwords
132
-	 *
133
-	 * @param int $minLength
134
-	 */
135
-	public function setMinPasswordLength($minLength) {
136
-		$this->config->setAppValue('security', 'min_password_length', $minLength);
137
-	}
138
-	/**
139
-	 * enforce upper and lower characters case
140
-	 *
141
-	 * @param bool $enforceUpperLowerCase
142
-	 */
143
-	public function setIsUpperLowerCaseEnforced($enforceUpperLowerCase) {
144
-		$value = $enforceUpperLowerCase === true ? '1' : '0';
145
-		$this->config->setAppValue('security', 'enforce_upper_lower_case', $value);
146
-	}
147
-	/**
148
-	 * enforce numeric characters
149
-	 *
150
-	 * @param bool $enforceNumericCharacters
151
-	 */
152
-	public function setIsNumericCharactersEnforced($enforceNumericCharacters) {
153
-		$value = $enforceNumericCharacters === true ? '1' : '0';
154
-		$this->config->setAppValue('security', 'enforce_numeric_characters', $value);
155
-	}
156
-	/**
157
-	 * enforce special characters
158
-	 *
159
-	 * @param bool $enforceSpecialCharacters
160
-	 */
161
-	public function setIsSpecialCharactersEnforced($enforceSpecialCharacters) {
162
-		$value = $enforceSpecialCharacters === true ? '1' : '0';
163
-		$this->config->setAppValue('security', 'enforce_special_characters', $value);
164
-	}
73
+    /**
74
+     * get the enforced minimum length of passwords
75
+     *
76
+     * @return int
77
+     */
78
+    public function getMinPasswordLength() {
79
+        $minLength = $this->config->getAppValue('security', 'min_password_length', '8');
80
+        return intval($minLength);
81
+    }
82
+    /**
83
+     * does the password need to contain upper and lower case characters
84
+     *
85
+     * @return bool
86
+     */
87
+    public function getIsUpperLowerCaseEnforced() {
88
+        $enforceUpperLowerCase = $this->config->getAppValue(
89
+            'security',
90
+            'enforce_upper_lower_case',
91
+            '0'
92
+        );
93
+        return boolval($enforceUpperLowerCase);
94
+    }
95
+    /**
96
+     * does the password need to contain numeric characters
97
+     *
98
+     * @return bool
99
+     */
100
+    public function getIsNumericCharactersEnforced() {
101
+        $enforceNumericCharacters = $this->config->getAppValue(
102
+            'security',
103
+            'enforce_numeric_characters',
104
+            '0'
105
+        );
106
+        return boolval($enforceNumericCharacters);
107
+    }
108
+    /**
109
+     * does the password need to contain special characters
110
+     *
111
+     * @return bool
112
+     */
113
+    public function getIsSpecialCharactersEnforced() {
114
+        $enforceSpecialCharacters = $this->config->getAppValue(
115
+            'security',
116
+            'enforce_special_characters',
117
+            '0'
118
+        );
119
+        return boolval($enforceSpecialCharacters);
120
+    }
121
+    /**
122
+     * enable brute force protection
123
+     *
124
+     * @param bool $enableBruteForceProtection
125
+     */
126
+    public function setIsBruteForceProtectionEnabled($enableBruteForceProtection) {
127
+        $value = $enableBruteForceProtection === true ? '1' : '0';
128
+        $this->config->setAppValue('security', 'enable_brute_force_protection', $value);
129
+    }
130
+    /**
131
+     * set minimal length of passwords
132
+     *
133
+     * @param int $minLength
134
+     */
135
+    public function setMinPasswordLength($minLength) {
136
+        $this->config->setAppValue('security', 'min_password_length', $minLength);
137
+    }
138
+    /**
139
+     * enforce upper and lower characters case
140
+     *
141
+     * @param bool $enforceUpperLowerCase
142
+     */
143
+    public function setIsUpperLowerCaseEnforced($enforceUpperLowerCase) {
144
+        $value = $enforceUpperLowerCase === true ? '1' : '0';
145
+        $this->config->setAppValue('security', 'enforce_upper_lower_case', $value);
146
+    }
147
+    /**
148
+     * enforce numeric characters
149
+     *
150
+     * @param bool $enforceNumericCharacters
151
+     */
152
+    public function setIsNumericCharactersEnforced($enforceNumericCharacters) {
153
+        $value = $enforceNumericCharacters === true ? '1' : '0';
154
+        $this->config->setAppValue('security', 'enforce_numeric_characters', $value);
155
+    }
156
+    /**
157
+     * enforce special characters
158
+     *
159
+     * @param bool $enforceSpecialCharacters
160
+     */
161
+    public function setIsSpecialCharactersEnforced($enforceSpecialCharacters) {
162
+        $value = $enforceSpecialCharacters === true ? '1' : '0';
163
+        $this->config->setAppValue('security', 'enforce_special_characters', $value);
164
+    }
165 165
 }
166 166
\ No newline at end of file
Please login to merge, or discard this patch.
lib/Db/DbService.php 2 patches
Indentation   -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
-
4 3
  *
5 4
  * @author Semih Serhat Karakaya
6 5
  * @copyright Copyright (c) 2017, ownCloud GmbH
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     /**
55 55
      * @param string $uid
56 56
      */
57
-    public function addFailedLoginAttempt($uid, $ip){
57
+    public function addFailedLoginAttempt($uid, $ip) {
58 58
         $builder = $this->connection->getQueryBuilder();
59 59
         $builder->insert('failed_login_attempts')
60 60
             ->setValue('ip', $builder->createNamedParameter($ip))
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
     public function deleteSuspiciousAttemptsForIp($ip) {
99 99
         $builder = $this->connection->getQueryBuilder();
100 100
         $builder->delete('failed_login_attempts')
101
-            ->where($builder->expr()->eq('ip',$builder->createNamedParameter($ip)))
101
+            ->where($builder->expr()->eq('ip', $builder->createNamedParameter($ip)))
102 102
             ->execute();
103 103
     }
104 104
 }
105 105
\ No newline at end of file
Please login to merge, or discard this patch.