Skip to content
Snippets Groups Projects
Commit 282bef33 authored by Maja Górecka-Wolniewicz's avatar Maja Górecka-Wolniewicz
Browse files

handling errors in parameters when fed_id is given

parent 6f09d97c
Branches
Tags
No related merge requests found
...@@ -72,29 +72,35 @@ class Validator { ...@@ -72,29 +72,35 @@ class Validator {
$this->params['federror'] = "No metadata URL registered in the eduGAIN database for federation ".$this->edugain->FEDS[$fed_id]['fed_id'].' - '.$this->edugain->FEDS[$fed_id]['name']; $this->params['federror'] = "No metadata URL registered in the eduGAIN database for federation ".$this->edugain->FEDS[$fed_id]['fed_id'].' - '.$this->edugain->FEDS[$fed_id]['name'];
} else { } else {
$this->params['fedname'] = $this->edugain->FEDS[$fed_id]['name']; $this->params['fedname'] = $this->edugain->FEDS[$fed_id]['name'];
$this->params['regauth'] = $this->edugain->FEDS[$fed_id]['reg_auth']; if (isset($this->edugain->FEDS[$fed_id]['reg_auth'])) {
for ($n=0; $n<count($this->edugain->FEDS[$fed_id]['certificate']); $n++) { $this->params['regauth'] = $this->edugain->FEDS[$fed_id]['reg_auth'];
$certificate = $this->edugain->FEDS[$fed_id]['certificate'][$n]['data']; } else {
$certificate = trim($certificate, "\n"); $this->params['regauth'] = '';
$fnamesuffix = ''; }
if ($n > 0) { if (isset($this->edugain->FEDS[$fed_id]['certificate'])) {
$fnamesuffix = "_$n"; for ($n=0; $n<count($this->edugain->FEDS[$fed_id]['certificate']); $n++) {
$certificate = $this->edugain->FEDS[$fed_id]['certificate'][$n]['data'];
$certificate = trim($certificate, "\n");
$fnamesuffix = '';
if ($n > 0) {
$fnamesuffix = "_$n";
}
$certfilename = $this->params['filename'].$fnamesuffix."-fromdb.crt";
if (strlen($certificate)) {
$ff = fopen($certfilename, 'w');
fputs($ff, "-----BEGIN CERTIFICATE-----\n");
for ($i=0; ; $i=$i+64) {
if (substr($certificate, $i, 64) == '') break;
fputs($ff, substr($certificate, $i, 64)."\n");
}
fputs($ff, "-----END CERTIFICATE-----\n");
fclose($ff);
$this->edugain->FEDS[$fed_id]['certificate'][$n]['certfile'] = $certfilename;
}
} }
$certfilename = $this->params['filename'].$fnamesuffix."-fromdb.crt"; $ff = fopen($this->params['filename'].'-certinfo.json', 'w');
if (strlen($certificate)) { fputs($ff, json_encode($this->edugain->FEDS[$fed_id]['certificate']));
$ff = fopen($certfilename, 'w'); }
fputs($ff, "-----BEGIN CERTIFICATE-----\n");
for ($i=0; ; $i=$i+64) {
if (substr($certificate, $i, 64) == '') break;
fputs($ff, substr($certificate, $i, 64)."\n");
}
fputs($ff, "-----END CERTIFICATE-----\n");
fclose($ff);
$this->edugain->FEDS[$fed_id]['certificate'][$n]['certfile'] = $certfilename;
}
}
$ff = fopen($this->params['filename'].'-certinfo.json', 'w');
fputs($ff, json_encode($this->edugain->FEDS[$fed_id]['certificate']));
} }
} }
$this->params['auto'] = $this->params['validate'] = $this->params['edugain'] = 1; $this->params['auto'] = $this->params['validate'] = $this->params['edugain'] = 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment