apps/sharebymail/lib/ShareByMailProvider.php
/**
	 * auto generate password in case of password enforcement on mail shares
	 *
	 * @param IShare $share
	 * @return string
	 * @throws \Exception
	 */
auto generate password in case of password enforcement on mail shares
@param IShare $share
@return string
@throws \Exception
auto generate password in case of password enforcement on mail shares @param IShare $share @return string @throws \ Exception
protected function autoGeneratePassword($share) {
		$initiatorUser = $this->userManager->get($share->getSharedBy());
		$initiatorEMailAddress = ($initiatorUser instanceof IUser) ? $initiatorUser->getEMailAddress() : null;
		$allowPasswordByMail = $this->settingsManager->sendPasswordByMail();
		if ($initiatorEMailAddress === null && !$allowPasswordByMail) {
			throw new \Exception(
				$this->l->t("We can't send you the auto-generated password. Please set a valid email address in your personal settings and try again.")
			);
		}
		$passwordPolicy = $this->getPasswordPolicy();
		$passwordCharset = ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_DIGITS;
		$passwordLength = 8;
		if (!empty($passwordPolicy)) {
			$passwordLength = (int)$passwordPolicy['minLength'] > 0 ? (int)$passwordPolicy['minLength'] : $passwordLength;
			$passwordCharset .= $passwordPolicy['enforceSpecialCharacters'] ? ISecureRandom::CHAR_SYMBOLS : '';
		}
		$password = $this->secureRandom->generate($passwordLength, $passwordCharset);
		$share->setPassword($this->hasher->hash($password));
		return $password;
	}
protected function autoGeneratePassword ( $ share ) { $ initiatorUser = $ this -> userManager -> get ( $ share -> getSharedBy ( ) ) ; $ initiatorEMailAddress = ( $ initiatorUser instanceof IUser ) ? $ initiatorUser -> getEMailAddress ( ) : null ; $ allowPasswordByMail = $ this -> settingsManager -> sendPasswordByMail ( ) ; if ( $ initiatorEMailAddress === null && ! $ allowPasswordByMail ) { throw new \ Exception ( $ this -> l -> t ( " We can't send you the auto-generated password. Please set a valid email address in your personal settings and try again. " ) ) ; } $ passwordPolicy = $ this -> getPasswordPolicy ( ) ; $ passwordCharset = ISecureRandom :: CHAR_LOWER . ISecureRandom :: CHAR_UPPER . ISecureRandom :: CHAR_DIGITS ; $ passwordLength = 8 ; if ( ! empty ( $ passwordPolicy ) ) { $ passwordLength = ( int ) $ passwordPolicy [ 'minLength' ] > 0 ? ( int ) $ passwordPolicy [ 'minLength' ] : $ passwordLength ; $ passwordCharset .= $ passwordPolicy [ 'enforceSpecialCharacters' ] ? ISecureRandom :: CHAR_SYMBOLS : '' ; } $ password = $ this -> secureRandom -> generate ( $ passwordLength , $ passwordCharset ) ; $ share -> setPassword ( $ this -> hasher -> hash ( $ password ) ) ; return $ password ; }
auto generate password in case of password enforcement on mail shares
 @param IShare $share
 @return string
 @throws \Exception
auto generate password in case of password enforcement on mail shares @param IShare $share @return string @throws \ Exception