diff --git a/lib/API.php b/lib/API.php index 24c9f902d3d2584186737e0078f60efecc77b62d..6adbef436bb48ae145119a63e4baba530d43f83e 100644 --- a/lib/API.php +++ b/lib/API.php @@ -866,26 +866,41 @@ class API { private function action_show_entity_clashes() { $this->description([ - 'header' => "Show federations supplyilng this entity. Will only work for entities appearing in more then one federation. This method is meant for internal use.", - 'supportedFormats' => ['xml - this is set automatically and need not be specified'], + 'header' => "Show federations supplying this entity. Will only work for entities appearing in more then one federation. " + . "The 'fed' element points to the federation currently supplying the entity to eduGAIN. " + . "'other-fed' array is ordered by preference - i.e. how federations will be selected in case of the entity disapearing" + . " from the currently supplyng one.", + 'supportedFormats' => ['json', 'print_r'], 'arguments' => [ [ 'arg' => 'row_id', - 'required' => TRUE, + 'required' => FALSE, 'values' => 'valid internal identifier', 'description' => 'internal database identity identifier', ], + [ + 'arg' => 'e_id', + 'required' => FALSE, + 'values' => 'a valid entityId', + 'description' => 'a valid entityId (full string), either e_id or row_id is required, e_id takes precedence', + ], $this->addStdArgument('format'), + ], + 'examples' => [ + ['opt' => ['e_id' => 'https://shibboleth.cambridge.org/shibboleth-sp'], + 'format' => 'default', + 'title' => 'show supplying federations', + ], ] ]); if ($this->opts['help'] == 1) { return ""; } $e = new eduGAIN_entity(); - $out = $e->showEntityClashes($this->opts['row_id']); + $out = $e->showEntityClashes($this->opts['row_id'], $this->opts['e_id']); return $out; } - + private function action_show_entity() { $this->description([ 'header' => "Show the full entityID XML. This method is mostly for internal use.", @@ -965,8 +980,22 @@ class API { } if ($this->opts['opt'] !== 'internal' && $this->format === 'html') { $out = $e->printHeader(); + $out .= '<div><h1>Entity details</h1> + <button id="show_coco" class="greenbutton">Show CoCo info</button> + <button id="show_eccs" class="greenbutton">Show ECCS info</button> + <button id="show_met" class="greenbutton">Show MET info</button> + <button id="show_xml" class="greenbutton">Show XML</button> + </div><script> coco_id = 0;</script>'; } $out .= $entity_html; + $out .= '<script> if(coco_id != 0) + $("#show_coco").show(); + else + $("#show_coco").hide(); + if(eccs_status != 0) + $("#show_eccs").show(); + else + $("#show_eccs").hide();</script>'; return $out; } @@ -1059,11 +1088,20 @@ Click action names for a full description.</p>'; $e = new eduGAIN_entity(); $details = $e->showEntityName($this->opts['e_id'], $this->opts['lang'], $this->opts['type']); if ($this->opts['opt'] == 1) { - $out = $details; - } else { - $out = $details[0]; + return [$details[0], $details[1]]; } - return $out; + + if ($this->opts['opt'] == 2) { + $out = []; + $out['status'] = 0; + if (isset($details[0])) { + $out['status'] = 1; + $out['name'] = $details[0]; + $out['regauth'] = $details[2]; + } + return $out; + } + return $details[0]; } private function action_show_global_history() { diff --git a/lib/eduGAIN_core.php b/lib/eduGAIN_core.php index 1b32a7316188667dc295e9bc31489b52d05145bc..935d97247c034eeb4b4dcc60f807eac27b84cd5d 100644 --- a/lib/eduGAIN_core.php +++ b/lib/eduGAIN_core.php @@ -18,10 +18,13 @@ class eduGAIN_core{ * Dies if the connection cannot be set up. */ public function __construct() { + Utils::debug(5, "connect: ".DB_HOST.", ".USER.", ".DB_DATABASE.",".PASSWORD."\n"); $mysqli = new mysqli(DB_HOST, USER, PASSWORD, DB_DATABASE); - Utils::debug(5, "connect: ".DB_HOST.", ".USER.", ".DB_DATABASE."\n"); - if ($mysqli->connect_error) + if ($mysqli->connect_error) { + Utils::debug(2, "connect error\n"); die("Not connected"); + } + Utils::debug(5, "connect soccesful\n"); $mysqli->set_charset('utf8'); $mysqli->query("SET time_zone='+00:00'"); $this->mysqli = $mysqli; diff --git a/lib/eduGAIN_entity.php b/lib/eduGAIN_entity.php index ba09626cbc9c4057fcb92898bfebaf3d0724d8eb..649efc332bfbaa0cf36152bed42dab82926fa6df 100644 --- a/lib/eduGAIN_entity.php +++ b/lib/eduGAIN_entity.php @@ -106,7 +106,7 @@ class eduGAIN_entity extends eduGAIN { public function listEntityCategories() { $EC = []; $q = "SELECT friendly_name as value, value AS URI, short, name AS type, id FROM entityattributes_dict WHERE friendly_name IS NOT NULL ORDER BY value"; - $q = "SELECT friendly_name as value, value AS URI, short, name AS type, id FROM entityattributes_dict WHERE friendly_name IS NOT NULL"; + $q = "SELECT friendly_name as value, value AS URI, short, name AS type, id FROM entityattributes_dict WHERE friendly_name IS NOT NULL"; $result = $this->databaseQuery($q); while ($obj = $result->fetch_assoc()) { $uri = $obj['URI']; @@ -294,7 +294,7 @@ class eduGAIN_entity extends eduGAIN { if (!is_numeric($entity_row_id)) { exit; } - $q = "SELECT entities.entityid AS entityid,regauth, group_concat(entity_roles.id SEPARATOR ';') as roles, entity_history.first_seen AS first_seen FROM entities JOIN entity_roles on entities.id=entity_roles.entity_id JOIN entity_history on entity_history.entityid = entities.entityid WHERE entities.id = $entity_row_id GROUP BY entityid"; + $q = "SELECT entities.entityid AS entityid, regauth, group_concat(entity_roles.id SEPARATOR ';') as roles, entity_history.first_seen AS first_seen FROM entities JOIN entity_roles on entities.id=entity_roles.entity_id JOIN entity_history on entity_history.entityid = entities.entityid WHERE entities.id = $entity_row_id GROUP BY entityid"; $result = $this->databaseQuery($q); $obj = $result->fetch_assoc(); $ec = $this->getEntityCat($entity_row_id); @@ -333,7 +333,7 @@ class eduGAIN_entity extends eduGAIN { } $e_id = $this->cleanInput($e_id); $entity_row_id = $this->getEntityRowId($e_id); - $q = "SELECT entities.entityid AS entityid, group_concat(entity_roles.id SEPARATOR ';') as roles FROM entities JOIN entity_roles on entities.id=entity_roles.entity_id WHERE entities.id = $entity_row_id GROUP BY entityid"; + $q = "SELECT entities.entityid AS entityid, entities.regauth AS regauth, group_concat(entity_roles.id SEPARATOR ';') as roles FROM entities JOIN entity_roles on entities.id=entity_roles.entity_id WHERE entities.id = $entity_row_id GROUP BY entityid"; $result = $this->databaseQuery($q); if ($result->num_rows == 0) { return(0); @@ -350,6 +350,7 @@ class eduGAIN_entity extends eduGAIN { $N[$lg] = $V['name']; } } + $regauth = $obj['regauth']; $roles = explode(';', $obj['roles']); $R = []; foreach ($roles as $roleId) { @@ -399,13 +400,13 @@ class eduGAIN_entity extends eduGAIN { switch ($role) { case Constants::IDP: - return([$R['IDPSSODescriptor'], '']); + return([$R['IDPSSODescriptor'], '', $regauth]); case Constants::AA: - return([$R['AttributeAuthorityDescriptor'], '']); + return([$R['AttributeAuthorityDescriptor'], '', $regauth]); case Constants::SP: - return([$R['SPSSODescriptor'], $requestinitiator]); + return([$R['SPSSODescriptor'], $requestinitiator, $regauth]); default: - return([$R, $requestinitiator]); + return([$R, $requestinitiator, $regauth]); } } @@ -474,15 +475,24 @@ class eduGAIN_entity extends eduGAIN { return $entityArray; } - public function showEntityClashes($entity_id) { + public function showEntityClashes($entity_row_id, $e_id = 'NOTSET') { + if ($e_id !== 'NOTSET') { + $entity_row_id = $this->getEntityRowId($e_id); + if ($entity_row_id == 0) { + exit; + } + } + if (!is_numeric($entity_row_id)) { + exit; + } $out = []; $out['other_fed'] = []; - $q = "SELECT mds_data.code AS code FROM mds_data JOIN entities ON mds_data.reg_auth=entities.regauth WHERE entities.id = $entity_id"; + $q = "SELECT mds_data.code AS code FROM mds_data JOIN entities ON mds_data.reg_auth=entities.regauth WHERE entities.id = $entity_row_id"; $result = $this->databaseQuery($q); $obj = $result->fetch_assoc(); $fedId = $obj['code']; $out['fed'] = $this->federation_names[$fedId]; - $q = "SELECT code FROM entity_duplication WHERE entity_id=$entity_id ORDER by code"; + $q = "SELECT entity_duplication.code FROM entity_duplication join federation on entity_duplication.code = federation.code WHERE entity_id=$entity_row_id ORDER by production_date"; $result = $this->databaseQuery($q); while ($obj = $result->fetch_assoc()) { if ($obj['code'] == $fedId) @@ -743,6 +753,9 @@ class eduGAIN_entity extends eduGAIN { } private function getLangValue($data, $lang){ + if (!isset($data)) { + return(FALSE); + } if ([$lang, array_keys($data)]) { return($data[$lang]); } diff --git a/lib/eduGAIN_manage.php b/lib/eduGAIN_manage.php index b84e2af37637ed5fc8630d1f45c5c19c6271c88f..191f4ec7f21cc864e38995ba431e55dc997a7537 100644 --- a/lib/eduGAIN_manage.php +++ b/lib/eduGAIN_manage.php @@ -160,12 +160,13 @@ class eduGAIN_manage extends eduGAIN { $V = []; $FL = []; foreach ($fields as $f) { + $FL[] = $f; if (!isset($this->args[$f])) { - continue; + $val = "NULL"; + } else { + $v = $this->args[$f]; + $val = is_numeric($v) ? $v : "'$v'"; } - $FL[] = $f; - $v = $this->args[$f]; - $val = is_numeric($v) ? $v : "'$v'"; $V[] = $val; if (in_array($f, $this->changedFields)) { $U[] = "$f=$val"; diff --git a/page-logic/manage.php b/page-logic/manage.php index 16ab1e1e58e3fd9e4915e131f32a643a6aa8fd5a..610403fbdc07eaaa79f8bcc541db2172782a3e8f 100644 --- a/page-logic/manage.php +++ b/page-logic/manage.php @@ -235,7 +235,7 @@ $rows[] = $edugainGUI->row('Policy', 'POL', 'policy'); $rows[] = $edugainGUI->row('Policy in English', 'C', 'policy_english'); $rows[] = $edugainGUI->row('Metadata URL', 'I', 'metadata_url', '', 2,0,6); $rows[] = $edugainGUI->row('Registration Authority', 'I', 'reg_auth', '', 2,0,6); -$rows[] = $edugainGUI->row('Whitelist IdP', 'I', 'whitelist_idp', '', 2,0,6); +$rows[] = $edugainGUI->row('Whitelist IdP', 'I', 'whitelist_idp', '', 2,0,7); $rows[] = $edugainGUI->row('Signing certificate', 'CERT', 'certificate'); $data['federations'] = $federations; diff --git a/templates/manage.html b/templates/manage.html index 1ed79c2ca5fc0778a7db1856b77b79f4c6720f8d..3467c07fd09408879971541bc30f897ea72f5bf4 100644 --- a/templates/manage.html +++ b/templates/manage.html @@ -132,11 +132,17 @@ $("input[class*='nonempty_level_']").each(function(index) { x = Number($(this).attr("class").substring(15,16)); if (x <= status && ($(this).val() == '' || $(this).val() == '0000-00-00')) { - $(this).addClass("missing"); - missing_fields = 1; + if (($(this).attr('id') == 'policy_date') && $('#policy_version').val() == 0 && status < 3) { + $(this).removeClass("missing"); + } else { + $(this).addClass("missing"); + console.log($(this)); + missing_fields = 1; + } } else { $(this).removeClass("missing"); } + }); if(missing_fields == 1) { @@ -144,6 +150,7 @@ return(false); } $("#changed_fields").val(JSON.stringify(changedFields)); + console.log(changedFields); $("#main_form").submit(); } @@ -205,7 +212,17 @@ }); handlePolicyUploadDiv(); $("#fed_status").val(data.status); - if (data.status > 4 && admin != 1) { + /* + if (admin != 1) { + if (data.status > 4) { + $("#status").addClass('ot'); + $("#status").prop('disabled', true); + } + } + + */ + + if (data.status > 4 && admin != 1) { $("#status").addClass('ot'); $("#status").prop('disabled', true); } diff --git a/templates/status/status-members-details.html b/templates/status/status-members-details.html index 82c9bdce3f238308950169d686f269ebf6532435..208b8958fddbfcb7f35012075118372a9e578f40 100644 --- a/templates/status/status-members-details.html +++ b/templates/status/status-members-details.html @@ -7,10 +7,12 @@ </dd> {% endif %} <dt><h2>General</h2></dt><dd></dd> - {% if federation.field_properties.policy_version.data_missing == false %} + {% if federation.field_properties.policy_version.data_missing == false and federation.field_properties.policy_version.value != 0 %} {{ display.policy(federation.field_properties.policy_version, federation) }} {% endif %} + {% if c != 0 %} {{ display.string(federation.field_properties.policy_hardcopy) }} + {% endif %} {{ display.link(federation.field_properties.url) }} {{ display.email(federation.field_properties.contact_email) }} {{ display.sirtfi(federation.field_properties.security_contact) }} diff --git a/utils/compare_garr_psnc.sh b/utils/compare_garr_psnc.sh index cb666104d85ad9eb51a68a5c8ea7e417a1b22484..ef4dc590d47ed24cfd3cdc6adf54d99f66160a96 100755 --- a/utils/compare_garr_psnc.sh +++ b/utils/compare_garr_psnc.sh @@ -1,4 +1,6 @@ #!/bin/bash +dir=`dirname $0` +cd $dir if [ -z $1 ] then echo provide agriment 1 - to compare production and 0 to compare pre-preproduction @@ -7,7 +9,7 @@ fi date LEVEL=$1 GARR='http://test-ot-1.aai-test.garr.it/' -PSNC='https://technical.edugain.org/new/' +PSNC='https://technical.edugain.org/' URL=${GARR}'api.php?action=list_entity_sha1&opt='${LEVEL} wget -q -O f1.json $URL URL=${PSNC}'api.php?action=list_entity_sha1&opt='${LEVEL}