/**
  * Contructor
  *
  * @access public
  */
 public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
 {
     $this->type = 'ps';
     parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
     $this->lng->loadLanguageModule('ps');
     ilObjPrivacySecurityGUI::$ERROR_MESSAGE = array(ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_AUTO_HTTPS => $this->lng->txt("ps_error_message_https_header_missing"), ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_HTTPS_NOT_AVAILABLE => $this->lng->txt('https_not_possible'), ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_HTTP_NOT_AVAILABLE => $this->lng->txt('http_not_possible'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MIN_LENGTH => $this->lng->txt('ps_error_message_invalid_password_min_length'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_LENGTH => $this->lng->txt('ps_error_message_invalid_password_max_length'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_AGE => $this->lng->txt('ps_error_message_invalid_password_max_age'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_LOGIN_MAX_ATTEMPTS => $this->lng->txt('ps_error_message_invalid_login_max_attempts'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN2 => $this->lng->txt('ps_error_message_password_min2_because_chars_numbers'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN3 => $this->lng->txt('ps_error_message_password_min3_because_chars_numbers_sc'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MAX_LENGTH_LESS_MIN_LENGTH => $this->lng->txt('ps_error_message_password_max_less_min'));
 }
 public static function initErrorMessages()
 {
     global $lng;
     if (is_array(self::$ERROR_MESSAGE)) {
         return;
     }
     $lng->loadLanguageModule('ps');
     ilObjPrivacySecurityGUI::$ERROR_MESSAGE = array(ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_AUTO_HTTPS => $lng->txt("ps_error_message_https_header_missing"), ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_HTTPS_NOT_AVAILABLE => $lng->txt('https_not_possible'), ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_HTTP_NOT_AVAILABLE => $lng->txt('http_not_possible'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MIN_LENGTH => $lng->txt('ps_error_message_invalid_password_min_length'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_LENGTH => $lng->txt('ps_error_message_invalid_password_max_length'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_AGE => $lng->txt('ps_error_message_invalid_password_max_age'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_INVALID_LOGIN_MAX_ATTEMPTS => $lng->txt('ps_error_message_invalid_login_max_attempts'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN1 => $lng->txt('ps_error_message_password_min1_because_chars'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN2 => $lng->txt('ps_error_message_password_min2_because_chars_numbers'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN3 => $lng->txt('ps_error_message_password_min3_because_chars_numbers_sc'), ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MAX_LENGTH_LESS_MIN_LENGTH => $lng->txt('ps_error_message_password_max_less_min'));
 }
 /**
  * validate settings
  *
  * @return 0, if everything is ok, an error code otherwise
  */
 public function validate(ilPropertyFormGUI $a_form = null)
 {
     $code = null;
     if ($a_form) {
         include_once "Services/PrivacySecurity/classes/class.ilObjPrivacySecurityGUI.php";
     }
     // handled in form itself
     if ($this->isAutomaticHTTPSEnabled() && (strlen($this->getAutomaticHTTPSHeaderName()) == 0 || strlen($this->getAutomaticHTTPSHeaderValue()) == 0)) {
         return ilSecuritySettings::SECURITY_SETTINGS_ERR_CODE_AUTO_HTTPS;
     }
     include_once './Services/Http/classes/class.ilHTTPS.php';
     if ($this->isHTTPSEnabled()) {
         if (!ilHTTPS::_checkHTTPS()) {
             $code = ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_HTTPS_NOT_AVAILABLE;
             if (!$a_form) {
                 return $code;
             } else {
                 $a_form->getItemByPostVar('https_enabled')->setAlert(ilObjPrivacySecurityGUI::getErrorMessage($code));
             }
         }
     } elseif (!ilHTTPS::_checkHTTP()) {
         $code = ilSecuritySettings::$SECURITY_SETTINGS_ERR_CODE_HTTP_NOT_AVAILABLE;
         if (!$a_form) {
             return $code;
         } else {
             $a_form->getItemByPostVar('https_enabled')->setAlert(ilObjPrivacySecurityGUI::getErrorMessage($code));
         }
     }
     if ($this->getPasswordMinLength() < 0) {
         $code = self::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MIN_LENGTH;
         if (!$a_form) {
             return $code;
         } else {
             $a_form->getItemByPostVar('password_min_length')->setAlert(ilObjPrivacySecurityGUI::getErrorMessage($code));
         }
     }
     if ($this->getPasswordMaxLength() < 0) {
         $code = self::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_LENGTH;
         if (!$a_form) {
             return $code;
         } else {
             $a_form->getItemByPostVar('password_max_length')->setAlert(ilObjPrivacySecurityGUI::getErrorMessage($code));
         }
     }
     $password_min_length = 1;
     if ($this->getPasswordNumberOfUppercaseChars() > 0 || $this->getPasswordNumberOfLowercaseChars() > 0) {
         $password_min_length = 0;
         if ($this->getPasswordNumberOfUppercaseChars() > 0) {
             $password_min_length += $this->getPasswordNumberOfUppercaseChars();
         }
         if ($this->getPasswordNumberOfLowercaseChars() > 0) {
             $password_min_length += $this->getPasswordNumberOfLowercaseChars();
         }
         $password_min_length_error_code = self::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN1;
     }
     if ($this->isPasswordCharsAndNumbersEnabled()) {
         $password_min_length++;
         $password_min_length_error_code = self::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN2;
         if ($this->isPasswordSpecialCharsEnabled()) {
             $password_min_length++;
             $password_min_length_error_code = self::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN3;
         }
     } else {
         if ($password_min_length > 1 && $this->isPasswordSpecialCharsEnabled()) {
             $password_min_length++;
             $password_min_length_error_code = self::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MIN_LENGTH_MIN3;
         }
     }
     if ($this->getPasswordMinLength() > 0 && $this->getPasswordMinLength() < $password_min_length) {
         $code = $password_min_length_error_code;
         if (!$a_form) {
             return $code;
         } else {
             $a_form->getItemByPostVar('password_min_length')->setAlert(sprintf(ilObjPrivacySecurityGUI::getErrorMessage($code), $password_min_length));
         }
     }
     if ($this->getPasswordMaxLength() > 0 && $this->getPasswordMaxLength() < $this->getPasswordMinLength()) {
         $code = self::SECURITY_SETTINGS_ERR_CODE_PASSWORD_MAX_LENGTH_LESS_MIN_LENGTH;
         if (!$a_form) {
             return $code;
         } else {
             $a_form->getItemByPostVar('password_max_length')->setAlert(ilObjPrivacySecurityGUI::getErrorMessage($code));
         }
     }
     if ($this->getPasswordMaxAge() < 0) {
         $code = self::SECURITY_SETTINGS_ERR_CODE_INVALID_PASSWORD_MAX_AGE;
         if (!$a_form) {
             return $code;
         } else {
             $a_form->getItemByPostVar('password_max_age')->setAlert(ilObjPrivacySecurityGUI::getErrorMessage($code));
         }
     }
     if ($this->getLoginMaxAttempts() < 0) {
         $code = self::SECURITY_SETTINGS_ERR_CODE_INVALID_LOGIN_MAX_ATTEMPTS;
         if (!$a_form) {
             return $code;
         } else {
             $a_form->getItemByPostVar('login_max_attempts')->setAlert(ilObjPrivacySecurityGUI::getErrorMessage($code));
         }
     }
     /*
      * todo: have to check for local auth if first login password change is enabled??
      * than: add errorcode
      */
     if (!$a_form) {
         return 0;
     } else {
         return !(bool) $code;
     }
 }