24 function set($name, $value)
38 function get($name, $default=null)
103 $required = $this->requiredKeys();
105 foreach ($required as $k) {
106 if (!array_key_exists($k,
$data)) {
111 if (!$this->check(
$data)) {
116 $obj = $this->newObject(
$data);
122 foreach ($required as $k) {
123 $obj->$k =
$data[$k];
165 foreach ($obj as $k => $v) {
169 $extra = $this->prepareForSave($obj);
171 if ($extra && is_array($extra)) {
172 foreach ($extra as $k => $v) {
206 foreach ($obj as $k => $v) {
214 return is_array(
$data[
'type_uris']);
226 return array(
'starting_url',
239 $data[
'session_key']);
244 return is_array(
$data[
'services']);
251 foreach (
$data[
'services'] as $s) {
252 $services[] =
$loader->fromSession($s);
254 return array(
'services' => $services);
261 foreach ($obj->services as $s) {
262 $services[] =
$loader->toSession($s);
264 return array(
'services' => $services);
284 $services, $session_key)
287 $this->starting_url = $starting_url;
290 $this->yadis_url = $yadis_url;
293 $this->services = $services;
295 $this->session_key = $session_key;
298 $this->_current = null;
301 $this->stale =
false;
310 return count($this->services);
322 if ($this->services) {
323 $this->_current = array_shift($this->services);
325 $this->_current = null;
328 return $this->_current;
338 return $this->_current;
346 return in_array($url, array($this->starting_url, $this->yadis_url));
355 return $this->_current !== null;
374 var $DEFAULT_SUFFIX =
'auth';
379 var $PREFIX =
'_yadis_services_';
391 $session_key_suffix = null)
394 $this->session = $session;
396 if ($session_key_suffix === null) {
397 $session_key_suffix = $this->DEFAULT_SUFFIX;
400 $this->session_key_suffix = $session_key_suffix;
401 $this->session_key = $this->PREFIX . $this->session_key_suffix;
410 $manager = $this->getManager();
411 if (!$manager || (!$manager->services)) {
412 $this->destroyManager();
414 list($yadis_url, $services) = call_user_func($discover_cb,
418 $manager = $this->createManager($services, $yadis_url);
423 $service = $manager->nextService();
424 $this->session->set($this->session_key,
425 serialize(
$loader->toSession($manager)));
443 $manager = $this->getManager($force);
445 $service = $manager->current();
446 $this->destroyManager($force);
460 return $this->PREFIX . $this->session_key_suffix;
474 $manager_str = $this->session->get($this->getSessionKey());
477 if ($manager_str !== null) {
479 $manager =
$loader->fromSession(unserialize($manager_str));
482 if ($manager && ($manager->forURL($this->url) || $force)) {
492 $key = $this->getSessionKey();
493 if ($this->getManager()) {
494 return $this->getManager();
501 $this->session->set($this->session_key,
502 serialize(
$loader->toSession($manager)));
515 if ($this->getManager($force) !== null) {
516 $key = $this->getSessionKey();
517 $this->session->del($key);
Auth_Yadis_Manager($starting_url, $yadis_url, $services, $session_key)
Intialize a new yadis service manager.
toSession($obj)
Returns an array of keys and values built from the attributes of $obj.
contents()
Return the contents of the session in array form.
destroyManager($force=false)
private
newObject($data)
Returns a new instance of this loader's class, using the session data to construct it if necessary...
fromSession($data)
Given a session data value (an array), this creates an object (returned by $this->newObject()) whose ...
createManager($services, $yadis_url=null)
private
check($data)
Override this.
nextService()
Return the next service.
prepareForLoad($data)
Prepares the data array by making any necessary changes.
Object representing an OpenID service endpoint.
getManager($force=false)
private
del($name)
Remove a key/value pair from the session.
cleanup($force=false)
Clean up Yadis-related services in the session and return the most-recently-attempted service from th...
prepareForSave($obj)
Override this.
Auth_Yadis_Discovery($session, $url, $session_key_suffix=null)
Initialize a discovery object.
getNextService($discover_cb, $fetcher)
Return the next authentication service for the pair of user_input and session.