Rev 867 | Rev 870 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 867 | Rev 868 | ||
---|---|---|---|
Line 17... | Line 17... | ||
17 | * limitations under the License. |
17 | * limitations under the License. |
18 | */ |
18 | */ |
19 | 19 | ||
20 | require_once __DIR__ . '/../../../../../includes/oidplus.inc.php'; |
20 | require_once __DIR__ . '/../../../../../includes/oidplus.inc.php'; |
21 | 21 | ||
22 | define('XML_URN', 'urn:ietf:id:viathinksoft-oidip-02'); |
22 | define('XML_URN', 'urn:ietf:id:viathinksoft-oidip-03'); |
23 | define('XML_URN_URL', OIDplus::webpath(__DIR__,OIDplus::PATH_ABSOLUTE).'xml_schema.xsd'); |
23 | define('XML_URN_URL', OIDplus::webpath(__DIR__,OIDplus::PATH_ABSOLUTE).'xml_schema.xsd'); |
24 | define('JSON_SCHEMA', OIDplus::webpath(__DIR__,OIDplus::PATH_ABSOLUTE).'json_schema.json'); |
24 | define('JSON_SCHEMA', OIDplus::webpath(__DIR__,OIDplus::PATH_ABSOLUTE).'json_schema.json'); |
25 | 25 | ||
26 | OIDplus::init(true); |
26 | OIDplus::init(true); |
27 | set_exception_handler(array('OIDplusGui', 'html_exception_handler')); |
27 | set_exception_handler(array('OIDplusGui', 'html_exception_handler')); |
Line 436... | Line 436... | ||
436 | 436 | ||
437 | // we need this NAMED root, otherwise PHP will name the sections "0", "1", "2" if the array is not sequencial (e.g. because "signature" is added) |
437 | // we need this NAMED root, otherwise PHP will name the sections "0", "1", "2" if the array is not sequencial (e.g. because "signature" is added) |
438 | 'oidip' => $ary |
438 | 'oidip' => $ary |
439 | ); |
439 | ); |
440 | 440 | ||
- | 441 | $json = json_encode($ary); |
|
- | 442 | ||
441 | if (OIDplus::getPkiStatus()) { |
443 | if (OIDplus::getPkiStatus()) { |
442 | $cont = json_encode($ary); |
444 | require_once __DIR__.'/json/security.inc.php'; |
443 | $signature = ''; |
- | |
444 | if (@openssl_sign($cont, $signature, OIDplus::getSystemPrivateKey())) { |
445 | $json = oidplus_json_sign($json, OIDplus::getSystemPrivateKey(), OIDplus::getSystemPublicKey()); |
445 | $signature = base64_encode($signature); |
- | |
446 | $ary['signature'] = array('content' => $cont, 'signature' => $signature); |
- | |
447 | } |
- | |
448 | } |
446 | } |
449 | 447 | ||
450 | // Good JSON schema validator here: https://www.jsonschemavalidator.net |
448 | // Good JSON schema validator here: https://www.jsonschemavalidator.net |
451 | header('Content-Type:application/json; charset=UTF-8'); |
449 | header('Content-Type:application/json; charset=UTF-8'); |
452 | echo json_encode($ary); |
450 | echo $json; |
453 | } |
451 | } |
454 | 452 | ||
455 | if ($format == 'xml') { |
453 | if ($format == 'xml') { |
456 | $xml = '<oidip><section>'; |
454 | $xml = '<oidip><section>'; |
457 | foreach ($out as $line) { |
455 | foreach ($out as $line) { |
Line 467... | Line 465... | ||
467 | } |
465 | } |
468 | $xml .= '</section></oidip>'; |
466 | $xml .= '</section></oidip>'; |
469 | 467 | ||
470 | $xml = preg_replace('@<section><(.+)>(.+)</section>@ismU', '<\\1Section><\\1>\\2</\\1Section>', $xml); |
468 | $xml = preg_replace('@<section><(.+)>(.+)</section>@ismU', '<\\1Section><\\1>\\2</\\1Section>', $xml); |
471 | 469 | ||
- | 470 | // Good XSD validator here: https://www.liquid-technologies.com/online-xsd-validator |
|
- | 471 | $xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'. |
|
- | 472 | '<root xmlns="'.XML_URN.'"'. |
|
- | 473 | ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'. |
|
- | 474 | ' xsi:schemaLocation="'.XML_URN.' '.XML_URN_URL.'">'. |
|
- | 475 | $xml. |
|
- | 476 | '</root>'; |
|
- | 477 | ||
472 | if (OIDplus::getPkiStatus()) { |
478 | if (OIDplus::getPkiStatus()) { |
473 | $cont = $xml; |
- | |
474 | $signature = ''; |
- | |
475 | if (@openssl_sign($cont, $signature, OIDplus::getSystemPrivateKey())) { |
- | |
476 | $signature = base64_encode($signature); |
479 | require_once __DIR__.'/xml/security.inc.php'; |
477 | $cdata = '<![CDATA['.str_replace(']]>', ']]]]><![CDATA[>', $cont).']]>'; |
- | |
478 | $xml .= "<signatureSection><content>".$cdata."</content><signature>".htmlspecialchars($signature)."</signature></signatureSection>"; |
480 | $xml = oidplus_xml_sign($xml, OIDplus::getSystemPrivateKey(), OIDplus::getSystemPublicKey()); |
479 | } |
- | |
480 | } |
481 | } |
481 | 482 | ||
482 | // Good XSD validator here: https://www.liquid-technologies.com/online-xsd-validator |
- | |
483 | header('Content-Type:application/xml; charset=UTF-8'); |
483 | header('Content-Type:application/xml; charset=UTF-8'); |
484 | echo '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'; |
- | |
485 | echo '<root xmlns="'.XML_URN.'"'; |
- | |
486 | echo ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"'; |
- | |
487 | echo ' xsi:schemaLocation="'.XML_URN.' '.XML_URN_URL.'">'; |
- | |
488 | echo $xml; |
484 | echo $xml; |
489 | echo '</root>'; |
- | |
490 | } |
485 | } |
491 | 486 | ||
492 | # --- |
487 | # --- |
493 | 488 | ||
494 | function show_asn1_appendix($id) { |
489 | function show_asn1_appendix($id) { |