ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
Discover.php File Reference

Go to the source code of this file.

Data Structures

class  Auth_OpenID_ServiceEndpoint
 Object representing an OpenID service endpoint. More...

Functions

 Auth_OpenID_getOpenIDTypeURIs ()
 Auth_OpenID_getOpenIDConsumerTypeURIs ()
 Auth_OpenID_getOpenIDTypeName ($type_uri)
 Auth_OpenID_findOPLocalIdentifier ($service, $type_uris)
 filter_MatchesAnyOpenIDType ($service)
 filter_MatchesAnyOpenIDConsumerType (&$service)
 Auth_OpenID_bestMatchingService ($service, $preferred_types)
 Auth_OpenID_arrangeByType ($service_list, $preferred_types)
 Auth_OpenID_getOPOrUserServices ($openid_services)
 Auth_OpenID_makeOpenIDEndpoints ($uri, $yadis_services)
 Auth_OpenID_discoverWithYadis ($uri, $fetcher, $endpoint_filter='Auth_OpenID_getOPOrUserServices', $discover_function=null)
 Auth_OpenID_discoverURI ($uri, $fetcher)
 Auth_OpenID_discoverWithoutYadis ($uri, $fetcher)
 Auth_OpenID_discoverXRI ($iname, $fetcher)
 Auth_OpenID_discover ($uri, $fetcher)

Variables

const Auth_OpenID_XMLNS_1_0 = 'http://openid.net/xmlns/1.0'
 The OpenID and Yadis discovery implementation for OpenID 1.2.
const Auth_OpenID_TYPE_1_2 = 'http://openid.net/signon/1.2'
const Auth_OpenID_TYPE_1_1 = 'http://openid.net/signon/1.1'
const Auth_OpenID_TYPE_1_0 = 'http://openid.net/signon/1.0'
const Auth_OpenID_TYPE_2_0_IDP = 'http://specs.openid.net/auth/2.0/server'
const Auth_OpenID_TYPE_2_0 = 'http://specs.openid.net/auth/2.0/signon'
const Auth_OpenID_RP_RETURN_TO_URL_TYPE = 'http://specs.openid.net/auth/2.0/return_to'

Function Documentation

Auth_OpenID_arrangeByType (   $service_list,
  $preferred_types 
)

Definition at line 397 of file Discover.php.

References Auth_OpenID_bestMatchingService().

Referenced by Auth_OpenID_getOPOrUserServices().

{
// Rearrange service_list in a new list so services are ordered by
// types listed in preferred_types. Return the new list.
// Build a list with the service elements in tuples whose
// comparison will prefer the one with the best matching service
$prio_services = array();
foreach ($service_list as $index => $service) {
$prio_services[] = array(Auth_OpenID_bestMatchingService($service,
$preferred_types),
$index, $service);
}
sort($prio_services);
// Now that the services are sorted by priority, remove the sort
// keys from the list.
foreach ($prio_services as $index => $s) {
$prio_services[$index] = $prio_services[$index][2];
}
return $prio_services;

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_bestMatchingService (   $service,
  $preferred_types 
)

Definition at line 378 of file Discover.php.

Referenced by Auth_OpenID_arrangeByType().

{
// Return the index of the first matching type, or something
// higher if no type matches.
//
// This provides an ordering in which service elements that
// contain a type that comes earlier in the preferred types list
// come before service elements that come later. If a service
// element has more than one type, the most preferred one wins.
foreach ($preferred_types as $index => $typ) {
if (in_array($typ, $service->type_uris)) {
return $index;
}
}
return count($preferred_types);

+ Here is the caller graph for this function:

Auth_OpenID_discover (   $uri,
  $fetcher 
)

Definition at line 573 of file Discover.php.

References $result, Auth_OpenID_discoverURI(), Auth_OpenID_discoverXRI(), and Auth_Yadis_identifierScheme().

{
// If the fetcher (i.e., PHP) doesn't support SSL, we can't do
// discovery on an HTTPS URL.
if ($fetcher->isHTTPS($uri) && !$fetcher->supportsSSL()) {
return array($uri, array());
}
if (Auth_Yadis_identifierScheme($uri) == 'XRI') {
$result = Auth_OpenID_discoverXRI($uri, $fetcher);
} else {
$result = Auth_OpenID_discoverURI($uri, $fetcher);
}
// If the fetcher doesn't support SSL, we can't interact with
// HTTPS server URLs; remove those endpoints from the list.
if (!$fetcher->supportsSSL()) {
$http_endpoints = array();
list($new_uri, $endpoints) = $result;
foreach ($endpoints as $e) {
if (!$fetcher->isHTTPS($e->server_url)) {
$http_endpoints[] = $e;
}
}
$result = array($new_uri, $http_endpoints);
}
return $result;

+ Here is the call graph for this function:

Auth_OpenID_discoverURI (   $uri,
  $fetcher 
)

Definition at line 525 of file Discover.php.

References Auth_OpenID_discoverWithYadis(), and Auth_OpenID\normalizeUrl().

Referenced by Auth_OpenID_discover().

{
return Auth_OpenID_discoverWithYadis($uri, $fetcher);

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_discoverWithoutYadis (   $uri,
  $fetcher 
)

Definition at line 531 of file Discover.php.

References Auth_OpenID_ServiceEndpoint\fromHTML().

Referenced by Auth_OpenID_discoverWithYadis().

{
$http_resp = @$fetcher->get($uri);
if ($http_resp->status != 200 and $http_resp->status != 206) {
return array($uri, array());
}
$identity_url = $http_resp->final_url;
// Try to parse the response as HTML to get OpenID 1.0/1.1 <link
// rel="...">
$identity_url,
$http_resp->body);
return array($identity_url, $openid_services);

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_discoverWithYadis (   $uri,
  $fetcher,
  $endpoint_filter = 'Auth_OpenID_getOPOrUserServices',
  $discover_function = null 
)

Definition at line 475 of file Discover.php.

References Auth_OpenID_discoverWithoutYadis(), Auth_OpenID_ServiceEndpoint\fromHTML(), and Auth_OpenID_ServiceEndpoint\fromXRDS().

Referenced by Auth_OpenID_discoverURI().

{
// Discover OpenID services for a URI. Tries Yadis and falls back
// on old-style <link rel='...'> discovery if Yadis fails.
// Might raise a yadis.discover.DiscoveryFailure if no document
// came back for that URI at all. I don't think falling back to
// OpenID 1.0 discovery on the same URL will help, so don't bother
// to catch it.
if ($discover_function === null) {
$discover_function = array('Auth_Yadis_Yadis', 'discover');
}
$openid_services = array();
$response = call_user_func_array($discover_function,
array($uri, $fetcher));
$yadis_url = $response->normalized_uri;
$yadis_services = array();
if ($response->isFailure() && !$response->isXRDS()) {
return array($uri, array());
}
$yadis_url,
$response->response_text);
if (!$openid_services) {
if ($response->isXRDS()) {
$fetcher);
}
// Try to parse the response as HTML to get OpenID 1.0/1.1
// <link rel="...">
$yadis_url,
$response->response_text);
}
$openid_services = call_user_func_array($endpoint_filter,
array($openid_services));
return array($yadis_url, $openid_services);

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_discoverXRI (   $iname,
  $fetcher 
)

Definition at line 550 of file Discover.php.

References Auth_OpenID_getOpenIDTypeURIs(), Auth_OpenID_getOPOrUserServices(), and Auth_OpenID_makeOpenIDEndpoints().

Referenced by Auth_OpenID_discover().

{
$resolver = new Auth_Yadis_ProxyResolver($fetcher);
list($canonicalID, $yadis_services) =
$resolver->query($iname,
array('filter_MatchesAnyOpenIDType'));
$openid_services = Auth_OpenID_makeOpenIDEndpoints($iname,
$yadis_services);
$openid_services = Auth_OpenID_getOPOrUserServices($openid_services);
for ($i = 0; $i < count($openid_services); $i++) {
$openid_services[$i]->canonicalID = $canonicalID;
$openid_services[$i]->claimed_id = $canonicalID;
$openid_services[$i]->display_identifier = $iname;
}
// FIXME: returned xri should probably be in some normal form
return array($iname, $openid_services);

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_findOPLocalIdentifier (   $service,
  $type_uris 
)

Definition at line 307 of file Discover.php.

References Auth_OpenID_TYPE_1_0, Auth_OpenID_TYPE_1_1, Auth_OpenID_TYPE_2_0, Auth_OpenID_XMLNS_1_0, and Auth_Yadis_XMLNS_XRD_2_0.

Referenced by Auth_OpenID_ServiceEndpoint\parseService().

{
// Extract a openid:Delegate value from a Yadis Service element.
// If no delegate is found, returns null. Returns false on
// discovery failure (when multiple delegate/localID tags have
// different values).
$service->parser->registerNamespace('openid',
$service->parser->registerNamespace('xrd',
$parser = $service->parser;
$permitted_tags = array();
if (in_array(Auth_OpenID_TYPE_1_1, $type_uris) ||
in_array(Auth_OpenID_TYPE_1_0, $type_uris)) {
$permitted_tags[] = 'openid:Delegate';
}
if (in_array(Auth_OpenID_TYPE_2_0, $type_uris)) {
$permitted_tags[] = 'xrd:LocalID';
}
$local_id = null;
foreach ($permitted_tags as $tag_name) {
$tags = $service->getElements($tag_name);
foreach ($tags as $tag) {
$content = $parser->content($tag);
if ($local_id === null) {
$local_id = $content;
} else if ($local_id != $content) {
return false;
}
}
}
return $local_id;

+ Here is the caller graph for this function:

Auth_OpenID_getOpenIDConsumerTypeURIs ( )

Definition at line 33 of file Discover.php.

References Auth_OpenID_RP_RETURN_TO_URL_TYPE.

Referenced by filter_MatchesAnyOpenIDConsumerType().

+ Here is the caller graph for this function:

Auth_OpenID_getOpenIDTypeName (   $type_uri)

Definition at line 43 of file Discover.php.

References Auth_OpenID_RP_RETURN_TO_URL_TYPE, Auth_OpenID_TYPE_1_0, Auth_OpenID_TYPE_1_1, Auth_OpenID_TYPE_1_2, Auth_OpenID_TYPE_2_0, and Auth_OpenID_TYPE_2_0_IDP.

{
switch ($type_uri) {
return 'OpenID 2.0 IDP';
return 'OpenID 2.0';
return 'OpenID 1.2';
return 'OpenID 1.1';
return 'OpenID 1.0';
return 'OpenID relying party';
}
Auth_OpenID_getOPOrUserServices (   $openid_services)

Definition at line 429 of file Discover.php.

References Auth_OpenID_arrangeByType(), Auth_OpenID_getOpenIDTypeURIs(), and Auth_OpenID_TYPE_2_0_IDP.

Referenced by Auth_OpenID_discoverXRI().

{
$op_services = Auth_OpenID_arrangeByType($openid_services,
$openid_services = Auth_OpenID_arrangeByType($openid_services,
if ($op_services) {
return $op_services;
} else {
return $openid_services;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Auth_OpenID_makeOpenIDEndpoints (   $uri,
  $yadis_services 
)

Definition at line 444 of file Discover.php.

Referenced by Auth_OpenID_discoverXRI(), Auth_OpenID_ServiceEndpoint\consumerFromXRDS(), and Auth_OpenID_ServiceEndpoint\fromXRDS().

{
$s = array();
if (!$yadis_services) {
return $s;
}
foreach ($yadis_services as $service) {
$type_uris = $service->getTypes();
$uris = $service->getURIs();
// If any Type URIs match and there is an endpoint URI
// specified, then this is an OpenID endpoint
if ($type_uris &&
$uris) {
foreach ($uris as $service_uri) {
$openid_endpoint = new Auth_OpenID_ServiceEndpoint();
if ($openid_endpoint->parseService($uri,
$service_uri,
$type_uris,
$service)) {
$s[] = $openid_endpoint;
}
}
}
}
return $s;

+ Here is the caller graph for this function:

filter_MatchesAnyOpenIDConsumerType ( $service)

Definition at line 365 of file Discover.php.

References Auth_OpenID_getOpenIDConsumerTypeURIs().

{
$uris = $service->getTypes();
foreach ($uris as $uri) {
if (in_array($uri, Auth_OpenID_getOpenIDConsumerTypeURIs())) {
return true;
}
}
return false;

+ Here is the call graph for this function:

filter_MatchesAnyOpenIDType (   $service)

Definition at line 352 of file Discover.php.

References Auth_OpenID_getOpenIDTypeURIs().

{
$uris = $service->getTypes();
foreach ($uris as $uri) {
if (in_array($uri, Auth_OpenID_getOpenIDTypeURIs())) {
return true;
}
}
return false;

+ Here is the call graph for this function:

Variable Documentation

const Auth_OpenID_RP_RETURN_TO_URL_TYPE = 'http://specs.openid.net/auth/2.0/return_to'
const Auth_OpenID_TYPE_1_0 = 'http://openid.net/signon/1.0'
const Auth_OpenID_TYPE_1_2 = 'http://openid.net/signon/1.2'

Definition at line 17 of file Discover.php.

Referenced by Auth_OpenID_getOpenIDTypeName(), and Auth_OpenID_getOpenIDTypeURIs().

const Auth_OpenID_XMLNS_1_0 = 'http://openid.net/xmlns/1.0'

The OpenID and Yadis discovery implementation for OpenID 1.2.

Definition at line 14 of file Discover.php.

Referenced by Auth_OpenID_findOPLocalIdentifier().