summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/private/Server.php5
-rw-r--r--lib/private/Share20/Manager.php17
-rw-r--r--tests/lib/Share20/ManagerTest.php20
3 files changed, 33 insertions, 9 deletions
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 8345a0b66e0..ab2e7b1fdf6 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -235,7 +235,7 @@ class Server extends ServerContainer implements IServerContainer {
} else {
$defaultTokenProvider = null;
}
-
+
$userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig());
$userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) {
\OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password));
@@ -674,7 +674,8 @@ class Server extends ServerContainer implements IServerContainer {
$c->getL10N('core'),
$factory,
$c->getUserManager(),
- $c->getLazyRootFolder()
+ $c->getLazyRootFolder(),
+ $c->getEventDispatcher()
);
return $manager;
diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php
index 2857a394e1e..b337c3c7108 100644
--- a/lib/private/Share20/Manager.php
+++ b/lib/private/Share20/Manager.php
@@ -26,6 +26,7 @@ namespace OC\Share20;
use OC\Cache\CappedMemoryCache;
use OC\Files\Mount\MoveableMount;
+use OC\HintException;
use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
@@ -42,6 +43,8 @@ use OCP\Share\Exceptions\GenericShareException;
use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager;
use OCP\Share\IProviderFactory;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\GenericEvent;
/**
* This class is the communication hub for all sharing related operations.
@@ -70,6 +73,8 @@ class Manager implements IManager {
private $rootFolder;
/** @var CappedMemoryCache */
private $sharingDisabledForUsersCache;
+ /** @var EventDispatcher */
+ private $eventDispatcher;
/**
@@ -85,6 +90,7 @@ class Manager implements IManager {
* @param IProviderFactory $factory
* @param IUserManager $userManager
* @param IRootFolder $rootFolder
+ * @param EventDispatcher $eventDispatcher
*/
public function __construct(
ILogger $logger,
@@ -96,7 +102,8 @@ class Manager implements IManager {
IL10N $l,
IProviderFactory $factory,
IUserManager $userManager,
- IRootFolder $rootFolder
+ IRootFolder $rootFolder,
+ EventDispatcher $eventDispatcher
) {
$this->logger = $logger;
$this->config = $config;
@@ -108,6 +115,7 @@ class Manager implements IManager {
$this->factory = $factory;
$this->userManager = $userManager;
$this->rootFolder = $rootFolder;
+ $this->eventDispatcher = $eventDispatcher;
$this->sharingDisabledForUsersCache = new CappedMemoryCache();
}
@@ -137,6 +145,13 @@ class Manager implements IManager {
return;
}
+ try {
+ $event = new GenericEvent($password);
+ $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event);
+ } catch (HintException $e) {
+ throw new \Exception($e->getHint());
+ }
+
// Let others verify the password
$accepted = true;
$message = '';
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 4d4fcf1db73..9f543e51592 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -37,6 +37,7 @@ use OCP\Security\ISecureRandom;
use OCP\Security\IHasher;
use OCP\Files\Mount\IMountManager;
use OCP\IGroupManager;
+use Symfony\Component\EventDispatcher\EventDispatcher;
/**
* Class ManagerTest
@@ -70,9 +71,11 @@ class ManagerTest extends \Test\TestCase {
protected $userManager;
/** @var IRootFolder | \PHPUnit_Framework_MockObject_MockObject */
protected $rootFolder;
+ /** @var EventDispatcher | \PHPUnit_Framework_MockObject_MockObject */
+ protected $eventDispatcher;
public function setUp() {
-
+
$this->logger = $this->getMock('\OCP\ILogger');
$this->config = $this->getMock('\OCP\IConfig');
$this->secureRandom = $this->getMock('\OCP\Security\ISecureRandom');
@@ -81,6 +84,7 @@ class ManagerTest extends \Test\TestCase {
$this->groupManager = $this->getMock('\OCP\IGroupManager');
$this->userManager = $this->getMock('\OCP\IUserManager');
$this->rootFolder = $this->getMock('\OCP\Files\IRootFolder');
+ $this->eventDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcher');
$this->l = $this->getMock('\OCP\IL10N');
$this->l->method('t')
@@ -100,7 +104,8 @@ class ManagerTest extends \Test\TestCase {
$this->l,
$this->factory,
$this->userManager,
- $this->rootFolder
+ $this->rootFolder,
+ $this->eventDispatcher
);
$this->defaultProvider = $this->getMockBuilder('\OC\Share20\DefaultShareProvider')
@@ -127,7 +132,8 @@ class ManagerTest extends \Test\TestCase {
$this->l,
$this->factory,
$this->userManager,
- $this->rootFolder
+ $this->rootFolder,
+ $this->eventDispatcher
]);
}
@@ -146,7 +152,7 @@ class ManagerTest extends \Test\TestCase {
$group = $this->getMock('\OCP\IGroup');
$group->method('getGID')->willReturn('sharedWithGroup');
-
+
return [
[\OCP\Share::SHARE_TYPE_USER, 'sharedWithUser'],
[\OCP\Share::SHARE_TYPE_GROUP, 'sharedWithGroup'],
@@ -2022,7 +2028,8 @@ class ManagerTest extends \Test\TestCase {
$this->l,
$factory,
$this->userManager,
- $this->rootFolder
+ $this->rootFolder,
+ $this->eventDispatcher
);
$share = $this->getMock('\OCP\Share\IShare');
@@ -2054,7 +2061,8 @@ class ManagerTest extends \Test\TestCase {
$this->l,
$factory,
$this->userManager,
- $this->rootFolder
+ $this->rootFolder,
+ $this->eventDispatcher
);
$share = $this->getMock('\OCP\Share\IShare');