/**
* Constructor.
*
- * @param string $user_id The session will be setup for the user
- * with this ID.
* @param Horde_Kolab_Server $server The connection to the Kolab user
* database.
* @param array $params Kolab configuration settings.
*/
public function __construct(
- $user_id,
- Horde_Kolab_Server_Composite_Interface $server,
+ Horde_Kolab_Server_Composite $server,
array $params
) {
- $this->_user_id = $user_id;
$this->_server = $server;
$this->_params = $params;
}
/**
* Try to connect the session handler.
*
- * @param array $credentials An array of login credentials. For Kolab,
- * this must contain a "password" entry.
+ * @param string $user_id The user ID to connect with.
+ * @param array $credentials An array of login credentials. For Kolab,
+ * this must contain a "password" entry.
*
* @return NULL
*
* @throws Horde_Kolab_Session_Exception If the connection failed.
*/
- public function connect(array $credentials = null)
+ public function connect($user_id = null, array $credentials = null)
{
+ $this->_user_id = $user_id;
if (isset($credentials['password'])) {
$password = $credentials['password'];
} else {
/**
* Try to connect the session handler.
*
- * @param array $credentials An array of login credentials. For Kolab,
- * this must contain a "password" entry.
+ * @param string $user_id The user ID to connect with.
+ * @param array $credentials An array of login credentials. For Kolab,
+ * this must contain a "password" entry.
*
* @return NULL
*
* @throws Horde_Kolab_Session_Exception If the connection failed.
*/
- public function connect(array $credentials = null)
+ public function connect($user_id = null, array $credentials = null)
{
- $id = $this->_session->getId();
- if (empty($id) && $credentials === null) {
- $this->_session->setId($this->_anonymous_id);
- $this->_session->connect(array('password' => $this->_anonymous_pass));
+ if ($user_id === null && $credentials === null) {
+ $this->_session->connect($this->_anonymous_id, array('password' => $this->_anonymous_pass));
} else {
- $this->_session->connect($credentials);
+ $this->_session->connect($user_id, $credentials);
}
}
/**
* Try to connect the session handler.
*
- * @param array $credentials An array of login credentials. For Kolab,
- * this must contain a "password" entry.
+ * @param string $user_id The user ID to connect with.
+ * @param array $credentials An array of login credentials. For Kolab,
+ * this must contain a "password" entry.
*
* @return NULL
*
* @throws Horde_Kolab_Session_Exception If the connection failed.
*/
- public function connect(array $credentials = null)
+ public function connect($user_id = null, array $credentials = null)
{
try {
- $this->_session->connect($credentials);
+ $this->_session->connect($user_id, $credentials);
$this->_logger->info(
sprintf(
"Connected Kolab session for \"%s\".",
/**
* Try to connect the session handler.
*
- * @param array $credentials An array of login credentials. For Kolab,
- * this must contain a "password" entry.
+ * @param string $user_id The user ID to connect with.
+ * @param array $credentials An array of login credentials. For Kolab,
+ * this must contain a "password" entry.
*
* @return NULL
*/
- public function connect(array $credentials = null)
+ public function connect($user_id = null, array $credentials = null)
{
- $this->_session->connect($credentials);
+ $this->_session->connect($user_id, $credentials);
$this->_connected = true;
}
/**
* Validate the given session.
*
- * @param Horde_Kolab_Session $session The session to validate.
- * @param string $user The session will be validated for
- * this user ID.
+ * @param Horde_Kolab_Session_Interface $session The session to validate.
*
* @return boolean True if the given session is valid.
*/
public function validate(
- Horde_Kolab_Session_Interface $session,
- $user = null
+ Horde_Kolab_Session_Interface $session
) {
return $this->getSessionValidator(
$session,
$this->getSessionAuth()
- )->isValid($user);
+ )->isValid();
}
/**
* Returns a new session handler.
*
- * @param string $user The session will be setup for the user with this ID.
- *
* @return Horde_Kolab_Session The concrete Kolab session reference.
*/
- public function createSession($user = null)
+ public function createSession()
{
$session = new Horde_Kolab_Session_Base(
- $user,
$this->getServer(),
$this->getSessionConfiguration()
);
* Returns either a reference to a session handler with data retrieved from
* the session or a new session handler.
*
- * @param string $user The session will be setup for the user with
- * this ID.
- * @param array $credentials An array of login credentials.
- *
* @return Horde_Kolab_Session The concrete Kolab session reference.
*/
- public function getSession($user = null, array $credentials = null)
+ public function getSession()
{
$storage = $this->getSessionStorage();
$session = $storage->load();
- if (!empty($session) && $this->validate($session, $user)) {
+ if (!empty($session) && $this->validate($session)) {
return $session;
}
- $session = $this->createSession($user);
- $session->connect($credentials);
+ $session = $this->createSession();
return $session;
}
}
/**
* Validate the given session.
*
- * @param Horde_Kolab_Session $session The session to validate.
- * @param string $user The session will be validated for
- * this user ID.
- *
* @return boolean True if the given session is valid.
*/
- public function validate(Horde_Kolab_Session_Interface $session, $user = null)
- {
- return $this->_factory->validate($session, $user);
+ public function validate(
+ Horde_Kolab_Session_Interface $session
+ ) {
+ return $this->_factory->validate($session);
}
/**
* Returns a new session handler.
*
- * @param string $user The session will be setup for the user with this ID.
- *
* @return Horde_Kolab_Session The concrete Kolab session reference.
*/
- public function createSession($user = null)
+ public function createSession()
{
- return $this->_factory->createSession($user);
+ return $this->_factory->createSession();
}
/**
* Returns either a reference to a session handler with data retrieved from
* the session or a new session handler.
*
- * @param string $user The session will be setup for the user with
- * this ID.
- * @param array $credentials An array of login credentials.
- *
* @return Horde_Kolab_Session The concrete Kolab session reference.
*/
- public function getSession($user = null, array $credentials = null)
+ public function getSession()
{
- return $this->_factory->getSession($user, $credentials);
+ return $this->_factory->getSession();
}
}
* for the session.
*/
public function __construct(
- Horde_Kolab_Server_Composite_Interface $server,
+ Horde_Kolab_Server_Composite $server,
Horde_Kolab_Session_Auth_Interface $auth,
array $config,
Horde_Kolab_Session_Storage_Interface $storage
/**
* Return the session validation driver.
*
- * @param Horde_Kolab_Session_Interface $session The session to validate.
- * @param Horde_Kolab_Session_Auth_Interface $auth The auth handler.
- *
* @return Horde_Kolab_Session_Valid_Interface The driver for validating
* sessions.
*/
* Validate the given session.
*
* @param Horde_Kolab_Session_Interface $session The session to validate.
- * @param string $user The session will be validated
- * for this user ID.
*
* @return boolean True if the given session is valid.
*/
public function validate(
- Horde_Kolab_Session_Interface $session,
- $user = null
+ Horde_Kolab_Session_Interface $session
) {
- return $this->_factory->validate($session, $user);
+ return $this->_factory->validate($session);
}
/**
* Returns a new session handler.
*
- * @param string $user The session will be setup for the user with this ID.
- *
* @return Horde_Kolab_Session_Interface The concrete Kolab session reference.
*/
- public function createSession($user = null)
+ public function createSession()
{
- $session = $this->_factory->createSession($user);
+ $session = $this->_factory->createSession();
$session = new Horde_Kolab_Session_Decorator_Anonymous(
$session,
$this->_anonymous_id,
* Returns either a reference to a session handler with data retrieved from
* the session or a new session handler.
*
- * @param string $user The session will be setup for the user with
- * this ID.
- * @param array $credentials An array of login credentials.
- *
* @return Horde_Kolab_Session_Interface The concrete Kolab session reference.
*/
- public function getSession($user = null, array $credentials = null)
+ public function getSession()
{
- return $this->_factory->getSession($user, $credentials);
+ return $this->_factory->getSession();
}
}
* Validate the given session.
*
* @param Horde_Kolab_Session_Interface $session The session to validate.
- * @param string $user The session will be validated
- * for this user ID.
*
* @return boolean True if the given session is valid.
*/
public function validate(
- Horde_Kolab_Session_Interface $session,
- $user = null
+ Horde_Kolab_Session_Interface $session
) {
- return $this->_factory->validate($session, $user);
+ return $this->_factory->validate($session);
}
/**
* Returns a new session handler.
*
- * @param string $user The session will be setup for the user with this ID.
- *
* @return Horde_Kolab_Session_Interface The concrete Kolab session reference.
*/
- public function createSession($user = null)
+ public function createSession()
{
- $session = $this->_factory->createSession($user);
+ $session = $this->_factory->createSession();
$session = new Horde_Kolab_Session_Decorator_Logged(
$session, $this->_logger
);
*
* @return Horde_Kolab_Session_Interface The concrete Kolab session reference.
*/
- public function getSession($user = null, array $credentials = null)
+ public function getSession()
{
- return $this->_factory->getSession($user, $credentials);
+ return $this->_factory->getSession();
}
}
/**
* Validate the given session.
*
- * Validate the given session.
- *
* @param Horde_Kolab_Session_Interface $session The session to validate.
- * @param string $user The session will be validated
- * for this user ID.
*
* @return boolean True if the given session is valid.
*/
public function validate(
- Horde_Kolab_Session_Interface $session,
- $user = null
+ Horde_Kolab_Session_Interface $session
);
/**
* Returns a new session handler.
*
- * @param string $user The session will be setup for the user with this ID.
- *
* @return Horde_Kolab_Session_Interface The concrete Kolab session reference.
*/
- public function createSession($user = null);
+ public function createSession();
/**
* Returns either a reference to a session handler with data retrieved from
* the session or a new session handler.
*
- * @param string $user The session will be setup for the user with
- * this ID.
- * @param array $credentials An array of login credentials.
- *
* @return Horde_Kolab_Session_Interface The concrete Kolab session reference.
*/
- public function getSession($user = null, array $credentials = null);
+ public function getSession();
}
/**
* Try to connect the session handler.
*
- * @param array $credentials An array of login credentials. For Kolab,
- * this must contain a "password" entry.
+ * @param string $user_id The user ID to connect with.
+ * @param array $credentials An array of login credentials. For Kolab,
+ * this must contain a "password" entry.
*
* @return NULL
*
* @throws Horde_Kolab_Session_Exception If the connection failed.
*/
- public function connect(array $credentials = null);
+ public function connect($user_id = null, array $credentials = null);
/**
* Return the user id used for connecting the session.
);
}
- public function testMethodConstructHasParameterStringUserid()
+ public function testMethodConstructHasParameterServercompositeServer()
{
$session = new Horde_Kolab_Session_Base(
- 'userid', $this->_getComposite(), array()
+ $this->_getComposite(), array()
);
}
- public function testMethodConstructHasParameterServercompositeServer()
+ public function testMethodConstructHasParameterArrayParams()
{
$session = new Horde_Kolab_Session_Base(
- '', $this->_getComposite(), array()
+ $this->_getComposite(), array('params' => 'params')
);
}
- public function testMethodConstructHasParameterArrayParams()
+ public function testMethodConnectHasParameterStringUserid()
{
+ $this->user->expects($this->exactly(1))
+ ->method('getSingle')
+ ->will($this->returnValue('mail@example.org'));
+ $this->user->expects($this->exactly(4))
+ ->method('getExternal')
+ ->will($this->returnValue(array('mail@example.org')));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- '', $this->_getComposite(), array('params' => 'params')
+ $composite, array()
);
+ $session->connect('userid', array('password' => ''));
}
public function testMethodConnectHasParameterArrayCredentials()
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- '', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('', array('password' => ''));
}
public function testMethodConnectHasPostconditionThatTheUserMailAddressIsKnown()
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- '', $composite, array()
+ $composite, array()
);
$session->connect(array('password' => ''));
$this->assertEquals('mail@example.org', $session->getMail());
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- '', $composite, array()
+ $composite, array()
);
$session->connect(array('password' => ''));
$this->assertEquals('uid', $session->getUid());
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- '', $composite, array()
+ $composite, array()
);
$session->connect(array('password' => ''));
$this->assertEquals('name', $session->getName());
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('home.example.org', $session->getImapServer());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite,
+ $composite,
array('freebusy' => array('url_format' => 'https://%s/fb'))
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('https://freebusy.example.org/fb', $session->getFreebusyServer());
}
->method('connectGuid')
->will($this->throwException(new Horde_Kolab_Server_Exception('Error')));
$session = new Horde_Kolab_Session_Base(
- 'user', $composite, array()
+ $composite, array()
);
try {
- $session->connect(array('password' => 'pass'));
+ $session->connect('user', array('password' => 'pass'));
} catch (Horde_Kolab_Session_Exception $e) {
$this->assertEquals('Login failed!', $e->getMessage());
}
->method('connectGuid')
->will($this->throwException(new Horde_Kolab_Server_Exception_Bindfailed('Error')));
$session = new Horde_Kolab_Session_Base(
- 'user', $composite, array()
+ $composite, array()
);
try {
- $session->connect(array('password' => 'pass'));
+ $session->connect('user', array('password' => 'pass'));
} catch (Horde_Kolab_Session_Exception_Badlogin $e) {
$this->assertEquals('Invalid credentials!', $e->getMessage());
}
public function testMethodSleepHasResultArrayThePropertiesToSerialize()
{
$session = new Horde_Kolab_Session_Base(
- 'user', $this->_getComposite(), array()
+ $this->_getComposite(), array()
);
$this->assertEquals(
array(
public function testMethodGetidHasResultStringTheIdOfTheUserUserUsedForConnecting()
{
+ $this->user->expects($this->exactly(1))
+ ->method('getSingle')
+ ->will($this->returnValue('mail@example.org'));
+ $this->user->expects($this->exactly(4))
+ ->method('getExternal')
+ ->will($this->returnValue(array('mail@example.org')));
+ $composite = $this->_getMockedComposite();
+ $composite->objects->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $this->_getComposite(), array()
+ $composite, array()
);
+ $session->connect('userid', array('password' => 'pass'));
$this->assertEquals('userid', $session->getId());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('userid', $session->getMail());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('userid', $session->getUid());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('userid', $session->getName());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite,
+ $composite,
array('freebusy' => array('url_format' => 'https://%s/fb'))
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('https://freebusy.example.org/fb', $session->getFreebusyServer());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('http://freebusy.example.org/freebusy', $session->getFreebusyServer());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite,
+ $composite,
array('freebusy' => array('url' => 'https://freebusy2.example.org/fb'))
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('https://freebusy2.example.org/fb', $session->getFreebusyServer());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite,
+ $composite,
array('freebusy' => array('url_format' => 'https://%s/fb'))
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('https://localhost/fb', $session->getFreebusyServer());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('http://localhost/freebusy', $session->getFreebusyServer());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite,
+ $composite,
array('freebusy' => array('url_format' => 'https://%s/fb'))
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('https://localhost/fb', $session->getFreebusyServer());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('http://localhost/freebusy', $session->getFreebusyServer());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('home.example.org', $session->getImapServer());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite,
+ $composite,
array('imap' => array('server' => 'imap.example.org'))
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('imap.example.org', $session->getImapServer());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- 'userid', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('userid', array('password' => ''));
$this->assertEquals('localhost', $session->getImapServer());
}
{
$session = $this->getMock('Horde_Kolab_Session_Interface');
$session->expects($this->once())
- ->method('getId')
- ->will($this->returnValue(null));
- $session->expects($this->once())
- ->method('setId')
- ->with('anonymous');
- $session->expects($this->once())
->method('connect')
- ->with(array('password' => 'pass'));
+ ->with('anonymous', array('password' => 'pass'));
$anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
$session, 'anonymous', 'pass'
);
$this->session_auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('new@example.org'));
- $this->server->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $this->user->expects($this->exactly(1))
- ->method('getSingle')
- ->will($this->returnValue('mail@example.org'));
- $this->user->expects($this->exactly(4))
- ->method('getExternal')
- ->will($this->returnValue(array('mail@example.org')));
$factory = new Horde_Kolab_Session_Factory_Constructor(
$this->server, $this->session_auth, array(), $this->session_storage
);
$this->session_storage->expects($this->once())
->method('load')
->will($this->returnValue(false));
- $this->server->objects->expects($this->once())
- ->method('fetch')
- ->will($this->returnValue($this->user));
- $this->user->expects($this->exactly(1))
- ->method('getSingle')
- ->will($this->returnValue('mail@example.org'));
- $this->user->expects($this->exactly(4))
- ->method('getExternal')
- ->will($this->returnValue(array('mail@example.org')));
$factory = new Horde_Kolab_Session_Factory_Constructor(
$this->server, $this->session_auth, array(), $this->session_storage
);
)
);
$this->assertType(
- 'Horde_Kolab_Server_Composite_Interface',
+ 'Horde_Kolab_Server_Composite',
$factory->getServer()
);
}
$factory = new Horde_Kolab_Session_Factory_Constructor(
$this->server, $this->session_auth, array(), $this->session_storage
);
- $this->assertType('Horde_Kolab_Server_Composite_Interface', $factory->getServer());
+ $this->assertType('Horde_Kolab_Server_Composite', $factory->getServer());
}
public function testMethodGetsessionauthHasResultHordekolabsessionauth()
->method('fetch')
->will($this->returnValue($user));
$session = new Horde_Kolab_Session_Base(
- '', $composite, array()
+ $composite, array()
);
$anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
$session, 'anonymous', 'pass'
->will($this->returnValue(''));
$composite = $this->_getMockedComposite();
$session = new Horde_Kolab_Session_Base(
- '', $composite, array()
+ $composite, array()
);
$valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
$this->assertTrue($valid->isValid());
->will($this->returnValue('mail@example.org'));
$composite = $this->_getMockedComposite();
$session = new Horde_Kolab_Session_Base(
- '', $composite, array()
+ $composite, array()
);
$valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
$this->assertFalse($valid->isValid());
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- '', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('', array('password' => ''));
$valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
$this->assertFalse($valid->isValid());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- '', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('', array('password' => ''));
$valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
$this->assertTrue($valid->isValid());
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- '', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('', array('password' => ''));
$valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
$this->assertFalse($valid->isValid('somebody@example.org'));
}
->method('fetch')
->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
- '', $composite, array()
+ $composite, array()
);
- $session->connect(array('password' => ''));
+ $session->connect('', array('password' => ''));
$valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
$this->assertTrue($valid->isValid('mail@example.org'));
}
{
protected function _getComposite()
{
- return $this->getMock('Horde_Kolab_Server_Composite_Interface');
+ return $this->getMock('Horde_Kolab_Server_Composite', array(), array(), '', false, false);
}
protected function _getMockedComposite()
{
- return new Horde_Kolab_Server_Composite_Base(
+ return new Horde_Kolab_Server_Composite(
$this->getMock('Horde_Kolab_Server_Interface'),
$this->getMock('Horde_Kolab_Server_Objects_Interface'),
$this->getMock('Horde_Kolab_Server_Structure_Interface'),