ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Auth_OpenID_NamespaceMap Class Reference
+ Collaboration diagram for Auth_OpenID_NamespaceMap:

Public Member Functions

 Auth_OpenID_NamespaceMap ()
 
 getAlias ($namespace_uri)
 
 getNamespaceURI ($alias)
 
 iterNamespaceURIs ()
 
 iterAliases ()
 
 iteritems ()
 
 isImplicit ($namespace_uri)
 
 addAlias ($namespace_uri, $desired_alias, $implicit=false)
 
 add ($namespace_uri)
 
 contains ($namespace_uri)
 
 isDefined ($namespace_uri)
 

Detailed Description

Definition at line 275 of file Message.php.

Member Function Documentation

◆ add()

Auth_OpenID_NamespaceMap::add (   $namespace_uri)

Definition at line 370 of file Message.php.

372 {
373 // Add this namespace URI to the mapping, without caring what
374 // alias it ends up with
375
376 // See if this namespace is already mapped to an alias
377 $alias = $this->namespace_to_alias->get($namespace_uri);
378
379 if ($alias !== null) {
380 return $alias;
381 }
382
383 // Fall back to generating a numerical alias
384 $i = 0;
385 while (1) {
386 $alias = 'ext' . strval($i);
387 if ($this->addAlias($namespace_uri, $alias) === null) {
388 $i += 1;
389 } else {
390 return $alias;
391 }
392 }
393
394 // Should NEVER be reached!
395 return null;
addAlias($namespace_uri, $desired_alias, $implicit=false)
Definition: Message.php:315

References addAlias().

+ Here is the call graph for this function:

◆ addAlias()

Auth_OpenID_NamespaceMap::addAlias (   $namespace_uri,
  $desired_alias,
  $implicit = false 
)

Definition at line 315 of file Message.php.

317 {
318 // Add an alias from this namespace URI to the desired alias
320
321 // Check that desired_alias is not an openid protocol field as
322 // per the spec.
323 if (in_array($desired_alias, $Auth_OpenID_OPENID_PROTOCOL_FIELDS)) {
324 Auth_OpenID::log("\"%s\" is not an allowed namespace alias",
325 $desired_alias);
326 return null;
327 }
328
329 // Check that desired_alias does not contain a period as per
330 // the spec.
331 if (strpos($desired_alias, '.') !== false) {
332 Auth_OpenID::log('"%s" must not contain a dot', $desired_alias);
333 return null;
334 }
335
336 // Check that there is not a namespace already defined for the
337 // desired alias
338 $current_namespace_uri =
339 $this->alias_to_namespace->get($desired_alias);
340
341 if (($current_namespace_uri !== null) &&
342 ($current_namespace_uri != $namespace_uri)) {
343 Auth_OpenID::log('Cannot map "%s" because previous mapping exists',
344 $namespace_uri);
345 return null;
346 }
347
348 // Check that there is not already a (different) alias for
349 // this namespace URI
350 $alias = $this->namespace_to_alias->get($namespace_uri);
351
352 if (($alias !== null) && ($alias != $desired_alias)) {
353 Auth_OpenID::log('Cannot map %s to alias %s. ' .
354 'It is already mapped to alias %s',
355 $namespace_uri, $desired_alias, $alias);
356 return null;
357 }
358
359 assert((Auth_OpenID_NULL_NAMESPACE === $desired_alias) ||
360 is_string($desired_alias));
361
362 $this->alias_to_namespace->set($desired_alias, $namespace_uri);
363 $this->namespace_to_alias->set($namespace_uri, $desired_alias);
364 if ($implicit) {
365 array_push($this->implicit_namespaces, $namespace_uri);
366 }
367
368 return $desired_alias;
global $Auth_OpenID_OPENID_PROTOCOL_FIELDS
Definition: Message.php:57
const Auth_OpenID_NULL_NAMESPACE
Definition: Message.php:39
static log($format_string)
Wrap PHP's standard error_log functionality.
Definition: OpenID.php:525

References $Auth_OpenID_OPENID_PROTOCOL_FIELDS, Auth_OpenID_NULL_NAMESPACE, and Auth_OpenID\log().

Referenced by add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Auth_OpenID_NamespaceMap()

Auth_OpenID_NamespaceMap::Auth_OpenID_NamespaceMap ( )

Definition at line 276 of file Message.php.

276 {
277 function Auth_OpenID_NamespaceMap()
278 {
279 $this->alias_to_namespace = new Auth_OpenID_Mapping();
280 $this->namespace_to_alias = new Auth_OpenID_Mapping();
281 $this->implicit_namespaces = array();

References Auth_OpenID_NamespaceMap().

Referenced by Auth_OpenID_NamespaceMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ contains()

Auth_OpenID_NamespaceMap::contains (   $namespace_uri)

Definition at line 397 of file Message.php.

399 {
400 return $this->isDefined($namespace_uri);
isDefined($namespace_uri)
Definition: Message.php:402

References isDefined().

+ Here is the call graph for this function:

◆ getAlias()

Auth_OpenID_NamespaceMap::getAlias (   $namespace_uri)

Definition at line 283 of file Message.php.

285 {
286 return $this->namespace_to_alias->get($namespace_uri);

◆ getNamespaceURI()

Auth_OpenID_NamespaceMap::getNamespaceURI (   $alias)

Definition at line 288 of file Message.php.

290 {
291 return $this->alias_to_namespace->get($alias);

◆ isDefined()

Auth_OpenID_NamespaceMap::isDefined (   $namespace_uri)

Definition at line 402 of file Message.php.

404 {
405 return $this->namespace_to_alias->contains($namespace_uri);

Referenced by contains().

+ Here is the caller graph for this function:

◆ isImplicit()

Auth_OpenID_NamespaceMap::isImplicit (   $namespace_uri)

Definition at line 310 of file Message.php.

312 {
313 return in_array($namespace_uri, $this->implicit_namespaces);

◆ iterAliases()

Auth_OpenID_NamespaceMap::iterAliases ( )

Definition at line 299 of file Message.php.

301 {
302 // Return an iterator over the aliases"""
303 return $this->alias_to_namespace->keys();

◆ iteritems()

Auth_OpenID_NamespaceMap::iteritems ( )

Definition at line 305 of file Message.php.

307 {
308 return $this->namespace_to_alias->items();

◆ iterNamespaceURIs()

Auth_OpenID_NamespaceMap::iterNamespaceURIs ( )

Definition at line 293 of file Message.php.

295 {
296 // Return an iterator over the namespace URIs
297 return $this->namespace_to_alias->keys();

The documentation for this class was generated from the following file: