private function load()
{
$url = fix_parse_url($this->url);
$response = SimpleHTTP::send('POST', $url['host'], $url['port'], $url['path'], array('a' => 'description'));
if ('200' != $response['status_code']) {
throw new Exception("Invalid status code `{$response['status_code']}' returned from server `{$url['host']}'.");
}
$descriptor_xml = trim($response['body']);
if ('' === $descriptor_xml) {
throw new Exception("Unable to load project descriptor from `{$url['host']}{$url['path']}'.");
}
$project = new SimpleXMLElement($descriptor_xml);
$this->name = (string) $project->configuration->name;
$this->protocol_version = (double) $project->configuration->protocol_version;
$this->authentication_scheme = (string) $project->configuration->authentication_scheme;
if (1.0 != $this->protocol_version) {
// currently the only one supported
throw new Exception("Unsupported project protocol version `{$this->protocol_version}'.");
}
// checking authorization scheme type
$is_authenticated = false;
$auth_params = '';
switch ($this->authentication_scheme) {
case 'readonly':
case 'anyone':
$is_authenticated = true;
break;
case 'external_login_page':
$auth_params = (string) $project->configuration->authentication_params;
break;
case 'external_login_handler':
$auth_params = (string) $project->configuration->authentication_params;
break;
case 'facebook':
break;
case 'openid':
break;
default:
throw new Exception("Unsupported authentication scheme `{$this->authentication_scheme}'.");
}
$this->authentication_params = $auth_params;
}