This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
More...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.
If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning
Definition at line 21 of file class.ilSecuritySettingsChecker.php.
◆ generatePasswords()
static ilSecuritySettingsChecker::generatePasswords |
( |
int |
$a_number | ) |
|
|
static |
Generate a number of passwords.
Definition at line 243 of file class.ilSecuritySettingsChecker.php.
References $i, and ilSecuritySettings\_getInstance().
Referenced by ilStartUpGUI\_checkGoto(), shibUser\createFields(), ilAuthProviderSoap\handleSoapAuth(), and ilAccountRegistrationGUI\saveForm().
246 srand((
int) microtime() * 1000000);
250 for (
$i = 1;
$i <= $a_number;
$i++) {
251 $min = ($security->getPasswordMinLength() > 0)
252 ? $security->getPasswordMinLength()
254 $max = ($security->getPasswordMaxLength() > 0)
255 ? $security->getPasswordMaxLength()
261 $length = $random->int($min, $max);
262 $next = $random->int(1, 2);
264 $vowels_uc = strtoupper($vowels);
265 $consonants =
"bcdfghjklmnpqrstvwxyz";
266 $consonants_uc = strtoupper($consonants);
267 $numbers =
"1234567890";
268 $special =
"_.+?#-*@!$%~";
271 if ($security->getPasswordNumberOfUppercaseChars() > 0) {
272 for ($j = 0; $j < $security->getPasswordNumberOfUppercaseChars(); $j++) {
275 $pw .= $consonants_uc[$random->int(0, strlen($consonants_uc) - 1)];
280 $pw .= $vowels_uc[$random->int(0, strlen($vowels_uc) - 1)];
287 if ($security->isPasswordCharsAndNumbersEnabled()) {
288 $pw .= $numbers[$random->int(0, strlen($numbers) - 1)];
291 if ($security->isPasswordSpecialCharsEnabled()) {
292 $pw .= $special[$random->int(0, strlen($special) - 1)];
295 $num_lcase_chars = max($security->getPasswordNumberOfLowercaseChars(), $length - strlen($pw));
296 for ($j = 0; $j < $num_lcase_chars; $j++) {
299 $pw .= $consonants[$random->int(0, strlen($consonants) - 1)];
304 $pw .= $vowels[$random->int(0, strlen($vowels) - 1)];
310 $pw = str_shuffle($pw);
Wrapper for generation of random numbers, strings, bytes.
static _getInstance()
Get instance of ilSecuritySettings.
◆ getPasswordRequirementsInfo()
static ilSecuritySettingsChecker::getPasswordRequirementsInfo |
( |
| ) |
|
|
static |
infotext for ilPasswordInputGUI setInfo()
- Returns
- string info about allowed chars for password <type> $lng
Definition at line 190 of file class.ilSecuritySettingsChecker.php.
References $DIC, $lng, and ilSecuritySettings\_getInstance().
Referenced by ilUserProfile\addStandardFieldsToForm(), ilPasswordAssistanceGUI\getAssignPasswordForm(), ilObjUserGUI\initForm(), ilPersonalSettingsGUI\initPasswordForm(), and ilPDNewsBlockGUI\initPrivateSettingsForm().
194 $lng = $DIC->language();
198 $infos = [sprintf(
$lng->txt(
'password_allow_chars'), self::getPasswordValidChars(
false))];
201 if ($security->getPasswordMinLength() > 0) {
202 $infos[] = sprintf(
$lng->txt(
'password_to_short'), $security->getPasswordMinLength());
206 if ($security->getPasswordMaxLength() > 0) {
207 $infos[] = sprintf(
$lng->txt(
'password_to_long'), $security->getPasswordMaxLength());
211 if ($security->isPasswordCharsAndNumbersEnabled()) {
212 $infos[] =
$lng->txt(
'password_must_chars_and_numbers');
216 if ($security->isPasswordSpecialCharsEnabled()) {
217 $infos[] =
$lng->txt(
'password_must_special_chars');
220 if ($security->getPasswordNumberOfUppercaseChars() > 0) {
222 $lng->txt(
'password_must_contain_ucase_chars'),
223 $security->getPasswordNumberOfUppercaseChars()
227 if ($security->getPasswordNumberOfLowercaseChars() > 0) {
229 $lng->txt(
'password_must_contain_lcase_chars'),
230 $security->getPasswordNumberOfLowercaseChars()
234 return implode(
'<br />', $infos);
static _getInstance()
Get instance of ilSecuritySettings.
◆ getPasswordValidChars()
static ilSecuritySettingsChecker::getPasswordValidChars |
( |
bool |
$a_as_regex = true , |
|
|
bool |
$a_only_special_chars = false |
|
) |
| |
|
static |
All valid chars for password.
- Parameters
-
bool | $a_as_regex | |
bool | $a_only_special_chars | |
- Returns
- string
Definition at line 133 of file class.ilSecuritySettingsChecker.php.
136 if ($a_only_special_chars) {
137 return '/[_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+/';
139 return '/^[A-Za-z0-9_\.\+\?\#\-\*\@!\$\%\~\/\:\;]+$/';
142 return 'A-Z a-z 0-9 _.+?#-*@!$%~/:;';
◆ isPassword()
static ilSecuritySettingsChecker::isPassword |
( |
string |
$a_passwd, |
|
|
?string & |
$customError = null |
|
) |
| |
|
static |
- Deprecated:
- use ilSecuritySettings
Definition at line 26 of file class.ilSecuritySettingsChecker.php.
References $DIC, $errors, $lng, ilSecuritySettings\_getInstance(), and ilStr\strLen().
Referenced by ilPasswordInputGUI\checkInput(), and ilPersonalSettingsGUI\savePassword().
30 $lng = $DIC->language();
35 if (empty($a_passwd)) {
36 $customError =
$lng->txt(
'password_empty');
44 if ($security->getPasswordMinLength() > 0 && strlen($a_passwd) < $security->getPasswordMinLength()) {
45 $errors[] = sprintf(
$lng->txt(
'password_to_short'), $security->getPasswordMinLength());
51 if ($security->getPasswordMaxLength() > 0 && strlen($a_passwd) > $security->getPasswordMaxLength()) {
52 $errors[] = sprintf(
$lng->txt(
'password_to_long'), $security->getPasswordMaxLength());
57 if ($security->isPasswordCharsAndNumbersEnabled()) {
58 $hasCharsAndNumbers =
true;
61 if (!preg_match(
'/[A-Za-z]+/', $a_passwd)) {
62 $hasCharsAndNumbers =
false;
66 if (!preg_match(
'/[0-9]+/', $a_passwd)) {
67 $hasCharsAndNumbers =
false;
70 if (!$hasCharsAndNumbers) {
71 $errors[] =
$lng->txt(
'password_must_chars_and_numbers');
76 if ($security->getPasswordNumberOfUppercaseChars() > 0) {
78 preg_replace(
'/[A-Z]/',
'', $a_passwd)
79 ) < $security->getPasswordNumberOfUppercaseChars()) {
81 $lng->txt(
'password_must_contain_ucase_chars'),
82 $security->getPasswordNumberOfUppercaseChars()
88 if ($security->getPasswordNumberOfLowercaseChars() > 0) {
90 preg_replace(
'/[a-z]/',
'', $a_passwd)
91 ) < $security->getPasswordNumberOfLowercaseChars()) {
93 $lng->txt(
'password_must_contain_lcase_chars'),
94 $security->getPasswordNumberOfLowercaseChars()
101 if ($security->isPasswordSpecialCharsEnabled()) {
103 if (!preg_match(self::getPasswordValidChars(
true,
true), $a_passwd)) {
104 $errors[] =
$lng->txt(
'password_must_special_chars');
110 if (!preg_match(self::getPasswordValidChars(), $a_passwd)) {
111 $errors[] =
$lng->txt(
'password_contains_invalid_chars');
118 } elseif (count(
$errors) > 1) {
119 $customError =
$lng->txt(
'password_multiple_errors');
120 $customError .=
'<br />' . implode(
'<br />',
$errors);
static strLen(string $a_string)
static _getInstance()
Get instance of ilSecuritySettings.
◆ isPasswordValidForUserContext()
static ilSecuritySettingsChecker::isPasswordValidForUserContext |
( |
string |
$clear_text_password, |
|
|
|
$user, |
|
|
?string & |
$error_language_variable = null |
|
) |
| |
|
static |
The documentation for this class was generated from the following file: