summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/openid/lib/Auth/OpenID/Discover.php')
-rw-r--r--plugins/openid/lib/Auth/OpenID/Discover.php93
1 files changed, 50 insertions, 43 deletions
diff --git a/plugins/openid/lib/Auth/OpenID/Discover.php b/plugins/openid/lib/Auth/OpenID/Discover.php
index 95c32f45..177d4880 100644
--- a/plugins/openid/lib/Auth/OpenID/Discover.php
+++ b/plugins/openid/lib/Auth/OpenID/Discover.php
@@ -24,16 +24,18 @@ define('Auth_OpenID_RP_RETURN_TO_URL_TYPE',
function Auth_OpenID_getOpenIDTypeURIs()
{
- return array(Auth_OpenID_TYPE_2_0_IDP,
- Auth_OpenID_TYPE_2_0,
- Auth_OpenID_TYPE_1_2,
- Auth_OpenID_TYPE_1_1,
- Auth_OpenID_TYPE_1_0);
+ return [
+ Auth_OpenID_TYPE_2_0_IDP,
+ Auth_OpenID_TYPE_2_0,
+ Auth_OpenID_TYPE_1_2,
+ Auth_OpenID_TYPE_1_1,
+ Auth_OpenID_TYPE_1_0,
+ ];
}
function Auth_OpenID_getOpenIDConsumerTypeURIs()
{
- return array(Auth_OpenID_RP_RETURN_TO_URL_TYPE);
+ return [Auth_OpenID_RP_RETURN_TO_URL_TYPE];
}
@@ -67,7 +69,7 @@ class Auth_OpenID_ServiceEndpoint {
{
$this->claimed_id = null;
$this->server_url = null;
- $this->type_uris = array();
+ $this->type_uris = [];
$this->local_id = null;
$this->canonicalID = null;
$this->used_yadis = false; // whether this came from an XRDS
@@ -123,7 +125,7 @@ class Auth_OpenID_ServiceEndpoint {
*/
function matchTypes($type_uris)
{
- $result = array();
+ $result = [];
foreach ($type_uris as $test_uri) {
if ($this->supportsType($test_uri)) {
$result[] = $test_uri;
@@ -157,7 +159,7 @@ class Auth_OpenID_ServiceEndpoint {
// a given OP Endpoint URL
$obj = new Auth_OpenID_ServiceEndpoint();
$obj->server_url = $op_endpoint_url;
- $obj->type_uris = array(Auth_OpenID_TYPE_2_0_IDP);
+ $obj->type_uris = [Auth_OpenID_TYPE_2_0_IDP];
return $obj;
}
@@ -210,7 +212,7 @@ class Auth_OpenID_ServiceEndpoint {
if ($xrds) {
$yadis_services =
- $xrds->services(array('filter_MatchesAnyOpenIDConsumerType'));
+ $xrds->services(['filter_MatchesAnyOpenIDConsumerType']);
return Auth_OpenID_makeOpenIDEndpoints($uri, $yadis_services);
}
@@ -229,7 +231,7 @@ class Auth_OpenID_ServiceEndpoint {
if ($xrds) {
$yadis_services =
- $xrds->services(array('filter_MatchesAnyOpenIDType'));
+ $xrds->services(['filter_MatchesAnyOpenIDType']);
return Auth_OpenID_makeOpenIDEndpoints($uri, $yadis_services);
}
@@ -258,14 +260,20 @@ class Auth_OpenID_ServiceEndpoint {
static function fromHTML($uri, $html)
{
- $discovery_types = array(
- array(Auth_OpenID_TYPE_2_0,
- 'openid2.provider', 'openid2.local_id'),
- array(Auth_OpenID_TYPE_1_1,
- 'openid.server', 'openid.delegate')
- );
-
- $services = array();
+ $discovery_types = [
+ [
+ Auth_OpenID_TYPE_2_0,
+ 'openid2.provider',
+ 'openid2.local_id',
+ ],
+ [
+ Auth_OpenID_TYPE_1_1,
+ 'openid.server',
+ 'openid.delegate',
+ ],
+ ];
+
+ $services = [];
foreach ($discovery_types as $triple) {
list($type_uri, $server_rel, $delegate_rel) = $triple;
@@ -283,7 +291,7 @@ class Auth_OpenID_ServiceEndpoint {
$service->claimed_id = $uri;
$service->local_id = $delegate_url;
$service->server_url = $server_url;
- $service->type_uris = array($type_uri);
+ $service->type_uris = [$type_uri];
$services[] = $service;
}
@@ -326,7 +334,7 @@ function Auth_OpenID_findOPLocalIdentifier($service, $type_uris)
$parser = $service->parser;
- $permitted_tags = array();
+ $permitted_tags = [];
if (in_array(Auth_OpenID_TYPE_1_1, $type_uris) ||
in_array(Auth_OpenID_TYPE_1_0, $type_uris)) {
@@ -416,11 +424,13 @@ function Auth_OpenID_arrangeByType($service_list, $preferred_types)
// Build a list with the service elements in tuples whose
// comparison will prefer the one with the best matching service
- $prio_services = array();
+ $prio_services = [];
foreach ($service_list as $index => $service) {
- $prio_services[] = array(Auth_OpenID_bestMatchingService($service,
- $preferred_types),
- $index, $service);
+ $prio_services[] = [
+ Auth_OpenID_bestMatchingService($service, $preferred_types),
+ $index,
+ $service,
+ ];
}
sort($prio_services);
@@ -443,11 +453,9 @@ function Auth_OpenID_arrangeByType($service_list, $preferred_types)
// Returns a list of OpenIDServiceEndpoint objects."""
function Auth_OpenID_getOPOrUserServices($openid_services)
{
- $op_services = Auth_OpenID_arrangeByType($openid_services,
- array(Auth_OpenID_TYPE_2_0_IDP));
+ $op_services = Auth_OpenID_arrangeByType($openid_services, [Auth_OpenID_TYPE_2_0_IDP]);
- $openid_services = Auth_OpenID_arrangeByType($openid_services,
- Auth_OpenID_getOpenIDTypeURIs());
+ $openid_services = Auth_OpenID_arrangeByType($openid_services, Auth_OpenID_getOpenIDTypeURIs());
if ($op_services) {
return $op_services;
@@ -463,7 +471,7 @@ function Auth_OpenID_getOPOrUserServices($openid_services)
*/
function Auth_OpenID_makeOpenIDEndpoints($uri, $yadis_services)
{
- $s = array();
+ $s = [];
if (!$yadis_services) {
return $s;
@@ -504,16 +512,15 @@ function Auth_OpenID_discoverWithYadis($uri, $fetcher,
// 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');
+ $discover_function = ['Auth_Yadis_Yadis', 'discover'];
}
- $response = call_user_func_array($discover_function,
- array($uri, $fetcher));
+ $response = call_user_func_array($discover_function, [$uri, $fetcher]);
$yadis_url = $response->normalized_uri;
if ($response->isFailure() && !$response->isXRDS()) {
- return array($uri, array());
+ return [$uri, []];
}
$openid_services = Auth_OpenID_ServiceEndpoint::fromXRDS(
@@ -534,9 +541,9 @@ function Auth_OpenID_discoverWithYadis($uri, $fetcher,
}
$openid_services = call_user_func_array($endpoint_filter,
- array($openid_services));
+ [$openid_services]);
- return array($yadis_url, $openid_services);
+ return [$yadis_url, $openid_services];
}
function Auth_OpenID_discoverURI($uri, $fetcher)
@@ -555,7 +562,7 @@ function Auth_OpenID_discoverWithoutYadis($uri, $fetcher)
$http_resp = @$fetcher->get($uri);
if ($http_resp->status != 200 and $http_resp->status != 206) {
- return array($uri, array());
+ return [$uri, []];
}
$identity_url = $http_resp->final_url;
@@ -566,7 +573,7 @@ function Auth_OpenID_discoverWithoutYadis($uri, $fetcher)
$identity_url,
$http_resp->body);
- return array($identity_url, $openid_services);
+ return [$identity_url, $openid_services];
}
function Auth_OpenID_discoverXRI($iname, $fetcher)
@@ -575,7 +582,7 @@ function Auth_OpenID_discoverXRI($iname, $fetcher)
list($canonicalID, $yadis_services) =
$resolver->query($iname,
Auth_OpenID_getOpenIDTypeURIs(),
- array('filter_MatchesAnyOpenIDType'));
+ ['filter_MatchesAnyOpenIDType']);
$openid_services = Auth_OpenID_makeOpenIDEndpoints($iname,
$yadis_services);
@@ -589,7 +596,7 @@ function Auth_OpenID_discoverXRI($iname, $fetcher)
}
// FIXME: returned xri should probably be in some normal form
- return array($iname, $openid_services);
+ return [$iname, $openid_services];
}
/**
@@ -602,7 +609,7 @@ function Auth_OpenID_discover($uri, $fetcher)
// 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());
+ return [$uri, []];
}
if (Auth_Yadis_identifierScheme($uri) == 'XRI') {
@@ -614,7 +621,7 @@ function Auth_OpenID_discover($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();
+ $http_endpoints = [];
list($new_uri, $endpoints) = $result;
foreach ($endpoints as $e) {
@@ -623,7 +630,7 @@ function Auth_OpenID_discover($uri, $fetcher)
}
}
- $result = array($new_uri, $http_endpoints);
+ $result = [$new_uri, $http_endpoints];
}
return $result;