Skip to content
Snippets Groups Projects
Commit 6db47f7e authored by Andreas Åkre Solberg's avatar Andreas Åkre Solberg
Browse files

Removed a lot of unused code in discojuice module...

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3016 44740490-163a-0410-bde0-09ae8108e29a
parent ea2f96f6
No related branches found
No related tags found
No related merge requests found
<?php
/**
* Hook to run a cron job.
*
* @param array &$croninfo Output
*/
function discojuice_hook_cron(&$croninfo) {
assert('is_array($croninfo)');
assert('array_key_exists("summary", $croninfo)');
assert('array_key_exists("tag", $croninfo)');
if ($croninfo['tag'] !== 'hourly') return;
SimpleSAML_Logger::info('cron [discojuice metadata caching]: Running cron in tag [' . $croninfo['tag'] . '] ');
try {
$feed = new sspmod_discojuice_Feed();
$feed->store();
} catch (Exception $e) {
$croninfo['summary'][] = 'Error during discojuice metadata caching: ' . $e->getMessage();
}
}
?>
\ No newline at end of file
<?php
/**
* Hook to add links to the frontpage.
*
* @param array &$links The links on the frontpage, split into sections.
*/
function discojuice_hook_frontpage(&$links) {
assert('is_array($links)');
assert('array_key_exists("links", $links)');
$links['federation'][] = array(
'href' => SimpleSAML_Module::getModuleURL('discojuice/central.php'),
'text' => array('en' => 'DiscoJuice: Discovery Service (not functional without IdP Discovery parameters)'),
);
$links['federation'][] = array(
'href' => SimpleSAML_Module::getModuleURL('discojuice/feed.php'),
'text' => array('en' => 'DiscoJuice: Metadata Feed (JSON)'),
);
}
?>
\ No newline at end of file
<?php
/**
* ...
*/
class sspmod_discojuice_CentralHelper {
public static function show($path = '/simplesaml/module.php/discojuice/discojuice/') {
$djconfig = SimpleSAML_Configuration::getOptionalConfig('discojuicecentral.php');
$config = SimpleSAML_Configuration::getInstance();
$feed = new sspmod_discojuice_Feed();
$metadata = json_decode($feed->read(), TRUE);
$t = new SimpleSAML_XHTML_Template($config, 'discojuice:central.tpl.php');
$t->data['metadata'] = $metadata;
$t->data['discojuice.options'] = $djconfig->getValue('discojuice.options');
$t->data['discojuice.options']['discoPath'] = $path;
$t->data['acl'] = $djconfig->getValue('acl');
$t->show();
}
}
<?php
/**
* ...
*/
class sspmod_discojuice_Country {
const CACHETIME = 86400;
/* Instance of sspmod_core_Storage_SQLPermanentStorage
*
* key1 calendar URL
* key2 NULL
* type 'calendar'
*
*/
public $store;
public $ip;
public function __construct($ip = NULL) {
if (is_null($ip)) $ip = $_SERVER['REMOTE_ADDR'];
if (empty($ip))
throw new Exception('Trying to use the TimeZone class without specifying an IP address');
$this->ip = $ip;
$this->store = new sspmod_core_Storage_SQLPermanentStorage('iptimezone');
}
public function lookupRegion($region) {
if ($this->store->exists('region', $region, NULL)) {
SimpleSAML_Logger::debug('IP Geo location: Found region [' . $region . '] in cache.');
return $this->store->getValue('region', $region, NULL);
}
SimpleSAML_Logger::debug('Lookup region');
$rawdata = file_get_contents('http://freegeoip.net/tz/json/' . $region);
if (empty($rawdata)) throw new Exception('Error looking up IP geo location for [' . $ip . ']');
$data = json_decode($rawdata, TRUE);
if (empty($data)) throw new Exception('Error decoding response from looking up IP geo location for [' . $ip . ']');
if (empty($data['timezone'])) throw new Exception('Could not get TimeZone from IP lookup');
$timezone = $data['timezone'];
SimpleSAML_Logger::debug('IP Geo location: Store region [' . $region . '] in cache: ' . $timezone);
$this->store->set('region', $region, NULL, $timezone);
return $timezone;
}
public function getRegion() {
return $this->lookupIP($this->ip);
}
public function getGeo() {
return $this->lookupGeo($this->ip);
}
public function lookupGeo($ip) {
if ($this->store->exists('geo', $ip, NULL)) {
SimpleSAML_Logger::debug('IP Geo location (geo): Found ip [' . $ip . '] in cache.');
$stored = $this->store->getValue('geo', $ip, NULL);
if ($stored === NULL) throw new Exception('Got negative cache for this IP');
return $stored;
}
SimpleSAML_Logger::debug('Lookup IP');
$rawdata = file_get_contents('http://freegeoip.net/json/' . $ip);
if (empty($rawdata)) throw new Exception('Error looking up IP geo location for [' . $ip . ']');
$data = json_decode($rawdata, TRUE);
if (empty($data)) throw new Exception('Error decoding response from looking up IP geo location for [' . $ip . ']');
if (empty($data['longitude'])) {
$this->store->set('geo', $ip, NULL, NULL);
}
if (empty($data['longitude'])) throw new Exception('Could not get longitude from IP lookup');
if (empty($data['latitude'])) throw new Exception( 'Could not get latitude from IP lookup');
$geo = $data['latitude'] . ',' . $data['longitude'];
SimpleSAML_Logger::debug('IP Geo location: Store ip [' . $ip . '] in cache: ' . $geo);
$this->store->set('geo', $ip, NULL, $geo);
return $geo;
}
public function lookupIP($ip) {
if ($this->store->exists('ip', $ip, NULL)) {
SimpleSAML_Logger::debug('IP Geo location: Found ip [' . $ip . '] in cache.');
return $this->store->getValue('ip', $ip, NULL);
}
SimpleSAML_Logger::debug('Lookup IP [' . $ip. ']');
$rawdata = file_get_contents('http://freegeoip.net/json/' . $ip);
if (empty($rawdata)) throw new Exception('Error looking up IP geo location for [' . $ip . ']');
$data = json_decode($rawdata, TRUE);
if (empty($data)) throw new Exception('Error decoding response from looking up IP geo location for [' . $ip . ']');
SimpleSAML_Logger::info('Country code: ' . $data['country_code']);
if (empty($data['country_code'])) throw new Exception('Could not get Coutry Code from IP lookup : ' . var_export($data, TRUE));
if (empty($data['region_code'])) $region = 'NA';
$region = $data['country_code'] . '/' . $data['region_code'];
SimpleSAML_Logger::debug('IP Geo location: Store ip [' . $ip . '] in cache: ' . $region);
$this->store->set('ip', $ip, NULL, $region);
return $region;
}
public function getTimeZone() {
$tz = 'Europe/Amsterdam';
try {
$tz = $this->lookupRegion($this->lookupIP($this->ip));
} catch(Exception $e) {
$tz = 'Europe/Amsterdam';
}
return $tz;
}
public function getSelectedTimeZone() {
if (isset($_REQUEST['timezone'])) {
return $_REQUEST['timezone'];
}
return $this->getTimeZone();
}
public function getHTMLList($default = NULL, $autosubmit = FALSE) {
$tzlist = DateTimeZone::listIdentifiers();
$tzlist = array_reverse($tzlist);
$thiszone = $this->getTimeZone();
if (is_null($default)) $default = $thiszone;
$a = '';
if ($autosubmit) $a = "onchange='this.form.submit()' ";
$html = '<select ' . $a . 'name="timezone">' . "\n";
foreach($tzlist AS $tz) {
if ($tz == $default) {
$html .= ' <option selected="selected" value="' . htmlspecialchars($tz) . '">' . htmlspecialchars($tz) . '</option>' . "\n";
} else {
$html .= ' <option value="' . htmlspecialchars($tz) . '">' . htmlspecialchars($tz) . '</option>' . "\n";
}
}
$html .= '</select>' . "\n";
return $html;
}
}
<?php
/**
* ...
*/
class sspmod_discojuice_EmbedHelper {
public static function head($includeJQuery = TRUE) {
$version = '0.1-4';
$config = SimpleSAML_Configuration::getInstance();
$djconfig = SimpleSAML_Configuration::getOptionalConfig('discojuiceembed.php');
if ($includeJQuery) {
echo '
<!-- JQuery (Required for DiscoJuice) -->
<script type="text/javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/jquery-1.6.min.js') . '"></script>
<script type="text/javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/jquery-ui-1.8.5.custom.min.js') . '"></script>
<link rel="stylesheet" type="text/css" href="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/css/custom/jquery-ui-1.8.5.custom.css') . '" />
';
}
echo '
<!-- DiscoJuice (version identifier: ' . $version . ' ) -->
<script type="text/javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuice.misc.js?v=' . $version) . '"></script>
<script type="text/javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuice.ui.js?v=' . $version) . '"></script>
<script type="text/javascript" src="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuice.control.js?v=' . $version) . '"></script>
<link rel="stylesheet" type="text/css" href="' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/css/discojuice.css?v=' . $version) . '" />
';
$options = $djconfig->getValue('discojuice.options');
$target = $djconfig->getValue('target');
echo '<script type="text/javascript">';
echo 'var options = ' . json_encode($options) . ';' . "\n";
echo 'var target = "' . $target . '";' . "\n\n";
echo 'options.countryAPI = "' . SimpleSAML_Module::getModuleURL('discojuice/country.php'). '"; ' . "\n";
if (empty($options['metadata'])) {
echo 'options.metadata = "' . SimpleSAML_Module::getModuleURL('discojuice/feed.php'). '"; ' . "\n";
}
if (!empty($options['disco'])) {
echo 'options.disco.url = "' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/discojuiceDiscoveryResponse.html?'). '"; ' . "\n";
}
echo 'options.discoPath = "' . SimpleSAML_Module::getModuleURL('discojuice/discojuice/') . '"; ' . "\n";
echo 'options.callback = ' . $djconfig->getValue('callback', 'null') . ';' . "\n\n";
echo '
$(document).ready(function() {
$(target).DiscoJuice(options);
});
</script>
';
}
}
<?php
/*
* File: SimpleImage.php
* Author: Simon Jarvis
* Copyright: 2006 Simon Jarvis
* Date: 08/11/06
* Link: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
* http://www.gnu.org/licenses/gpl.html
*
*/
class SimpleImage {
var $image;
var $image_type;
function load($filename) {
$image_info = getimagesize($filename);
$this->image_type = $image_info[2];
if( $this->image_type == IMAGETYPE_JPEG ) {
$this->image = imagecreatefromjpeg($filename);
} elseif( $this->image_type == IMAGETYPE_GIF ) {
$this->image = imagecreatefromgif($filename);
} elseif( $this->image_type == IMAGETYPE_PNG ) {
$this->image = imagecreatefrompng($filename);
}
}
function save($filename, $image_type=IMAGETYPE_PNG, $compression=90, $permissions=null) {
if( $image_type == IMAGETYPE_JPEG ) {
imagejpeg($this->image,$filename,$compression);
} elseif( $image_type == IMAGETYPE_GIF ) {
imagegif($this->image,$filename);
} elseif( $image_type == IMAGETYPE_PNG ) {
imagepng($this->image,$filename);
}
if( $permissions != null) {
chmod($filename,$permissions);
}
}
function output($image_type=IMAGETYPE_JPEG) {
if( $image_type == IMAGETYPE_JPEG ) {
imagejpeg($this->image);
} elseif( $image_type == IMAGETYPE_GIF ) {
imagegif($this->image);
} elseif( $image_type == IMAGETYPE_PNG ) {
imagepng($this->image);
}
}
function getWidth() {
return imagesx($this->image);
}
function getHeight() {
return imagesy($this->image);
}
function resizeToHeight($height) {
$ratio = $height / $this->getHeight();
$width = $this->getWidth() * $ratio;
$this->resize($width,$height);
}
function resizeToWidth($width) {
$ratio = $width / $this->getWidth();
$height = $this->getheight() * $ratio;
$this->resize($width,$height);
}
function scale($scale) {
$width = $this->getWidth() * $scale/100;
$height = $this->getheight() * $scale/100;
$this->resize($width,$height);
}
function resize($width,$height) {
$new_image = imagecreatetruecolor($width, $height);
imagealphablending($new_image, false);
imagesavealpha($new_image,true);
$transparent = imagecolorallocatealpha($new_image, 255, 255, 255, 127);
imagefilledrectangle($new_image, 0, 0, $width, $height, $transparent);
imagecopyresampled($new_image, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
$this->image = $new_image;
}
}
/**
* ...
*/
class sspmod_discojuice_Feed {
protected $config, $djconfig;
protected $excludes, $override, $insert, $idplist;
protected $metadata;
protected $feed;
protected $contrytags, $countryTLDs;
function __construct() {
$this->config = SimpleSAML_Configuration::getInstance();
$this->djconfig = SimpleSAML_Configuration::getOptionalConfig('discojuicefeed.php');
$metadatah = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
$saml2 = $metadatah->getList('saml20-idp-remote');
$shib = $metadatah->getList('shib13-idp-remote');
foreach($shib AS $s) {
$this->metadata[$s['entityid']] = $s;
}
foreach($saml2 AS $s) {
$this->metadata[$s['entityid']] = $s;
}
// $this->metadata = array_merge($this->metadata, $shib);
$this->idplist = $this->getIdPList();
SimpleSAML_Logger::info('IdP List contained : ' . count($this->idplist) . ' entries.');
$this->excludes = array_flip($this->djconfig->getValue('exclude'));
$this->insert = $this->djconfig->getValue('insert');
$this->overrides = $this->djconfig->getValue('overrides');
$this->countrytags = array(
'croatia' => 'HR',
'czech' => 'CZ',
'denmark' => 'DK',
'finland' => 'FI',
'france' => 'FR',
'germany' => 'DE',
'greece' => 'GR',
'ireland' => 'IE',
'italy' => 'IT',
'luxembourg' => 'LU',
'hungary' => 'HU',
'netherlands' => 'NL',
'norway' => 'NO',
'portugal' => 'PT',
'poland' => 'PL',
'slovenia' => 'SI',
'spain' => 'ES',
'sweden' => 'SE',
'switzerland' => 'CH',
'turkey' => 'TR',
'us' => 'US',
'uk' => 'GB',
'japan' => 'JP',
);
$this->countryTLDs = array(
'lp.' => 'PL',
'uh.' => 'HU',
'es.' => 'SE',
'ed.' => 'DE',
'if.' => 'FI',
'zc.' => 'CZ',
'rt.' => 'TR',
'kd.' => 'DK',
'on.' => 'NO',
'ude.' => 'US',
'ku.oc.' => 'GB',
);
}
public function store() {
$datadir = $this->config->getPathValue('datadir', 'data/');
if (!is_dir($datadir))
throw new Exception('Data directory [' . $datadir. '] does not exist');
if (!is_writable($datadir))
throw new Exception('Data directory [' . $datadir. '] is not writable');
$djdatadir = $datadir . 'discojuice/';
if (!is_dir($djdatadir)) {
mkdir($djdatadir);
}
$djdatafile = $djdatadir . 'discojuice.cache';
$data = $this->getJSON();
file_put_contents($djdatafile, json_encode($data));
}
public function read() {
$djdatafile = $this->config->getPathValue('datadir', 'data/') . 'discojuice/' . 'discojuice.cache';
if (!file_exists($djdatafile)) {
error_log('Did not find cached version, generating content again...');
return json_encode($this->getJSON());
}
return file_get_contents($djdatafile);
}
private function exclude($e) {
if ($this->excludes === NULL) return FALSE;
return (array_key_exists($e, $this->excludes));
}
protected function getIdPList() {
$api = $this->djconfig->getValue('idplistapi', NULL);
if (empty($api)) return array();
$result = array();
$apiresult = json_decode(file_get_contents($api), TRUE);
if ($apiresult['status'] === 'ok') {
foreach($apiresult['data'] AS $idp) {
$result[$idp] = 1;
}
}
return $result;
}
private function process() {
$this->feed = array();
$this->merge();
foreach($this->metadata AS $m) {
if ($this->exclude($m['entityid'])) continue;
$nc = $this->processEntity($m);
// if (empty($nc['icon'])) continue;
$this->feed[] = $nc;
}
if (!empty($this->insert)) {
foreach($this->insert AS $i) {
$this->feed[] = $i;
}
}
}
protected function merge() {
$mergeendpoints = $this->djconfig->getValue('mergeEndpoints', NULL);
SimpleSAML_Logger::info('Processing merge endpoint: ' . var_export($mergeendpoints, TRUE));
if ($mergeendpoints === NULL) return;
if (!is_array($mergeendpoints)) return;
foreach($mergeendpoints AS $me) {
SimpleSAML_Logger::info('Processing merge endpoint: ' . $me);
$newlist = json_decode(file_get_contents($me), TRUE);
$this->feed = array_merge($this->feed, $newlist);
}
}
private function processEntity($m) {
$data = array('entityID' => $m['entityid']);
$this->getCountry($data, $m);
$this->getTitle($data, $m);
$this->getOverrides($data, $m);
$this->getGeo($data, $m);
$this->getLogo($data, $m);
if (!empty($this->idplist)) {
$this->islisted($data, $m);
}
return $data;
}
public function getJSON() {
$this->process();
return $this->feed;
}
protected function islisted(&$data, $m) {
$weight = 0;
if (array_key_exists('weight', $data)) $weight = $data['weight'];
if (!array_key_exists($m['entityid'], $this->idplist)) {
#echo 'Match for ' . $m['entityid'];
$weight += 2;
}
$data['weight'] = $weight;
# echo '<pre>';
# print_r($this->idplist); exit;
}
protected static function getPreferredLogo($logos) {
$current = array('height' => 0);
$found = false;
foreach($logos AS $logo) {
if (
$logo['height'] > 23 &&
$logo['height'] < 41 &&
$logo['height'] > $current['height']
) {
$current = $logo;
$found = true;
}
}
if ($found) return $current;
foreach($logos AS $logo) {
if (
$logo['height'] > $current['height']
) {
$current = $logo;
$found = true;
}
}
if ($found) return $current;
return NULL;
}
protected static function getCachedLogo($logo) {
$hash = sha1($logo['url']);
$relfile = 'cached/' . $hash;
$file = dirname(dirname(__FILE__)) . '/www/discojuice/logos/' . $relfile;
$fileorig = $file . '.orig';
if (file_exists($file)) {
return $relfile;
}
//echo 'icon file: ' . $file; exit;
$orgimg = file_get_contents($logo['url']);
if (empty($orgimg)) return null;
file_put_contents($fileorig, $orgimg);
if ($logo['height'] > 40) {
$image = new SimpleImage();
$image->load($fileorig);
$image->resizeToHeight(38);
$image->save($file);
if (file_exists($file)) {
return $relfile;
}
}
file_put_contents($file, $orgimg);
if (file_exists($file)) {
return $relfile;
}
}
protected function getLogo(&$data, $m) {
if (!empty($m['mdui']) && !empty($m['mdui']['logos'])) {
$cl = self::getPreferredLogo($m['mdui']['logos']);
if (!empty($cl)) {
$cached = self::getCachedLogo($cl);
if (!empty($cached)) {
$data['icon'] = $cached;
}
}
// echo '<pre>'; print_r($m); exit;
}
}
protected function getGeo(&$data, $m) {
if (!empty($m['disco']) && !empty($m['disco']['geo'])) {
$data['geo'] = $m['disco']['geo'];
// $data['discogeo'] = 1;
}
// Do not lookup Geo locations from IP if geo location is already set.
if (array_key_exists('geo', $data)) return;
// Look for SingleSignOnService endpoint.
if (!empty($m['SingleSignOnService']) ) {
$m['metadata-set'] = 'saml20-idp-remote';
$mc = SimpleSAML_Configuration::loadFromArray($m);
$endpoint = $mc->getDefaultEndpoint('SingleSignOnService');
try {
$host = parse_url($endpoint['Location'], PHP_URL_HOST); if (empty($host)) return;
$ip = gethostbyname($host);
if (empty($ip)) return;
if ($ip === $host) return;
$capi = new sspmod_discojuice_Country($ip);
if (empty($data['geo'])) {
$geo = $capi->getGeo();
$geos = explode(',', $geo);
$data['geo'] = array('lat' => $geos[0], 'lon' => $geos[1]);
}
} catch(Exception $e) {
error_log('Error looking up geo coordinates: ' . $e->getMessage());
}
}
}
protected function getCountry(&$data, $m) {
if (!empty($m['tags'])) {
foreach($m['tags'] AS $tag) {
if (array_key_exists($tag, $this->countrytags)) {
$data['country'] = $this->countrytags[$tag];
return;
}
}
}
$c = self::countryFromURL($m['entityid']);
if (!empty($c)) { $data['country'] = $c; return; }
if (!empty($m['SingleSignOnService']) ) {
SimpleSAML_Logger::debug('SingleSignOnService found');
$m['metadata-set'] = 'saml20-idp-remote';
$mc = SimpleSAML_Configuration::loadFromArray($m);
$endpoint = $mc->getDefaultEndpoint('SingleSignOnService');
error_log('Endpoint: ' . var_export($endpoint, TRUE));
$c = $this->countryFromURL($endpoint['Location']);
if (!empty($c)) { $data['country'] = $c; return; }
try {
$host = parse_url($endpoint['Location'], PHP_URL_HOST);
$ip = gethostbyname($host);
$capi = new sspmod_discojuice_Country($ip);
$region = $capi->getRegion();
if (preg_match('|^([A-Z][A-Z])/|', $region, $match)) {
$data['country'] = $match[1];
}
} catch(Exception $e) {}
}
return null;
}
protected function getTitle(&$data, $m) {
if(isset($m['name']) && is_string($m['name'])) {
$data['title'] = $m['name'];
} else if(isset($m['name']) && array_key_exists('en', $m['name'])) {
$data['title'] = $m['name']['en'];
} else if(isset($m['name']) && is_array($m['name'])) {
$data['title'] = array_pop($m['name']);
} else if (isset($m['name']) && is_string($m['name'])) {
$data['title'] = $m['name'];
} else if (isset($m['OrganizationName']) && isset($m['OrganizationName']['en'])) {
$data['title'] = $m['OrganizationName']['en'];
} else if (isset($m['OrganizationName']) && is_array($m['OrganizationName'])) {
$data['title'] = array_pop($m['OrganizationName']);
} else {
$data['title'] = substr($m['entityid'], 0, 20);
$data['weight'] = 9;
}
}
protected function getOverrides(&$data, $m) {
if (empty($this->overrides)) return;
if (empty($this->overrides[$m['entityid']])) return;
$override = $this->overrides[$m['entityid']];
foreach($override AS $k => $v) {
$data[$k] = $v;
}
}
protected static function prefix($word, $prefix) {
if ( strlen($word) < strlen($prefix)) {
$tmp = $prefix;
$prefix = $word;
$word = $tmp;
}
$word = substr($word, 0, strlen($prefix));
if ($prefix == $word) {
return 1;
}
return 0;
}
protected function countryFromURL($entityid) {
try {
$pu = parse_url($entityid, PHP_URL_HOST);
if (!empty($pu)) {
$rh = strrev($pu);
// error_log('Looking up TLD : ' . $rh);
foreach($this->countryTLDs AS $domain => $country) {
if (self::prefix($domain, $rh)) {
error_log('Looking up TLD : ' . $rh . ' matched ' . $country);
return $country;
}
}
}
} catch(Exception $e) {
}
return null;
}
}
...@@ -7,18 +7,13 @@ header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT ...@@ -7,18 +7,13 @@ header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>Select Your Login Provider</title> <title>Select Your Login Provider</title>
<link rel="shortcut icon" href="http://discojuice.bridge.uninett.no/simplesaml/module.php/discojuice/favicon.png" />
<!-- JQuery hosted by Google -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<!-- DiscoJuice hosted by UNINETT at discojuice.org --> <!-- JQuery hosted by Google -->
<script type="text/javascript" src="https://engine.discojuice.org/discojuice-stable.min.js"></script> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="https://static.discojuice.org/css/discojuice.css" />
<!-- DiscoJuice hosted by UNINETT at discojuice.org -->
<script type="text/javascript" src="https://engine.discojuice.org/discojuice-stable.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://static.discojuice.org/css/discojuice.css" />
<style type="text/css"> <style type="text/css">
body { body {
...@@ -47,8 +42,8 @@ header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT ...@@ -47,8 +42,8 @@ header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT
json_encode($this->data['hostedConfig'][4]) . json_encode($this->data['hostedConfig'][4]) .
');'; ');';
echo " djc.country = false;\n"; // echo " djc.country = false;\n";
echo " djc.showLocationInfo = false;\n"; // echo " djc.showLocationInfo = false;\n";
if (!$this->data['enableCentralStorage']) { if (!$this->data['enableCentralStorage']) {
echo " delete djc.disco;\n"; echo " delete djc.disco;\n";
......
...@@ -4,15 +4,9 @@ if (empty($_REQUEST['entityID'])) throw new Exception('Missing parameter [entity ...@@ -4,15 +4,9 @@ if (empty($_REQUEST['entityID'])) throw new Exception('Missing parameter [entity
if (empty($_REQUEST['return'])) throw new Exception('Missing parameter [return]'); if (empty($_REQUEST['return'])) throw new Exception('Missing parameter [return]');
$djconfig = SimpleSAML_Configuration::getOptionalConfig('discojuice.php'); $djconfig = SimpleSAML_Configuration::getOptionalConfig('discojuice.php');
$config = SimpleSAML_Configuration::getInstance(); $config = SimpleSAML_Configuration::getInstance();
$feed = new sspmod_discojuice_Feed();
$metadata = json_decode($feed->read(), TRUE);
// EntityID // EntityID
$entityid = $_REQUEST['entityID']; $entityid = $_REQUEST['entityID'];
...@@ -34,7 +28,7 @@ $hostedConfig = array( ...@@ -34,7 +28,7 @@ $hostedConfig = array(
SimpleSAML_Module::getModuleURL('discojuice/response.html'), SimpleSAML_Module::getModuleURL('discojuice/response.html'),
// Set of feeds to subscribe to. // Set of feeds to subscribe to.
$djconfig->getArray('feeds', 'Service'), $djconfig->getArray('feeds', array('edugain')),
$href $href
); );
......
...@@ -31,18 +31,22 @@ function receive() { ...@@ -31,18 +31,22 @@ function receive() {
if (urlParams.cid) cid = urlParams.cid; if (urlParams.cid) cid = urlParams.cid;
var sender = parseURL(document.referrer); var sender = parseURL(document.referrer);
// Received a specific entity ID from the storage.
if (urlParams.entityID) { if (urlParams.entityID) {
window.parent.DiscoJuice.Utils.log('ResponseLocation: Response from discovery service [' + sender + ']: ' + urlParams.entityID + ' subID: ' + urlParams.subID); window.parent.DiscoJuice.Utils.log('ResponseLocation: Response from discovery service [' + sender + ']: ' + urlParams.entityID + ' subID: ' + urlParams.subID);
window.parent.DiscoJuice.Control.discoResponse(sender, urlParams.entityID, urlParams.subID, cid); window.parent.DiscoJuice.Control.discoResponse(sender, urlParams.entityID, urlParams.subID, cid);
// Received a textual error from the storage, to show in the debug log.
} else if (urlParams['error']) { } else if (urlParams['error']) {
window.parent.DiscoJuice.Control.discoResponseError(cid, window.parent.DiscoJuice.Control.discoResponseError(cid,
"Error from IdP Discovery Service [" + sender + "]: " + urlParams.error); "Error from IdP Discovery Service [" + sender + "]: " + urlParams.error);
// Did not receive a response parameter. This probably means that the Disco storage did not have a stored preference
// for the user. Consequently: no error.
} else { } else {
console.log('No valid response parameters. cid[' + cid + ']'); window.parent.DiscoJuice.Utils.log('No valid response parameters. cid[' + cid + ']');
window.parent.DiscoJuice.Control.discoResponseError(cid); window.parent.DiscoJuice.Control.discoResponseError(cid);
// "ResponseLocation: Response from discovery service [" + sender + "]: No valid response parameters");
} }
} }
...@@ -51,6 +55,6 @@ function receive() { ...@@ -51,6 +55,6 @@ function receive() {
</head> </head>
<body onload="receive();"> <body onload="receive();">
</body>
</html> </body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment