* @return Horde_Kolab_Storage The storage connection.
*/
public function getStorage();
-
- /**
- * Return the connection status of this session.
- *
- * @return boolean True if the session has been successfully connected.
- */
- public function isConnected();
}
{
return $this->_session->getStorage();
}
-
- /**
- * Return the connection status of this session.
- *
- * @return boolean True if the session has been successfully connected.
- */
- public function isConnected()
- {
- return $this->_session->isConnected();
- }
}
private $_storage;
/**
- * Indicate if this session was successfully connected.
- *
- * @var array
- */
- private $_connected = false;
-
- /**
* Constructor.
*
* @param string $user_id The session will be setup for the user
if (isset($credentials['password'])) {
$password = $credentials['password'];
} else {
- throw new Horde_Kolab_Session_Exception('Missing password!');
+ $password = '';
}
try {
$this->_server->connect($this->_user_id, $password);
- $user_object = $this->_server->objects->fetch();
+ $user_object = $this->_server->objects->fetch();
} catch (Horde_Kolab_Server_Exception_Bindfailed $e) {
throw new Horde_Kolab_Session_Exception_Badlogin($e);
} catch (Horde_Kolab_Server_Exception $e) {
}
return $this->_storage;
}
-
- /**
- * Return the connection status of this session.
- *
- * @return boolean True if the session has been successfully connected.
- */
- public function isConnected()
- {
- return $this->_connected;
- }
}
* 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 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);
+ public function getSession($user = null, array $credentials = null);
}
* 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 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)
+ public function getSession($user = null, array $credentials = null)
{
- return $this->_factory->getSession($user);
+ return $this->_factory->getSession($user, $credentials);
}
}
* 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 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)
+ public function getSession($user = null, array $credentials = null)
{
$storage = $this->getSessionStorage();
$session = $storage->load();
if (!empty($session) && $this->validate($session, $user)) {
return $session;
}
- return $this->createSession($user);
+ $session = $this->createSession($user);
+ $session->connect($credentials);
+ return $session;
}
}
* 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 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)
+ public function getSession($user = null, array $credentials = null)
{
- return $this->_factory->getSession($user);
+ return $this->_factory->getSession($user, $credentials);
}
}
* 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 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)
+ public function getSession($user = null, array $credentials = null)
{
- return $this->_factory->getSession($user);
+ return $this->_factory->getSession($user, $credentials);
}
}
{
return $this->_session->getStorage();
}
-
- /**
- * Return the connection status of this session.
- *
- * @return boolean True if the session has been successfully connected.
- */
- public function isConnected()
- {
- return $this->_session->isConnected();
- }
}
$config = $conf['kolab'];
$config['logger'] = Horde::getLogger();
$factory = new Horde_Kolab_Session_Factory_Configuration($config);
- self::$_instance = $factory->getSession($user);
- if (!self::$_instance->isConnected()) {
- self::$_instance->connect($credentials);
- }
+ self::$_instance = $factory->getSession($user, $credentials);
}
return self::$_instance;
}
{
return $this->_session->getStorage();
}
-
- /**
- * Return the connection status of this session.
- *
- * @return boolean True if the session has been successfully connected.
- */
- public function isConnected()
- {
- return $this->_session->isConnected();
- }
}
$this->assertEquals('https://freebusy.example.org/fb', $session->getFreebusyServer());
}
- public function testMethodConnectThrowsExceptionIfTheCredentialsHaveNoPasswordEntry()
- {
- $session = new Horde_Kolab_Session_Base(
- 'user', $this->_getComposite(), array()
- );
- try {
- $session->connect(array());
- } catch (Horde_Kolab_Session_Exception $e) {
- $this->assertEquals('Missing password!', $e->getMessage());
- }
- }
-
public function testMethodConnectThrowsExceptionIfTheConnectionFailed()
{
$composite = $this->_getMockedComposite();
{
parent::setUp();
$this->setupFactoryMocks();
+ $this->user = $this->getMock(
+ 'Horde_Kolab_Server_Object_Hash', array(), array(), '', false, false
+ );
}
public function testMethodGetvalidatorHasResultHordekolabsesessionvalid()
$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
);
$factory = new Horde_Kolab_Session_Factory_Configuration(
array(
'server' => array(
- 'basedn' => ''
+ 'mock' => true,
+ 'basedn' => '',
+ 'data' => array(
+ 'dn=user' => array(
+ 'dn' => 'dn=user',
+ 'data' => array(
+ 'uid' => array(''),
+ 'mail' => array('user@example.org'),
+ 'userPassword' => array(''),
+ 'objectClass' => array('top', 'kolabInetOrgPerson'),
+ )
+ )
+ )
)
)
);