@@ -2,12 +2,12 @@ |
||
2 | 2 | define('SOCKET', '/opt/Socket/CAT_requests/queue'); |
3 | 3 | |
4 | 4 | function cat_socket($obj) { |
5 | - $sock = socket_create(AF_UNIX, SOCK_STREAM, 0); |
|
6 | - $conn = socket_connect($sock, SOCKET); |
|
7 | - if ( $conn ) { |
|
8 | - socket_write ($sock, $obj, strlen($obj)); |
|
9 | - $out = socket_read ($sock, 2048); |
|
10 | - return $out; |
|
11 | - } |
|
12 | - return 'FAILURE'; |
|
5 | + $sock = socket_create(AF_UNIX, SOCK_STREAM, 0); |
|
6 | + $conn = socket_connect($sock, SOCKET); |
|
7 | + if ( $conn ) { |
|
8 | + socket_write ($sock, $obj, strlen($obj)); |
|
9 | + $out = socket_read ($sock, 2048); |
|
10 | + return $out; |
|
11 | + } |
|
12 | + return 'FAILURE'; |
|
13 | 13 | } |
@@ -6,9 +6,9 @@ |
||
6 | 6 | function cat_socket($obj) { |
7 | 7 | $sock = socket_create(AF_UNIX, SOCK_STREAM, 0); |
8 | 8 | $conn = socket_connect($sock, SOCKET); |
9 | - if ( $conn ) { |
|
10 | - socket_write ($sock, $obj, strlen($obj)); |
|
11 | - $out = socket_read ($sock, 2048); |
|
9 | + if ($conn) { |
|
10 | + socket_write($sock, $obj, strlen($obj)); |
|
11 | + $out = socket_read($sock, 2048); |
|
12 | 12 | return $out; |
13 | 13 | } |
14 | 14 | return 'FAILURE'; |
@@ -372,20 +372,20 @@ discard block |
||
372 | 372 | ); |
373 | 373 | // Generate a new private (and public) key pair |
374 | 374 | $privkey = openssl_pkey_new(array( |
375 | - "private_key_bits" => 4096, |
|
376 | - "private_key_type" => OPENSSL_KEYTYPE_RSA)); |
|
375 | + "private_key_bits" => 4096, |
|
376 | + "private_key_type" => OPENSSL_KEYTYPE_RSA)); |
|
377 | 377 | // export private key to $clientprivateKey (as string) |
378 | 378 | openssl_pkey_export($privkey, $this->radsec_priv); |
379 | 379 | // Generate a certificate signing request |
380 | 380 | $csr = openssl_csr_new($dn, $privkey, |
381 | - array('digest_alg' => 'sha256', 'config' => ROOT . "/config/ManagedSPCerts/openssl.cnf")); |
|
381 | + array('digest_alg' => 'sha256', 'config' => ROOT . "/config/ManagedSPCerts/openssl.cnf")); |
|
382 | 382 | // get CA certificate and private key |
383 | 383 | $caprivkey = array(file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.key"), |
384 | 384 | \config\Master::MANAGEDSP['capass']); |
385 | 385 | $cacert = file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.pem"); |
386 | 386 | $this->setTLSSerialNumber(); |
387 | 387 | $clientcert = openssl_csr_sign($csr, $cacert, $caprivkey, \config\Master::MANAGEDSP['daystoexpiry'], |
388 | - array('digest_alg'=>'sha512', 'config' => ROOT . "/config/ManagedSPCerts/openssl.cnf"), $this->radsec_cert_serial_no); |
|
388 | + array('digest_alg'=>'sha512', 'config' => ROOT . "/config/ManagedSPCerts/openssl.cnf"), $this->radsec_cert_serial_no); |
|
389 | 389 | openssl_x509_export($clientcert, $this->radsec_cert); |
390 | 390 | } |
391 | 391 | /** |
@@ -506,9 +506,9 @@ discard block |
||
506 | 506 | */ |
507 | 507 | public function renewtls() |
508 | 508 | { |
509 | - $id = $this->identifier; |
|
510 | - $futureTlsClient = $this->createTLScredentials(); |
|
511 | - $this->databaseHandle->exec("UPDATE deployment SET radsec_priv = ?, radsec_cert = ?, radsec_cert_serial_number = ? WHERE deployment_id = ?", "ssii", $this->radsec_priv, $this->radsec_cert, $this->radsec_cert_serial_no, $id); |
|
509 | + $id = $this->identifier; |
|
510 | + $futureTlsClient = $this->createTLScredentials(); |
|
511 | + $this->databaseHandle->exec("UPDATE deployment SET radsec_priv = ?, radsec_cert = ?, radsec_cert_serial_number = ? WHERE deployment_id = ?", "ssii", $this->radsec_priv, $this->radsec_cert, $this->radsec_cert_serial_no, $id); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | /** |
@@ -518,38 +518,38 @@ discard block |
||
518 | 518 | */ |
519 | 519 | public function tlsfromcsr($csr) |
520 | 520 | { |
521 | - $id = $this->identifier; |
|
522 | - $dn = array(); |
|
523 | - $dn['rdnSequence'] = array(); |
|
524 | - $dn['rdnSequence'][0] = array(); |
|
525 | - $dn['rdnSequence'][0][] = array('type' => 'id-at-organizationName', 'value' => array()); |
|
526 | - $dn['rdnSequence'][0][0]['value']['utf8String'] = 'eduroam'; |
|
527 | - $dn['rdnSequence'][1] = array(); |
|
528 | - $dn['rdnSequence'][1][] = array('type' => 'id-at-organizationalUnitName', 'value' => array()); |
|
529 | - $dn['rdnSequence'][1][0]['value']['utf8String'] = 'eduroam Managed SP'; |
|
530 | - $dn['rdnSequence'][2] = array(); |
|
531 | - $dn['rdnSequence'][2][] = array('type' => 'id-at-commonName', 'value' => array()); |
|
532 | - $dn['rdnSequence'][2][0]['value']['utf8String'] = 'SP' . $this->identifier . "-" . $this->institution; |
|
533 | - $csr->setDN($dn); |
|
534 | - $pemcakey = file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.key"); |
|
535 | - $cakey = \phpseclib3\Crypt\PublicKeyLoader::loadPrivateKey($pemcakey, \config\Master::MANAGEDSP['capass'] ); |
|
536 | - $pemca = file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.pem"); |
|
537 | - $ca = new \phpseclib3\File\X509(); |
|
538 | - $ca->loadX509($pemca); |
|
539 | - $ca->setPrivateKey($cakey); |
|
540 | - // Sign the updated request, producing the certificate. |
|
541 | - $x509 = new \phpseclib3\File\X509(); |
|
542 | - $csr->setExtension('id-ce-keyUsage', ['digitalSignature', 'nonRepudiation', 'keyEncipherment']); |
|
543 | - $csr->setExtension('id-ce-extKeyUsage', ['id-kp-clientAuth']); |
|
544 | - $csr->setExtension('id-ce-basicConstraints', ['cA' => false], false); |
|
545 | - $x509->setEndDate('+' . \config\Master::MANAGEDSP['daystoexpiry'] . ' days'); |
|
546 | - $this->setTLSSerialNumber(999999999999999999); |
|
547 | - $x509->setSerialNumber($this->radsec_cert_serial_no, 10); |
|
548 | - $cert = $x509->loadX509($x509->saveX509($x509->sign($ca, $csr))); |
|
549 | - $this->radsec_cert = $x509->saveX509($cert); |
|
550 | - $this->radsec_priv = NULL; |
|
551 | - //$futureTlsClient = $this->createTLScredentials(); |
|
552 | - $this->databaseHandle->exec("UPDATE deployment SET radsec_priv = NULL, radsec_cert = ?, radsec_cert_serial_number = ? WHERE deployment_id = ?", "sii", $this->radsec_cert, $this->radsec_cert_serial_no, $id); |
|
521 | + $id = $this->identifier; |
|
522 | + $dn = array(); |
|
523 | + $dn['rdnSequence'] = array(); |
|
524 | + $dn['rdnSequence'][0] = array(); |
|
525 | + $dn['rdnSequence'][0][] = array('type' => 'id-at-organizationName', 'value' => array()); |
|
526 | + $dn['rdnSequence'][0][0]['value']['utf8String'] = 'eduroam'; |
|
527 | + $dn['rdnSequence'][1] = array(); |
|
528 | + $dn['rdnSequence'][1][] = array('type' => 'id-at-organizationalUnitName', 'value' => array()); |
|
529 | + $dn['rdnSequence'][1][0]['value']['utf8String'] = 'eduroam Managed SP'; |
|
530 | + $dn['rdnSequence'][2] = array(); |
|
531 | + $dn['rdnSequence'][2][] = array('type' => 'id-at-commonName', 'value' => array()); |
|
532 | + $dn['rdnSequence'][2][0]['value']['utf8String'] = 'SP' . $this->identifier . "-" . $this->institution; |
|
533 | + $csr->setDN($dn); |
|
534 | + $pemcakey = file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.key"); |
|
535 | + $cakey = \phpseclib3\Crypt\PublicKeyLoader::loadPrivateKey($pemcakey, \config\Master::MANAGEDSP['capass'] ); |
|
536 | + $pemca = file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.pem"); |
|
537 | + $ca = new \phpseclib3\File\X509(); |
|
538 | + $ca->loadX509($pemca); |
|
539 | + $ca->setPrivateKey($cakey); |
|
540 | + // Sign the updated request, producing the certificate. |
|
541 | + $x509 = new \phpseclib3\File\X509(); |
|
542 | + $csr->setExtension('id-ce-keyUsage', ['digitalSignature', 'nonRepudiation', 'keyEncipherment']); |
|
543 | + $csr->setExtension('id-ce-extKeyUsage', ['id-kp-clientAuth']); |
|
544 | + $csr->setExtension('id-ce-basicConstraints', ['cA' => false], false); |
|
545 | + $x509->setEndDate('+' . \config\Master::MANAGEDSP['daystoexpiry'] . ' days'); |
|
546 | + $this->setTLSSerialNumber(999999999999999999); |
|
547 | + $x509->setSerialNumber($this->radsec_cert_serial_no, 10); |
|
548 | + $cert = $x509->loadX509($x509->saveX509($x509->sign($ca, $csr))); |
|
549 | + $this->radsec_cert = $x509->saveX509($cert); |
|
550 | + $this->radsec_priv = NULL; |
|
551 | + //$futureTlsClient = $this->createTLScredentials(); |
|
552 | + $this->databaseHandle->exec("UPDATE deployment SET radsec_priv = NULL, radsec_cert = ?, radsec_cert_serial_number = ? WHERE deployment_id = ?", "sii", $this->radsec_cert, $this->radsec_cert_serial_no, $id); |
|
553 | 553 | } |
554 | 554 | /** |
555 | 555 | * marks the deployment as deactivated |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | $serverCandidates[IdPlist::geoDistance($adminLocation, ['lat' => $iterator->location_lat, 'lon' => $iterator->location_lon])] = $iterator->server_id; |
323 | 323 | } |
324 | 324 | if ($clients > $maxSupportedClients * 0.9) { |
325 | - $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (" . $iterator->server_id . ") is serving at more than 90% capacity!"); |
|
325 | + $this->loggerInstance->debug(1, "A RADIUS server for Managed SP (".$iterator->server_id.") is serving at more than 90% capacity!"); |
|
326 | 326 | } |
327 | 327 | } |
328 | 328 | if (count($serverCandidates) == 0 && $federation != "DEFAULT") { |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * |
345 | 345 | * @throws Exception |
346 | 346 | */ |
347 | - private function setTLSSerialNumber($max=PHP_INT_MAX) { |
|
347 | + private function setTLSSerialNumber($max = PHP_INT_MAX) { |
|
348 | 348 | $nonDupSerialFound = FALSE; |
349 | 349 | do { |
350 | 350 | $serial = random_int(1000000000, $max); |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | */ |
365 | 365 | private function createTLScredentials() |
366 | 366 | { |
367 | - $clientName = 'SP' . $this->identifier . '-' . $this->institution; |
|
367 | + $clientName = 'SP'.$this->identifier.'-'.$this->institution; |
|
368 | 368 | $dn = array( |
369 | 369 | "organizationName" => "eduroam", |
370 | 370 | "organizationalUnitName" => "eduroam Managed SP", |
@@ -378,14 +378,14 @@ discard block |
||
378 | 378 | openssl_pkey_export($privkey, $this->radsec_priv); |
379 | 379 | // Generate a certificate signing request |
380 | 380 | $csr = openssl_csr_new($dn, $privkey, |
381 | - array('digest_alg' => 'sha256', 'config' => ROOT . "/config/ManagedSPCerts/openssl.cnf")); |
|
381 | + array('digest_alg' => 'sha256', 'config' => ROOT."/config/ManagedSPCerts/openssl.cnf")); |
|
382 | 382 | // get CA certificate and private key |
383 | - $caprivkey = array(file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.key"), |
|
383 | + $caprivkey = array(file_get_contents(ROOT."/config/ManagedSPCerts/eduroamSP-CA.key"), |
|
384 | 384 | \config\Master::MANAGEDSP['capass']); |
385 | - $cacert = file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.pem"); |
|
385 | + $cacert = file_get_contents(ROOT."/config/ManagedSPCerts/eduroamSP-CA.pem"); |
|
386 | 386 | $this->setTLSSerialNumber(); |
387 | 387 | $clientcert = openssl_csr_sign($csr, $cacert, $caprivkey, \config\Master::MANAGEDSP['daystoexpiry'], |
388 | - array('digest_alg'=>'sha512', 'config' => ROOT . "/config/ManagedSPCerts/openssl.cnf"), $this->radsec_cert_serial_no); |
|
388 | + array('digest_alg'=>'sha512', 'config' => ROOT."/config/ManagedSPCerts/openssl.cnf"), $this->radsec_cert_serial_no); |
|
389 | 389 | openssl_x509_export($clientcert, $this->radsec_cert); |
390 | 390 | } |
391 | 391 | /** |
@@ -410,8 +410,8 @@ discard block |
||
410 | 410 | $conditional1 = "AND activity_time > DATE_SUB(NOW(), INTERVAL $backlog SECOND )"; |
411 | 411 | $conditional2 = "DESC"; |
412 | 412 | } |
413 | - $client = 'SP' . $this->identifier . '-' . $this->institution; |
|
414 | - $stats = $this->databaseHandle->exec("SELECT activity_time, realm, mac, cui, result, ap_id, prot, outer_user FROM activity WHERE owner = ? $conditional1 ORDER BY activity_time $conditional2", "s", $client ); |
|
413 | + $client = 'SP'.$this->identifier.'-'.$this->institution; |
|
414 | + $stats = $this->databaseHandle->exec("SELECT activity_time, realm, mac, cui, result, ap_id, prot, outer_user FROM activity WHERE owner = ? $conditional1 ORDER BY activity_time $conditional2", "s", $client); |
|
415 | 415 | |
416 | 416 | return mysqli_fetch_all($stats, \MYSQLI_ASSOC); |
417 | 417 | } |
@@ -529,11 +529,11 @@ discard block |
||
529 | 529 | $dn['rdnSequence'][1][0]['value']['utf8String'] = 'eduroam Managed SP'; |
530 | 530 | $dn['rdnSequence'][2] = array(); |
531 | 531 | $dn['rdnSequence'][2][] = array('type' => 'id-at-commonName', 'value' => array()); |
532 | - $dn['rdnSequence'][2][0]['value']['utf8String'] = 'SP' . $this->identifier . "-" . $this->institution; |
|
532 | + $dn['rdnSequence'][2][0]['value']['utf8String'] = 'SP'.$this->identifier."-".$this->institution; |
|
533 | 533 | $csr->setDN($dn); |
534 | - $pemcakey = file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.key"); |
|
535 | - $cakey = \phpseclib3\Crypt\PublicKeyLoader::loadPrivateKey($pemcakey, \config\Master::MANAGEDSP['capass'] ); |
|
536 | - $pemca = file_get_contents(ROOT . "/config/ManagedSPCerts/eduroamSP-CA.pem"); |
|
534 | + $pemcakey = file_get_contents(ROOT."/config/ManagedSPCerts/eduroamSP-CA.key"); |
|
535 | + $cakey = \phpseclib3\Crypt\PublicKeyLoader::loadPrivateKey($pemcakey, \config\Master::MANAGEDSP['capass']); |
|
536 | + $pemca = file_get_contents(ROOT."/config/ManagedSPCerts/eduroamSP-CA.pem"); |
|
537 | 537 | $ca = new \phpseclib3\File\X509(); |
538 | 538 | $ca->loadX509($pemca); |
539 | 539 | $ca->setPrivateKey($cakey); |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | $csr->setExtension('id-ce-keyUsage', ['digitalSignature', 'nonRepudiation', 'keyEncipherment']); |
543 | 543 | $csr->setExtension('id-ce-extKeyUsage', ['id-kp-clientAuth']); |
544 | 544 | $csr->setExtension('id-ce-basicConstraints', ['cA' => false], false); |
545 | - $x509->setEndDate('+' . \config\Master::MANAGEDSP['daystoexpiry'] . ' days'); |
|
545 | + $x509->setEndDate('+'.\config\Master::MANAGEDSP['daystoexpiry'].' days'); |
|
546 | 546 | $this->setTLSSerialNumber(999999999999999999); |
547 | 547 | $x509->setSerialNumber($this->radsec_cert_serial_no, 10); |
548 | 548 | $cert = $x509->loadX509($x509->saveX509($x509->sign($ca, $csr))); |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | { |
585 | 585 | $customAttrib = $this->getAttributes("managedsp:operatorname"); |
586 | 586 | if (count($customAttrib) == 0) { |
587 | - return "1sp." . $this->identifier . "-" . $this->institution . \config\ConfAssistant::SILVERBULLET['realm_suffix']; |
|
587 | + return "1sp.".$this->identifier."-".$this->institution.\config\ConfAssistant::SILVERBULLET['realm_suffix']; |
|
588 | 588 | } |
589 | 589 | return $customAttrib[0]["value"]; |
590 | 590 | } |
@@ -599,14 +599,14 @@ discard block |
||
599 | 599 | private function sendToRADIUS(int $idx, $post) |
600 | 600 | { |
601 | 601 | $hostname = "radius_hostname_$idx"; |
602 | - $ch = curl_init("http://" . $this->$hostname . ':' . \config\Master::MANAGEDSP['radiusconfigport']); |
|
602 | + $ch = curl_init("http://".$this->$hostname.':'.\config\Master::MANAGEDSP['radiusconfigport']); |
|
603 | 603 | if ($ch === FALSE) { |
604 | 604 | $res = 'FAILURE'; |
605 | 605 | } else { |
606 | 606 | curl_setopt($ch, CURLOPT_USERAGENT, "CAT-ManagedSP"); |
607 | 607 | curl_setopt($ch, CURLOPT_POST, 1); |
608 | 608 | curl_setopt($ch, CURLOPT_POSTFIELDS, $post); |
609 | - $this->loggerInstance->debug(1, "Posting to http://" . $this->$hostname . ':' . \config\Master::MANAGEDSP['radiusconfigport'] . "/$post\n"); |
|
609 | + $this->loggerInstance->debug(1, "Posting to http://".$this->$hostname.':'.\config\Master::MANAGEDSP['radiusconfigport']."/$post\n"); |
|
610 | 610 | curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); |
611 | 611 | curl_setopt($ch, CURLOPT_HEADER, 0); |
612 | 612 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
@@ -645,19 +645,19 @@ discard block |
||
645 | 645 | } else { |
646 | 646 | $txt = $remove ? _('Profile deactivation failed') : _('Profile activation/modification failed'); |
647 | 647 | } |
648 | - $txt = $txt . ' '; |
|
648 | + $txt = $txt.' '; |
|
649 | 649 | if (array_count_values($response)[$status] == 2) { |
650 | - $txt = $txt . _('on both RADIUS servers: primary and backup') . '.'; |
|
650 | + $txt = $txt._('on both RADIUS servers: primary and backup').'.'; |
|
651 | 651 | } else { |
652 | 652 | if ($response['res[1]'] == $status) { |
653 | - $txt = $txt . _('on primary RADIUS server') . '.'; |
|
653 | + $txt = $txt._('on primary RADIUS server').'.'; |
|
654 | 654 | } else { |
655 | - $txt = $txt . _('on backup RADIUS server') . '.'; |
|
655 | + $txt = $txt._('on backup RADIUS server').'.'; |
|
656 | 656 | } |
657 | 657 | } |
658 | 658 | $mail = \core\common\OutsideComm::mailHandle(); |
659 | 659 | $email = $this->getAttributes("support:email")[0]['value']; |
660 | - $mail->FromName = \config\Master::APPEARANCE['productname'] . " Notification System"; |
|
660 | + $mail->FromName = \config\Master::APPEARANCE['productname']." Notification System"; |
|
661 | 661 | $mail->addAddress($email); |
662 | 662 | if ($status == 'OK') { |
663 | 663 | $mail->Subject = _('RADIUS profile update problem fixed'); |
@@ -691,7 +691,7 @@ discard block |
||
691 | 691 | return NULL; |
692 | 692 | } |
693 | 693 | $timeout = 10; |
694 | - curl_setopt($ch, CURLOPT_URL, 'http://' . $host); |
|
694 | + curl_setopt($ch, CURLOPT_URL, 'http://'.$host); |
|
695 | 695 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
696 | 696 | curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); |
697 | 697 | curl_exec($ch); |
@@ -783,52 +783,52 @@ discard block |
||
783 | 783 | { |
784 | 784 | $toPost = ($onlyone ? array($onlyone => '') : array(1 => '', 2 => '')); |
785 | 785 | if ($torevoke != '') { |
786 | - $toPostTemplate = 'instid=' . $this->institution . '&deploymentid=' . $this->identifier . |
|
786 | + $toPostTemplate = 'instid='.$this->institution.'&deploymentid='.$this->identifier. |
|
787 | 787 | "&torevoke=$torevoke"; |
788 | 788 | foreach (array_keys($toPost) as $key) { |
789 | 789 | $toPost[$key] = $toPostTemplate; |
790 | 790 | } |
791 | 791 | } else { |
792 | 792 | $remove = ($this->status == \core\AbstractDeployment::INACTIVE) ? 0 : 1; |
793 | - $toPostTemplate = 'instid=' . $this->institution . '&deploymentid=' . $this->identifier . |
|
794 | - '&secret=' . $this->secret . |
|
795 | - '&country=' . $this->getAttributes("internal:country")[0]['value'] . |
|
796 | - '&pskkey=' . $this->pskkey . '&'; |
|
793 | + $toPostTemplate = 'instid='.$this->institution.'&deploymentid='.$this->identifier. |
|
794 | + '&secret='.$this->secret. |
|
795 | + '&country='.$this->getAttributes("internal:country")[0]['value']. |
|
796 | + '&pskkey='.$this->pskkey.'&'; |
|
797 | 797 | if ($remove) { |
798 | - $toPostTemplate = $toPostTemplate . 'remove=1&'; |
|
798 | + $toPostTemplate = $toPostTemplate.'remove=1&'; |
|
799 | 799 | } else { |
800 | - $toPostTemplate = $toPostTemplate . 'operatorname=' . $this->getOperatorName() . '&'; |
|
800 | + $toPostTemplate = $toPostTemplate.'operatorname='.$this->getOperatorName().'&'; |
|
801 | 801 | if ($this->getAttributes("managedsp:vlan")[0]['value'] ?? NULL) { |
802 | 802 | $allRealms = $this->getAllRealms(); |
803 | 803 | if (!empty($allRealms)) { |
804 | - $toPostTemplate = $toPostTemplate . 'vlan=' . $this->getAttributes("managedsp:vlan")[0]['value'] . '&'; |
|
805 | - $toPostTemplate = $toPostTemplate . 'realmforvlan[]=' . implode('&realmforvlan[]=', $allRealms) . '&'; |
|
804 | + $toPostTemplate = $toPostTemplate.'vlan='.$this->getAttributes("managedsp:vlan")[0]['value'].'&'; |
|
805 | + $toPostTemplate = $toPostTemplate.'realmforvlan[]='.implode('&realmforvlan[]=', $allRealms).'&'; |
|
806 | 806 | } |
807 | 807 | } |
808 | 808 | if ($this->getAttributes("managedsp:guest_vlan")[0]['value'] ?? NULL) { |
809 | - $toPostTemplate = $toPostTemplate . 'guest_vlan=' . $this->getAttributes("managedsp:guest_vlan")[0]['value'] . '&'; |
|
809 | + $toPostTemplate = $toPostTemplate.'guest_vlan='.$this->getAttributes("managedsp:guest_vlan")[0]['value'].'&'; |
|
810 | 810 | } |
811 | 811 | } |
812 | 812 | foreach (array_keys($toPost) as $key) { |
813 | - $elem = 'port' . $key; |
|
814 | - $toPost[$key] = $toPostTemplate . 'port=' . $this->$elem; |
|
813 | + $elem = 'port'.$key; |
|
814 | + $toPost[$key] = $toPostTemplate.'port='.$this->$elem; |
|
815 | 815 | } |
816 | 816 | } |
817 | 817 | $response = array(); |
818 | 818 | foreach ($toPost as $key => $value) { |
819 | - $this->loggerInstance->debug(1, 'toPost ' . $toPost[$key] . "\n"); |
|
819 | + $this->loggerInstance->debug(1, 'toPost '.$toPost[$key]."\n"); |
|
820 | 820 | // temporarly one server $response['res[' . $key . ']'] = $this->sendToRADIUS($key, $toPost[$key]); |
821 | 821 | //if ($key == 2) { |
822 | 822 | // $response['res[2]'] = 'OK'; |
823 | 823 | //} else { |
824 | - $response['res[' . $key . ']'] = $this->sendToRADIUS($key, $toPost[$key]); |
|
824 | + $response['res['.$key.']'] = $this->sendToRADIUS($key, $toPost[$key]); |
|
825 | 825 | //} |
826 | 826 | } |
827 | 827 | if ($onlyone) { |
828 | - $response['res[' . ($onlyone == 1) ? 2 : 1 . ']'] = \core\AbstractDeployment::RADIUS_OK; |
|
828 | + $response['res['.($onlyone == 1) ? 2 : 1.']'] = \core\AbstractDeployment::RADIUS_OK; |
|
829 | 829 | } |
830 | 830 | foreach (array('OK', 'FAILURE') as $status) { |
831 | - if ( ( ($status == 'OK' && $notify) || ($status == 'FAILURE') ) && ( in_array($status, $response) ) ) { |
|
831 | + if ((($status == 'OK' && $notify) || ($status == 'FAILURE')) && (in_array($status, $response))) { |
|
832 | 832 | $this->sendMailtoAdmin($remove, $response, $status); |
833 | 833 | } |
834 | 834 | } |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | public function __construct() |
36 | 36 | { |
37 | 37 | |
38 | - if ( \config\ConfAssistant::eduPKI['testing'] === true ) { |
|
39 | - $this->locationRaCert = ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.pem"; |
|
40 | - $this->locationRaKey = ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.clearkey"; |
|
41 | - $this->locationWebRoot = ROOT . "/config/SilverbulletClientCerts/eduPKI-webserver-root.pem"; |
|
38 | + if (\config\ConfAssistant::eduPKI['testing'] === true) { |
|
39 | + $this->locationRaCert = ROOT."/config/SilverbulletClientCerts/edupki-test-ra.pem"; |
|
40 | + $this->locationRaKey = ROOT."/config/SilverbulletClientCerts/edupki-test-ra.clearkey"; |
|
41 | + $this->locationWebRoot = ROOT."/config/SilverbulletClientCerts/eduPKI-webserver-root.pem"; |
|
42 | 42 | $this->eduPkiRaId = 700; |
43 | 43 | $this->eduPkiCertProfileBoth = "Radius Server SOAP"; |
44 | 44 | $this->eduPkiCertProfileIdp = "Radius Server SOAP"; |
@@ -47,9 +47,9 @@ discard block |
||
47 | 47 | $this->eduPkiEndpointPublic = "https://pki.edupki.org/edupki-test-ca/cgi-bin/pub/soap?wsdl=1"; |
48 | 48 | $this->eduPkiEndpointRa = "https://ra.edupki.org/edupki-test-ca/cgi-bin/ra/soap?wsdl=1"; |
49 | 49 | } else { |
50 | - $this->locationRaCert = ROOT . "/config/SilverbulletClientCerts/edupki-prod-ra.pem"; |
|
51 | - $this->locationRaKey = ROOT . "/config/SilverbulletClientCerts/edupki-prod-ra.clearkey"; |
|
52 | - $this->locationWebRoot = ROOT . "/config/SilverbulletClientCerts/eduPKI-webserver-root.pem"; |
|
50 | + $this->locationRaCert = ROOT."/config/SilverbulletClientCerts/edupki-prod-ra.pem"; |
|
51 | + $this->locationRaKey = ROOT."/config/SilverbulletClientCerts/edupki-prod-ra.clearkey"; |
|
52 | + $this->locationWebRoot = ROOT."/config/SilverbulletClientCerts/eduPKI-webserver-root.pem"; |
|
53 | 53 | $this->eduPkiRaId = 100; |
54 | 54 | $this->eduPkiCertProfileBoth = "eduroam IdP and SP"; |
55 | 55 | $this->eduPkiCertProfileIdp = "eduroam IdP"; |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | parent::__construct(); |
64 | 64 | |
65 | 65 | if (stat($this->locationRaCert) === FALSE) { |
66 | - throw new Exception("RA operator PEM file not found: " . $this->locationRaCert); |
|
66 | + throw new Exception("RA operator PEM file not found: ".$this->locationRaCert); |
|
67 | 67 | } |
68 | 68 | if (stat($this->locationRaKey) === FALSE) { |
69 | - throw new Exception("RA operator private key file not found: " . $this->locationRaKey); |
|
69 | + throw new Exception("RA operator private key file not found: ".$this->locationRaKey); |
|
70 | 70 | } |
71 | 71 | if (stat($this->locationWebRoot) === FALSE) { |
72 | - throw new Exception("CA website root CA file not found: " . $this->locationWebRoot); |
|
72 | + throw new Exception("CA website root CA file not found: ".$this->locationWebRoot); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -136,26 +136,26 @@ discard block |
||
136 | 136 | throw new Exception("Unexpected policies requested."); |
137 | 137 | } |
138 | 138 | $altArray = [# Array mit den Subject Alternative Names |
139 | - "email:" . $csr["USERMAIL"] |
|
139 | + "email:".$csr["USERMAIL"] |
|
140 | 140 | ]; |
141 | 141 | foreach ($csr["ALTNAMES"] as $oneAltName) { |
142 | 142 | if (!empty($oneAltName) && preg_match('/(?=^.{1,254}$)(^(?:(?!\d|-)[a-z0-9\-]{1,63}(?<!-)\.)+(?:[a-z]{2,})$)/i', $oneAltName) > 0) { |
143 | - $altArray[] = "DNS:" . $oneAltName; |
|
143 | + $altArray[] = "DNS:".$oneAltName; |
|
144 | 144 | } else { |
145 | - $altArray[] = "IP:" . $oneAltName; |
|
145 | + $altArray[] = "IP:".$oneAltName; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | $soapPub = $this->initEduPKISoapSession("PUBLIC"); |
149 | 149 | $this->loggerInstance->debug(5, "FIRST ACTUAL SOAP REQUEST (Public, newRequest)!\n"); |
150 | - $this->loggerInstance->debug(5, "PARAM_1: " . $this->eduPkiRaId . "\n"); |
|
151 | - $this->loggerInstance->debug(5, "PARAM_2: " . $csr["CSR_STRING"] . "\n"); |
|
150 | + $this->loggerInstance->debug(5, "PARAM_1: ".$this->eduPkiRaId."\n"); |
|
151 | + $this->loggerInstance->debug(5, "PARAM_2: ".$csr["CSR_STRING"]."\n"); |
|
152 | 152 | $this->loggerInstance->debug(5, "PARAM_3: "); |
153 | 153 | $this->loggerInstance->debug(5, $altArray); |
154 | - $this->loggerInstance->debug(5, "PARAM_4: " . $profile . "\n"); |
|
155 | - $this->loggerInstance->debug(5, "PARAM_5: " . sha1("notused") . "\n"); |
|
156 | - $this->loggerInstance->debug(5, "PARAM_6: " . $csr["USERNAME"] . "\n"); |
|
157 | - $this->loggerInstance->debug(5, "PARAM_7: " . $csr["USERMAIL"] . "\n"); |
|
158 | - $this->loggerInstance->debug(5, "PARAM_8: " . ProfileSilverbullet::PRODUCTNAME . "\n"); |
|
154 | + $this->loggerInstance->debug(5, "PARAM_4: ".$profile."\n"); |
|
155 | + $this->loggerInstance->debug(5, "PARAM_5: ".sha1("notused")."\n"); |
|
156 | + $this->loggerInstance->debug(5, "PARAM_6: ".$csr["USERNAME"]."\n"); |
|
157 | + $this->loggerInstance->debug(5, "PARAM_7: ".$csr["USERMAIL"]."\n"); |
|
158 | + $this->loggerInstance->debug(5, "PARAM_8: ".ProfileSilverbullet::PRODUCTNAME."\n"); |
|
159 | 159 | $this->loggerInstance->debug(5, "PARAM_9: false\n"); |
160 | 160 | |
161 | 161 | $soapNewRequest = $soapPub->newRequest( |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | #}\n"); |
186 | 186 | return 0; |
187 | 187 | } |
188 | - throw new Exception("Something odd happened while doing the SOAP request:" . $e->getMessage()); |
|
188 | + throw new Exception("Something odd happened while doing the SOAP request:".$e->getMessage()); |
|
189 | 189 | } |
190 | 190 | try { |
191 | 191 | $soap = $this->initEduPKISoapSession("RA"); |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | // for obnoxious reasons, we have to dump the request into a file and let pkcs7_sign read from the file |
218 | 218 | // rather than just using the string. Grr. |
219 | 219 | $tempdir = \core\common\Entity::createTemporaryDirectory("test"); |
220 | - file_put_contents($tempdir['dir'] . "/content.txt", $soapCleartext); |
|
220 | + file_put_contents($tempdir['dir']."/content.txt", $soapCleartext); |
|
221 | 221 | // retrieve our RA cert from filesystem |
222 | 222 | // the RA certificates are not needed right now because we |
223 | 223 | // have resorted to S/MIME signatures with openssl command-line |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | // sign the data, using cmdline because openssl_pkcs7_sign produces strange results |
230 | 230 | // -binary didn't help, nor switch -md to sha1 sha256 or sha512 |
231 | 231 | $this->loggerInstance->debug(2, "Actual content to be signed is this:\n $soapCleartext\n"); |
232 | - $execCmd = \config\Master::PATHS['openssl'] . " smime -sign -binary -in " . $tempdir['dir'] . "/content.txt -out " . $tempdir['dir'] . "/signature.txt -outform pem -inkey " . $this->locationRaKey . " -signer " . $this->locationRaCert; |
|
232 | + $execCmd = \config\Master::PATHS['openssl']." smime -sign -binary -in ".$tempdir['dir']."/content.txt -out ".$tempdir['dir']."/signature.txt -outform pem -inkey ".$this->locationRaKey." -signer ".$this->locationRaCert; |
|
233 | 233 | $this->loggerInstance->debug(2, "Calling openssl smime with following cmdline: $execCmd\n"); |
234 | 234 | $output = []; |
235 | 235 | $return = 999; |
@@ -238,21 +238,21 @@ discard block |
||
238 | 238 | throw new Exception("Non-zero return value from openssl smime!"); |
239 | 239 | } |
240 | 240 | // and get the signature blob back from the filesystem |
241 | - $detachedSig = trim(file_get_contents($tempdir['dir'] . "/signature.txt")); |
|
241 | + $detachedSig = trim(file_get_contents($tempdir['dir']."/signature.txt")); |
|
242 | 242 | $this->loggerInstance->debug(5, "Request for server approveRequest has parameters:\n"); |
243 | - $this->loggerInstance->debug(5, $soapReqnum . "\n"); |
|
244 | - $this->loggerInstance->debug(5, $soapCleartext . "\n"); // PHP magically encodes this as base64 while sending! |
|
245 | - $this->loggerInstance->debug(5, $detachedSig . "\n"); |
|
243 | + $this->loggerInstance->debug(5, $soapReqnum."\n"); |
|
244 | + $this->loggerInstance->debug(5, $soapCleartext."\n"); // PHP magically encodes this as base64 while sending! |
|
245 | + $this->loggerInstance->debug(5, $detachedSig."\n"); |
|
246 | 246 | $soapIssueCert = $soap->approveRequest($soapReqnum, $soapCleartext, $detachedSig); |
247 | - $this->loggerInstance->debug(5, "approveRequest Request was: \n" . $soap->__getLastRequest()); |
|
248 | - $this->loggerInstance->debug(5, "approveRequest Response was: \n" . $soap->__getLastResponse()); |
|
247 | + $this->loggerInstance->debug(5, "approveRequest Request was: \n".$soap->__getLastRequest()); |
|
248 | + $this->loggerInstance->debug(5, "approveRequest Response was: \n".$soap->__getLastResponse()); |
|
249 | 249 | if ($soapIssueCert === FALSE) { |
250 | 250 | throw new Exception("The locally approved request was NOT processed by the CA."); |
251 | 251 | } |
252 | 252 | } catch (SoapFault $e) { |
253 | - throw new Exception("SoapFault: Error when sending or receiving SOAP message: " . "{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n"); |
|
253 | + throw new Exception("SoapFault: Error when sending or receiving SOAP message: "."{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n"); |
|
254 | 254 | } catch (Exception $e) { |
255 | - throw new Exception("Exception: Something odd happened between the SOAP requests:" . $e->getMessage()); |
|
255 | + throw new Exception("Exception: Something odd happened between the SOAP requests:".$e->getMessage()); |
|
256 | 256 | } |
257 | 257 | return $soapReqnum; |
258 | 258 | } |
@@ -304,9 +304,9 @@ discard block |
||
304 | 304 | throw new Exception("CAInfo has no root certificate for us!"); |
305 | 305 | } |
306 | 306 | } catch (SoapFault $e) { |
307 | - throw new Exception("SoapFault: Error when sending or receiving SOAP message: " . "{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n"); |
|
307 | + throw new Exception("SoapFault: Error when sending or receiving SOAP message: "."{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n"); |
|
308 | 308 | } catch (Exception $e) { |
309 | - throw new Exception("Exception: Something odd happened between the SOAP requests:" . $e->getMessage()); |
|
309 | + throw new Exception("Exception: Something odd happened between the SOAP requests:".$e->getMessage()); |
|
310 | 310 | } |
311 | 311 | return [ |
312 | 312 | "CERT" => openssl_x509_read($parsedCert['pem']), |
@@ -339,12 +339,12 @@ discard block |
||
339 | 339 | // for obnoxious reasons, we have to dump the request into a file and let pkcs7_sign read from the file |
340 | 340 | // rather than just using the string. Grr. |
341 | 341 | $tempdir = \core\common\Entity::createTemporaryDirectory("test"); |
342 | - file_put_contents($tempdir['dir'] . "/content.txt", $soapRawRevRequest); |
|
342 | + file_put_contents($tempdir['dir']."/content.txt", $soapRawRevRequest); |
|
343 | 343 | // retrieve our RA cert from filesystem |
344 | 344 | // sign the data, using cmdline because openssl_pkcs7_sign produces strange results |
345 | 345 | // -binary didn't help, nor switch -md to sha1 sha256 or sha512 |
346 | 346 | $this->loggerInstance->debug(5, "Actual content to be signed is this:\n$soapRawRevRequest\n"); |
347 | - $execCmd = \config\Master::PATHS['openssl'] . " smime -sign -binary -in " . $tempdir['dir'] . "/content.txt -out " . $tempdir['dir'] . "/signature.txt -outform pem -inkey " . $this->locationRaKey . " -signer " . $this->locationRaCert; |
|
347 | + $execCmd = \config\Master::PATHS['openssl']." smime -sign -binary -in ".$tempdir['dir']."/content.txt -out ".$tempdir['dir']."/signature.txt -outform pem -inkey ".$this->locationRaKey." -signer ".$this->locationRaCert; |
|
348 | 348 | $this->loggerInstance->debug(2, "Calling openssl smime with following cmdline: $execCmd\n"); |
349 | 349 | $output = []; |
350 | 350 | $return = 999; |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | throw new Exception("Non-zero return value from openssl smime!"); |
354 | 354 | } |
355 | 355 | // and get the signature blob back from the filesystem |
356 | - $detachedSig = trim(file_get_contents($tempdir['dir'] . "/signature.txt")); |
|
356 | + $detachedSig = trim(file_get_contents($tempdir['dir']."/signature.txt")); |
|
357 | 357 | $soapIssueRev = $soap->approveRevocationRequest($soapRevocationSerial, $soapRawRevRequest, $detachedSig); |
358 | 358 | if ($soapIssueRev === FALSE) { |
359 | 359 | throw new Exception("The locally approved revocation request was NOT processed by the CA."); |
@@ -361,9 +361,9 @@ discard block |
||
361 | 361 | } catch (Exception $e) { |
362 | 362 | // PHP 7.1 can do this much better |
363 | 363 | if (is_soap_fault($e)) { |
364 | - throw new Exception("Error when sending SOAP request: " . "{$e->faultcode}: {$e->faultstring}\n"); |
|
364 | + throw new Exception("Error when sending SOAP request: "."{$e->faultcode}: {$e->faultstring}\n"); |
|
365 | 365 | } |
366 | - throw new Exception("Something odd happened while doing the SOAP request:" . $e->getMessage()); |
|
366 | + throw new Exception("Something odd happened while doing the SOAP request:".$e->getMessage()); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
@@ -465,9 +465,9 @@ discard block |
||
465 | 465 | */ |
466 | 466 | public function soapToXmlInteger($x) |
467 | 467 | { |
468 | - return '<' . $x[0] . '>' |
|
468 | + return '<'.$x[0].'>' |
|
469 | 469 | . htmlentities($x[1], ENT_NOQUOTES | ENT_XML1) |
470 | - . '</' . $x[0] . '>'; |
|
470 | + . '</'.$x[0].'>'; |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | /** |
@@ -486,9 +486,9 @@ discard block |
||
486 | 486 | // dump private key into directory |
487 | 487 | $outstring = ""; |
488 | 488 | openssl_pkey_export($privateKey, $outstring); |
489 | - file_put_contents($tempdir . "/pkey.pem", $outstring); |
|
489 | + file_put_contents($tempdir."/pkey.pem", $outstring); |
|
490 | 490 | // PHP can only do one DC in the Subject. But we need three. |
491 | - $execCmd = \config\Master::PATHS['openssl'] . " req -new -sha256 -key $tempdir/pkey.pem -out $tempdir/request.csr -subj /DC=test/DC=test/DC=eduroam/C=$fed/O=" . \config\ConfAssistant::CONSORTIUM['name'] . "/OU=$fed/CN=$username/emailAddress=$username"; |
|
491 | + $execCmd = \config\Master::PATHS['openssl']." req -new -sha256 -key $tempdir/pkey.pem -out $tempdir/request.csr -subj /DC=test/DC=test/DC=eduroam/C=$fed/O=".\config\ConfAssistant::CONSORTIUM['name']."/OU=$fed/CN=$username/emailAddress=$username"; |
|
492 | 492 | $this->loggerInstance->debug(2, "Calling openssl req with following cmdline: $execCmd\n"); |
493 | 493 | $output = []; |
494 | 494 | $return = 999; |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | return $this->counter; |
143 | 143 | } |
144 | 144 | |
145 | - $cachedNumber = @file_get_contents(ROOT . "/var/tmp/cachedSPNumber.serialised"); |
|
145 | + $cachedNumber = @file_get_contents(ROOT."/var/tmp/cachedSPNumber.serialised"); |
|
146 | 146 | if ($cachedNumber !== FALSE) { |
147 | 147 | $numberData = unserialize($cachedNumber); |
148 | 148 | $now = new \DateTime(); |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | } else { // data in cache is too old or doesn't exist. We really need to ask the database |
156 | 156 | $list = $this->listAllServiceProviders(); |
157 | 157 | $this->counter = count($list); |
158 | - file_put_contents(ROOT . "/var/tmp/cachedSPNumber.serialised", serialize(["number" => $this->counter, "timestamp" => new \DateTime()])); |
|
158 | + file_put_contents(ROOT."/var/tmp/cachedSPNumber.serialised", serialize(["number" => $this->counter, "timestamp" => new \DateTime()])); |
|
159 | 159 | return $this->counter; |
160 | 160 | } |
161 | 161 | } |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | $returnarray = []; |
247 | 247 | $query = "SELECT instid AS id, country, inst_realm as realmlist, name AS collapsed_name, contact AS collapsed_contact, type FROM view_active_institution WHERE country = ?"; |
248 | 248 | if ($eduroamDbType !== NULL) { |
249 | - $query .= " AND ( type = '" . ExternalEduroamDBData::TYPE_IDPSP . "' OR type = '" . $eduroamDbType . "')"; |
|
249 | + $query .= " AND ( type = '".ExternalEduroamDBData::TYPE_IDPSP."' OR type = '".$eduroamDbType."')"; |
|
250 | 250 | } |
251 | 251 | $externals = $this->db->exec($query, "s", $tld); |
252 | 252 | // was a SELECT query, so a resource and not a boolean |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @return array |
306 | 306 | */ |
307 | 307 | |
308 | - public function listExternalEntitiesByUserEmail($userEmail){ |
|
308 | + public function listExternalEntitiesByUserEmail($userEmail) { |
|
309 | 309 | $out = []; |
310 | 310 | $cat = $this->localDb->dbName; |
311 | 311 | $query = "SELECT DISTINCT view_institution_admins.instid, $cat.institution.inst_id, |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | WHERE view_active_institution.type != 2 AND view_institution_admins.email= ?"; |
321 | 321 | $externals = $this->db->exec($query, 's', $userEmail); |
322 | 322 | while ($row = $externals->fetch_array()) { |
323 | - $external_db_id = $row[0]; // identifier in eduroam DB |
|
323 | + $external_db_id = $row[0]; // identifier in eduroam DB |
|
324 | 324 | $inst_id = $row[1]; // identifier in CAT - possibly NULL |
325 | 325 | $country = $row[2]; // country |
326 | - $name = $row[3]; // institution name from eduroam DB |
|
326 | + $name = $row[3]; // institution name from eduroam DB |
|
327 | 327 | $realm = $row[4]; // realms from eduroam DB |
328 | 328 | $type = $row[5]; // institution type from eduroam DB |
329 | 329 | if (!isset($out[$country])) { |
@@ -404,19 +404,19 @@ discard block |
||
404 | 404 | * |
405 | 405 | * @return array |
406 | 406 | */ |
407 | - public function listExternalTlsServersInstitution($tld, $include_not_ready=FALSE) { |
|
407 | + public function listExternalTlsServersInstitution($tld, $include_not_ready = FALSE) { |
|
408 | 408 | $retval = []; |
409 | 409 | // this includes servers of type "staging", which is fine |
410 | 410 | $query = "SELECT ROid, instid, type, inst_name, servers, contacts, ts FROM view_tls_inst WHERE country = ?"; |
411 | 411 | if (!$include_not_ready) { |
412 | - $query = $query . " AND servers IS NOT NULL AND contacts IS NOT NULL"; |
|
412 | + $query = $query." AND servers IS NOT NULL AND contacts IS NOT NULL"; |
|
413 | 413 | } |
414 | 414 | $instServerTransaction = $this->db->exec($query, "s", $tld); |
415 | 415 | while ($instServerResponses = mysqli_fetch_object(/** @scrutinizer ignore-type */ $instServerTransaction)) { |
416 | 416 | $contactList = $this::dissectCollapsedContacts($instServerResponses->contacts); |
417 | 417 | $names = $this->splitNames($instServerResponses->inst_name); |
418 | 418 | $thelanguage = $names[$this->languageInstance->getLang()] ?? $names["en"] ?? array_shift($names); |
419 | - $retval[$instServerResponses->ROid . "-". $instServerResponses->instid] = [ |
|
419 | + $retval[$instServerResponses->ROid."-".$instServerResponses->instid] = [ |
|
420 | 420 | "names" => $names, |
421 | 421 | "name" => $thelanguage, |
422 | 422 | "type" => array_search($instServerResponses->type, self::TYPE_MAPPING), |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | } else { |
161 | 161 | $this->databaseHandle->exec("INSERT INTO ownership (user_id, institution_id, blesslevel, orig_mail) VALUES(?, ?, ?, ?)", "siss", $owner, $catId, $level, $destMail); |
162 | 162 | } |
163 | - common\Logging::writeAudit_s((string) $owner, "OWN", "IdP " . $invitationDetails['cat_institution_id'] . " - added user as owner"); |
|
163 | + common\Logging::writeAudit_s((string) $owner, "OWN", "IdP ".$invitationDetails['cat_institution_id']." - added user as owner"); |
|
164 | 164 | common\Entity::outOfThePotatoes(); |
165 | 165 | return new IdP($invitationDetails['cat_institution_id']); |
166 | 166 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | $idp = new IdP($fed->newIdP('TOKEN', $invitationDetails['invite_fortype'], $owner, $invitationDetails['invite_issuer_level'], $invitationDetails['invite_dest_mail'], $bestnameguess)); |
175 | 175 | $idp->addAttribute("general:instname", 'C', $bestnameguess); |
176 | 176 | } |
177 | - common\Logging::writeAudit_s($owner, "NEW", "IdP " . $idp->identifier . " - created from invitation"); |
|
177 | + common\Logging::writeAudit_s($owner, "NEW", "IdP ".$idp->identifier." - created from invitation"); |
|
178 | 178 | |
179 | 179 | // in case we have more admins in the queue which were invited to |
180 | 180 | // administer the same inst but haven't redeemed their invitations |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | WHERE invite_created >= TIMESTAMPADD(DAY, -1, NOW()) AND used = 0 AND name = ? AND country = ? AND ( cat_institution_id IS NULL OR external_db_uniquehandle IS NULL ) ", "ss", $invitationDetails['name'], $invitationDetails['country']); |
189 | 189 | // SELECT -> resource, no boolean |
190 | 190 | while ($pendingDetail = mysqli_fetch_object(/** @scrutinizer ignore-type */ $otherPending)) { |
191 | - $this->databaseHandle->exec("UPDATE invitations SET cat_institution_id = " . $idp->identifier . " WHERE id = " . $pendingDetail->id); |
|
191 | + $this->databaseHandle->exec("UPDATE invitations SET cat_institution_id = ".$idp->identifier." WHERE id = ".$pendingDetail->id); |
|
192 | 192 | } |
193 | 193 | common\Entity::outOfThePotatoes(); |
194 | 194 | return $idp; |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | 'invite_dest_mail' => $_SESSION['auth_email'], |
214 | 214 | ]; |
215 | 215 | $idp = $this->newIdPFromExternal($extId, $fed, $invitationDetails, $owner, $externalinfo); |
216 | - common\Logging::writeAudit_s($owner, "NEW", "IdP " . $idp->identifier . " - created from auto-registration of $extId"); |
|
216 | + common\Logging::writeAudit_s($owner, "NEW", "IdP ".$idp->identifier." - created from auto-registration of $extId"); |
|
217 | 217 | return $idp; |
218 | 218 | } |
219 | 219 | |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | $retval = []; |
336 | 336 | $invitations = $this->databaseHandle->exec("SELECT cat_institution_id, country, name, invite_issuer_level, invite_dest_mail, invite_token , TIMESTAMPADD(DAY, 1, invite_created) as expiry |
337 | 337 | FROM invitations |
338 | - WHERE cat_institution_id " . ( $idpIdentifier != 0 ? "= $idpIdentifier" : "IS NULL") . " AND invite_created >= TIMESTAMPADD(DAY, -1, NOW()) AND used = 0"); |
|
338 | + WHERE cat_institution_id " . ($idpIdentifier != 0 ? "= $idpIdentifier" : "IS NULL")." AND invite_created >= TIMESTAMPADD(DAY, -1, NOW()) AND used = 0"); |
|
339 | 339 | // SELECT -> resource, not boolean |
340 | - common\Logging::debug_s(4, "Retrieving pending invitations for " . ($idpIdentifier != 0 ? "IdP $idpIdentifier" : "IdPs awaiting initial creation" ) . ".\n"); |
|
340 | + common\Logging::debug_s(4, "Retrieving pending invitations for ".($idpIdentifier != 0 ? "IdP $idpIdentifier" : "IdPs awaiting initial creation").".\n"); |
|
341 | 341 | while ($invitationQuery = mysqli_fetch_object(/** @scrutinizer ignore-type */ $invitations)) { |
342 | 342 | $retval[] = ["country" => $invitationQuery->country, "name" => $invitationQuery->name, "mail" => $invitationQuery->invite_dest_mail, "token" => $invitationQuery->invite_token, "expiry" => $invitationQuery->expiry]; |
343 | 343 | } |
@@ -409,7 +409,7 @@ discard block |
||
409 | 409 | // these require no further checking |
410 | 410 | foreach ($extInstListTmp as $country => $extInstCountryList) { |
411 | 411 | $len = count($extInstCountryList); |
412 | - for($i = 0; $i < $len; ++$i) { |
|
412 | + for ($i = 0; $i < $len; ++$i) { |
|
413 | 413 | $extInst = $extInstCountryList[$i]; |
414 | 414 | if ($extInst['inst_id'] != NULL && in_array($extInst['inst_id'], $this->currentInstitutions['existing'])) { |
415 | 415 | unset($extInstList[$country][$i]); |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | $names = $disectedNames['joint']; |
501 | 501 | $realms = ExternalEduroamDBData::dissectCollapsedInstitutionRealms($extInst['realm']); |
502 | 502 | $foundMatch = $this->checkForSimilarInstitutions($names, $realms); |
503 | - common\Logging::debug_s(4, $foundMatch, "checkForSimilarInstitutions returned: ","\n"); |
|
503 | + common\Logging::debug_s(4, $foundMatch, "checkForSimilarInstitutions returned: ", "\n"); |
|
504 | 504 | if ($foundMatch == 0) { |
505 | 505 | $this->currentInstitutions['new'][] = [$extInst['external_db_id'], $disectedNames['perlang'], $country]; |
506 | 506 | } |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | if (\config\Master::MAILSETTINGS['notify_nro']) { |
368 | 368 | foreach ($admins as $id) { |
369 | 369 | $user = new User($id); |
370 | - /// organisation |
|
370 | + /// organisation |
|
371 | 371 | $retval = $user->sendMailToUser(sprintf(_("%s in your federation was created"), common\Entity::$nomenclature_participant), $message); |
372 | 372 | if ($retval === FALSE) { |
373 | 373 | $this->loggerInstance->debug(2, "Mail to federation admin was NOT sent!\n"); |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | $newReq = new CertificationAuthorityEduPkiServer(); |
435 | 435 | $reqserial = $newReq->sendRequestToCa($csr, $revocationPin, $expiryDays); |
436 | 436 | if ($reqserial > 0) { |
437 | - $this->loggerInstance->writeAudit($user, "NEW", "Certificate request - NRO: ".$this->tld." - serial: ".$reqserial." - subject: ".$csr['SUBJECT']); |
|
437 | + $this->loggerInstance->writeAudit($user, "NEW", "Certificate request - NRO: ".$this->tld." - serial: ".$reqserial." - subject: ".$csr['SUBJECT']); |
|
438 | 438 | $reqQuery = "INSERT INTO federation_servercerts " |
439 | 439 | ."(federation_id, ca_name, request_serial, distinguished_name, status, revocation_pin) " |
440 | 440 | ."VALUES (?, 'eduPKI', ?, ?, 'REQUESTED', ?)"; |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | $result = $this->databaseHandle->exec($query); |
495 | 495 | $rows = $result->fetch_all(); |
496 | 496 | foreach ($rows as $row) { |
497 | - $activeProfiles[] = $row[0]; |
|
497 | + $activeProfiles[] = $row[0]; |
|
498 | 498 | } |
499 | 499 | $query = "SELECT institution.inst_id AS inst_id, profile.profile_id AS profile_id, profile_option.option_value AS cert FROM profile_option JOIN profile ON profile_option.profile_id=profile.profile_id JOIN institution ON profile.inst_id=institution.inst_id WHERE profile_option.option_name='eap:ca_file' and institution.country='".$this->tld."'"; |
500 | 500 | $result = $this->databaseHandle->exec($query); |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | 'country' => strtoupper($idp->federation), |
580 | 580 | 'instance' => $idp, |
581 | 581 | 'realms' => $idpQuery->realms] |
582 | - ; |
|
582 | + ; |
|
583 | 583 | $returnarray[$idp->identifier] = $idpInfo; |
584 | 584 | } |
585 | 585 | if ($activeOnly != 0) { // we're only doing this once. |
@@ -159,17 +159,17 @@ |
||
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | - /** |
|
163 | - * Writes an audit log entry to the audit log file - static version. These audits are semantic logs; they don't record every single modification |
|
164 | - * in the database, but provide a logical "who did what" overview. The exact modification SQL statements are logged |
|
165 | - * automatically with writeSQLAudit() instead. The log file path is configurable in _config.php. |
|
166 | - * |
|
167 | - * @param string $user persistent identifier of the user who triggered the action |
|
168 | - * @param string $category type of modification, from the fixed vocabulary: "NEW", "OWN", "MOD", "DEL" |
|
169 | - * @param string $message message to log into the audit log |
|
170 | - * @return boolean TRUE if successful. Will terminate script execution on failure. |
|
171 | - * @throws Exception |
|
172 | - */ |
|
162 | + /** |
|
163 | + * Writes an audit log entry to the audit log file - static version. These audits are semantic logs; they don't record every single modification |
|
164 | + * in the database, but provide a logical "who did what" overview. The exact modification SQL statements are logged |
|
165 | + * automatically with writeSQLAudit() instead. The log file path is configurable in _config.php. |
|
166 | + * |
|
167 | + * @param string $user persistent identifier of the user who triggered the action |
|
168 | + * @param string $category type of modification, from the fixed vocabulary: "NEW", "OWN", "MOD", "DEL" |
|
169 | + * @param string $message message to log into the audit log |
|
170 | + * @return boolean TRUE if successful. Will terminate script execution on failure. |
|
171 | + * @throws Exception |
|
172 | + */ |
|
173 | 173 | public static function writeAudit_s($user, $category, $message) |
174 | 174 | { |
175 | 175 | switch ($category) { |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | private function writeToFile($filename, $message) |
51 | 51 | { |
52 | - file_put_contents(\config\Master::PATHS['logdir'] . "/$filename", sprintf("%-015s", microtime(TRUE)) . $message, FILE_APPEND); |
|
52 | + file_put_contents(\config\Master::PATHS['logdir']."/$filename", sprintf("%-015s", microtime(TRUE)).$message, FILE_APPEND); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | /** |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | private static function writeToFile_s($filename, $message) |
63 | 63 | { |
64 | - file_put_contents(\config\Master::PATHS['logdir'] . "/$filename", sprintf("%-015s", microtime(TRUE)) . $message, FILE_APPEND); |
|
64 | + file_put_contents(\config\Master::PATHS['logdir']."/$filename", sprintf("%-015s", microtime(TRUE)).$message, FILE_APPEND); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | $output .= " [$file / $function / $line] "; |
90 | 90 | } |
91 | 91 | if (is_string($stuff)) { |
92 | - $output .= $prefix . $stuff . $suffix; |
|
92 | + $output .= $prefix.$stuff.$suffix; |
|
93 | 93 | } else { |
94 | - $output .= $prefix . var_export($stuff, TRUE) . $suffix; |
|
94 | + $output .= $prefix.var_export($stuff, TRUE).$suffix; |
|
95 | 95 | } |
96 | 96 | $this->writeToFile("debug.log", $output); |
97 | 97 | |
@@ -123,9 +123,9 @@ discard block |
||
123 | 123 | $output .= " [$file / $function / $line] "; |
124 | 124 | } |
125 | 125 | if (is_string($stuff)) { |
126 | - $output .= $prefix . $stuff . $suffix; |
|
126 | + $output .= $prefix.$stuff.$suffix; |
|
127 | 127 | } else { |
128 | - $output .= $prefix . var_export($stuff, TRUE) . $suffix; |
|
128 | + $output .= $prefix.var_export($stuff, TRUE).$suffix; |
|
129 | 129 | } |
130 | 130 | self::writeToFile_s("debug.log", $output); |
131 | 131 | return; |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | $logTextStep1 = preg_replace("/[\n\r]/", "", $query); |
202 | 202 | $logTextStep2 = preg_replace("/ +/", " ", $logTextStep1); |
203 | 203 | $logTextStep3 = iconv("UTF-8", "UTF-8//IGNORE", $logTextStep2); |
204 | - $this->writeToFile("audit-SQL.log", " " . $logTextStep3 . "\n"); |
|
204 | + $this->writeToFile("audit-SQL.log", " ".$logTextStep3."\n"); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | |
@@ -219,6 +219,6 @@ discard block |
||
219 | 219 | $logTextStep1 = preg_replace("/[\n\r]/", "", $query); |
220 | 220 | $logTextStep2 = preg_replace("/ +/", " ", $logTextStep1); |
221 | 221 | $logTextStep3 = iconv("UTF-8", "UTF-8//IGNORE", $logTextStep2); |
222 | - self::writeToFile_s("audit-SQL.log", " " . $logTextStep3 . "\n"); |
|
222 | + self::writeToFile_s("audit-SQL.log", " ".$logTextStep3."\n"); |
|
223 | 223 | } |
224 | 224 | } |
225 | 225 | \ No newline at end of file |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | return false; |
174 | 174 | } |
175 | 175 | $entityId = $matches[1]; |
176 | - $url = \config\Diagnostics::EDUGAINRESOLVER['url'] . "?action=get_entity_name&type=idp&opt=2&e_id=$entityId"; |
|
177 | - \core\common\Logging::debug_s(4, $url, "URL: ","\n"); |
|
176 | + $url = \config\Diagnostics::EDUGAINRESOLVER['url']."?action=get_entity_name&type=idp&opt=2&e_id=$entityId"; |
|
177 | + \core\common\Logging::debug_s(4, $url, "URL: ", "\n"); |
|
178 | 178 | $ch = curl_init($url); |
179 | 179 | if ($ch === false) { |
180 | 180 | $loggerInstance->debug(2, "Unable ask eduGAIN about IdP - CURL init failed!"); |
@@ -200,10 +200,10 @@ discard block |
||
200 | 200 | return false; |
201 | 201 | } |
202 | 202 | if ($responseDetails['name'] === null) { |
203 | - \core\common\Logging::debug_s(4,"User not in eduGAIN\n"); |
|
203 | + \core\common\Logging::debug_s(4, "User not in eduGAIN\n"); |
|
204 | 204 | return false; |
205 | 205 | } |
206 | - \core\common\Logging::debug_s(4,"User in eduGAIN\n"); |
|
206 | + \core\common\Logging::debug_s(4, "User in eduGAIN\n"); |
|
207 | 207 | $_SESSION['eduGAIN'] = $responseDetails['regauth']; |
208 | 208 | return true; |
209 | 209 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * @return boolean did it work? |
244 | 244 | */ |
245 | 245 | public static function sendMailToCATadmins($subject, $content) { |
246 | - if (!isset(\config\Master::APPEARANCE['cat-admin-mail']) || \config\Master::APPEARANCE['cat-admin-mail'] === []) { |
|
246 | + if (!isset(\config\Master::APPEARANCE['cat-admin-mail']) || \config\Master::APPEARANCE['cat-admin-mail'] === []) { |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | foreach (\config\Master::APPEARANCE['cat-admin-mail'] as $mailaddr) { |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | common\Entity::intoThePotatoes(); |
267 | 267 | $mail = \core\common\OutsideComm::mailHandle(); |
268 | 268 | // who to whom? |
269 | - $mail->FromName = \config\Master::APPEARANCE['productname'] . " Notification System"; |
|
270 | - $mail->addReplyTo(\config\Master::APPEARANCE['support-contact']['developer-mail'], \config\Master::APPEARANCE['productname'] . " " . _("Feedback")); |
|
269 | + $mail->FromName = \config\Master::APPEARANCE['productname']." Notification System"; |
|
270 | + $mail->addReplyTo(\config\Master::APPEARANCE['support-contact']['developer-mail'], \config\Master::APPEARANCE['productname']." "._("Feedback")); |
|
271 | 271 | $mail->addAddress($mailaddr); |
272 | 272 | // what do we want to say? |
273 | 273 | $mail->Subject = $subject; |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | } |
334 | 334 | $lookFor .= "$name"; |
335 | 335 | } |
336 | - $finding = preg_match("/^(" . $lookFor . "):(.*)/", $oneRow->user_id, $matches); |
|
336 | + $finding = preg_match("/^(".$lookFor."):(.*)/", $oneRow->user_id, $matches); |
|
337 | 337 | if ($finding === 0 || $finding === false) { |
338 | 338 | return false; |
339 | 339 | } |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | $matchedProviders[] = $idp; |
353 | 353 | $name = $idp; |
354 | 354 | if ($skipCurl == 0) { |
355 | - $url = \config\Diagnostics::EDUGAINRESOLVER['url'] . "?action=get_entity_name&type=idp&e_id=$idp&lang=$lang"; |
|
355 | + $url = \config\Diagnostics::EDUGAINRESOLVER['url']."?action=get_entity_name&type=idp&e_id=$idp&lang=$lang"; |
|
356 | 356 | $ch = curl_init($url); |
357 | 357 | if ($ch === false) { |
358 | 358 | $loggerInstance->debug(2, "Unable ask eduGAIN about IdP - CURL init failed!"); |
@@ -377,7 +377,7 @@ discard block |
||
377 | 377 | } |
378 | 378 | curl_close($ch); |
379 | 379 | } |
380 | - $listOfProviders[] = User::PROVIDER_STRINGS[$providerStrings[0]] . " - IdP: " . $name; |
|
380 | + $listOfProviders[] = User::PROVIDER_STRINGS[$providerStrings[0]]." - IdP: ".$name; |
|
381 | 381 | } |
382 | 382 | break; |
383 | 383 | case $providerStrings[2]: |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | return false; |
394 | 394 | } |
395 | 395 | } |
396 | - \core\common\Logging::debug_s(4,$listOfProviders, "PROVIDERS:\n", "\n"); |
|
396 | + \core\common\Logging::debug_s(4, $listOfProviders, "PROVIDERS:\n", "\n"); |
|
397 | 397 | return $listOfProviders; |
398 | 398 | } |
399 | 399 | } |
400 | 400 | \ No newline at end of file |
@@ -17,9 +17,9 @@ discard block |
||
17 | 17 | class CertificationAuthorityEduPki extends EntityWithDBProperties implements CertificationAuthorityInterface |
18 | 18 | { |
19 | 19 | |
20 | - private const LOCATION_RA_CERT = ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.pem"; |
|
21 | - private const LOCATION_RA_KEY = ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.clearkey"; |
|
22 | - private const LOCATION_WEBROOT = ROOT . "/config/SilverbulletClientCerts/eduPKI-webserver-root.pem"; |
|
20 | + private const LOCATION_RA_CERT = ROOT."/config/SilverbulletClientCerts/edupki-test-ra.pem"; |
|
21 | + private const LOCATION_RA_KEY = ROOT."/config/SilverbulletClientCerts/edupki-test-ra.clearkey"; |
|
22 | + private const LOCATION_WEBROOT = ROOT."/config/SilverbulletClientCerts/eduPKI-webserver-root.pem"; |
|
23 | 23 | private const EDUPKI_RA_ID = 700; |
24 | 24 | private const EDUPKI_CERT_PROFILE = "User SOAP"; |
25 | 25 | private const EDUPKI_RA_PKEY_PASSPHRASE = "..."; |
@@ -35,13 +35,13 @@ discard block |
||
35 | 35 | parent::__construct(); |
36 | 36 | |
37 | 37 | if (stat(CertificationAuthorityEduPki::LOCATION_RA_CERT) === FALSE) { |
38 | - throw new Exception("RA operator PEM file not found: " . CertificationAuthorityEduPki::LOCATION_RA_CERT); |
|
38 | + throw new Exception("RA operator PEM file not found: ".CertificationAuthorityEduPki::LOCATION_RA_CERT); |
|
39 | 39 | } |
40 | 40 | if (stat(CertificationAuthorityEduPki::LOCATION_RA_KEY) === FALSE) { |
41 | - throw new Exception("RA operator private key file not found: " . CertificationAuthorityEduPki::LOCATION_RA_KEY); |
|
41 | + throw new Exception("RA operator private key file not found: ".CertificationAuthorityEduPki::LOCATION_RA_KEY); |
|
42 | 42 | } |
43 | 43 | if (stat(CertificationAuthorityEduPki::LOCATION_WEBROOT) === FALSE) { |
44 | - throw new Exception("CA website root CA file not found: " . CertificationAuthorityEduPki::LOCATION_WEBROOT); |
|
44 | + throw new Exception("CA website root CA file not found: ".CertificationAuthorityEduPki::LOCATION_WEBROOT); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
@@ -75,19 +75,19 @@ discard block |
||
75 | 75 | // initialise connection to eduPKI CA / eduroam RA and send the request to them |
76 | 76 | try { |
77 | 77 | $altArray = [# Array mit den Subject Alternative Names |
78 | - "email:" . $csr["USERNAME"] |
|
78 | + "email:".$csr["USERNAME"] |
|
79 | 79 | ]; |
80 | 80 | $soapPub = $this->initEduPKISoapSession("PUBLIC"); |
81 | 81 | $this->loggerInstance->debug(5, "FIRST ACTUAL SOAP REQUEST (Public, newRequest)!\n"); |
82 | - $this->loggerInstance->debug(5, "PARAM_1: " . CertificationAuthorityEduPki::EDUPKI_RA_ID . "\n"); |
|
83 | - $this->loggerInstance->debug(5, "PARAM_2: " . $csr["CSR_STRING"] . "\n"); |
|
82 | + $this->loggerInstance->debug(5, "PARAM_1: ".CertificationAuthorityEduPki::EDUPKI_RA_ID."\n"); |
|
83 | + $this->loggerInstance->debug(5, "PARAM_2: ".$csr["CSR_STRING"]."\n"); |
|
84 | 84 | $this->loggerInstance->debug(5, "PARAM_3: "); |
85 | 85 | $this->loggerInstance->debug(5, $altArray); |
86 | - $this->loggerInstance->debug(5, "PARAM_4: " . CertificationAuthorityEduPki::EDUPKI_CERT_PROFILE . "\n"); |
|
87 | - $this->loggerInstance->debug(5, "PARAM_5: " . sha1("notused") . "\n"); |
|
88 | - $this->loggerInstance->debug(5, "PARAM_6: " . $csr["USERNAME"] . "\n"); |
|
89 | - $this->loggerInstance->debug(5, "PARAM_7: " . $csr["USERNAME"] . "\n"); |
|
90 | - $this->loggerInstance->debug(5, "PARAM_8: " . \config\ConfAssistant::SILVERBULLET['product_name'] . "\n"); |
|
86 | + $this->loggerInstance->debug(5, "PARAM_4: ".CertificationAuthorityEduPki::EDUPKI_CERT_PROFILE."\n"); |
|
87 | + $this->loggerInstance->debug(5, "PARAM_5: ".sha1("notused")."\n"); |
|
88 | + $this->loggerInstance->debug(5, "PARAM_6: ".$csr["USERNAME"]."\n"); |
|
89 | + $this->loggerInstance->debug(5, "PARAM_7: ".$csr["USERNAME"]."\n"); |
|
90 | + $this->loggerInstance->debug(5, "PARAM_8: ".\config\ConfAssistant::SILVERBULLET['product_name']."\n"); |
|
91 | 91 | $this->loggerInstance->debug(5, "PARAM_9: false\n"); |
92 | 92 | $soapNewRequest = $soapPub->newRequest( |
93 | 93 | CertificationAuthorityEduPki::EDUPKI_RA_ID, # RA-ID |
@@ -109,11 +109,11 @@ discard block |
||
109 | 109 | } catch (Exception $e) { |
110 | 110 | // PHP 7.1 can do this much better |
111 | 111 | if (is_soap_fault($e)) { |
112 | - throw new Exception("Error when sending SOAP request: " . "{$e->faultcode}: { |
|
112 | + throw new Exception("Error when sending SOAP request: "."{$e->faultcode}: { |
|
113 | 113 | $e->faultstring |
114 | 114 | }\n"); |
115 | 115 | } |
116 | - throw new Exception("Something odd happened while doing the SOAP request:" . $e->getMessage()); |
|
116 | + throw new Exception("Something odd happened while doing the SOAP request:".$e->getMessage()); |
|
117 | 117 | } |
118 | 118 | try { |
119 | 119 | $soap = $this->initEduPKISoapSession("RA"); |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | $soapReqnum, [ |
126 | 126 | "RaID" => CertificationAuthorityEduPki::EDUPKI_RA_ID, |
127 | 127 | "Role" => CertificationAuthorityEduPki::EDUPKI_CERT_PROFILE, |
128 | - "Subject" => "DC=eduroam,DC=test,DC=test,C=" . $csr["FED"] . ",O=" . \config\ConfAssistant::CONSORTIUM['name'] . ",OU=" . $csr["FED"] . ",CN=" . $csr['USERNAME'] . ",emailAddress=" . $csr['USERNAME'], |
|
129 | - "SubjectAltNames" => ["email:" . $csr["USERNAME"]], |
|
128 | + "Subject" => "DC=eduroam,DC=test,DC=test,C=".$csr["FED"].",O=".\config\ConfAssistant::CONSORTIUM['name'].",OU=".$csr["FED"].",CN=".$csr['USERNAME'].",emailAddress=".$csr['USERNAME'], |
|
129 | + "SubjectAltNames" => ["email:".$csr["USERNAME"]], |
|
130 | 130 | "NotBefore" => (new \DateTime())->format('c'), |
131 | 131 | "NotAfter" => $expiry->format('c'), |
132 | 132 | ] |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | // for obnoxious reasons, we have to dump the request into a file and let pkcs7_sign read from the file |
146 | 146 | // rather than just using the string. Grr. |
147 | 147 | $tempdir = \core\common\Entity::createTemporaryDirectory("test"); |
148 | - file_put_contents($tempdir['dir'] . "/content.txt", $soapCleartext); |
|
148 | + file_put_contents($tempdir['dir']."/content.txt", $soapCleartext); |
|
149 | 149 | // retrieve our RA cert from filesystem |
150 | 150 | // the RA certificates are not needed right now because we |
151 | 151 | // have resorted to S/MIME signatures with openssl command-line |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | // sign the data, using cmdline because openssl_pkcs7_sign produces strange results |
158 | 158 | // -binary didn't help, nor switch -md to sha1 sha256 or sha512 |
159 | 159 | $this->loggerInstance->debug(5, "Actual content to be signed is this:\n $soapCleartext\n"); |
160 | - $execCmd = \config\Master::PATHS['openssl'] . " smime -sign -binary -in " . $tempdir['dir'] . "/content.txt -out " . $tempdir['dir'] . "/signature.txt -outform pem -inkey " . ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.clearkey -signer " . ROOT . "/config/SilverbulletClientCerts/edupki-test-ra.pem"; |
|
160 | + $execCmd = \config\Master::PATHS['openssl']." smime -sign -binary -in ".$tempdir['dir']."/content.txt -out ".$tempdir['dir']."/signature.txt -outform pem -inkey ".ROOT."/config/SilverbulletClientCerts/edupki-test-ra.clearkey -signer ".ROOT."/config/SilverbulletClientCerts/edupki-test-ra.pem"; |
|
161 | 161 | $this->loggerInstance->debug(2, "Calling openssl smime with following cmdline: $execCmd\n"); |
162 | 162 | $output = []; |
163 | 163 | $return = 999; |
@@ -166,14 +166,14 @@ discard block |
||
166 | 166 | throw new Exception("Non-zero return value from openssl smime!"); |
167 | 167 | } |
168 | 168 | // and get the signature blob back from the filesystem |
169 | - $detachedSig = trim(file_get_contents($tempdir['dir'] . "/signature.txt")); |
|
169 | + $detachedSig = trim(file_get_contents($tempdir['dir']."/signature.txt")); |
|
170 | 170 | $this->loggerInstance->debug(5, "Request for server approveRequest has parameters:\n"); |
171 | - $this->loggerInstance->debug(5, $soapReqnum . "\n"); |
|
172 | - $this->loggerInstance->debug(5, $soapCleartext . "\n"); // PHP magically encodes this as base64 while sending! |
|
173 | - $this->loggerInstance->debug(5, $detachedSig . "\n"); |
|
171 | + $this->loggerInstance->debug(5, $soapReqnum."\n"); |
|
172 | + $this->loggerInstance->debug(5, $soapCleartext."\n"); // PHP magically encodes this as base64 while sending! |
|
173 | + $this->loggerInstance->debug(5, $detachedSig."\n"); |
|
174 | 174 | $soapIssueCert = $soap->approveRequest($soapReqnum, $soapCleartext, $detachedSig); |
175 | - $this->loggerInstance->debug(5, "approveRequest Request was: \n" . $soap->__getLastRequest()); |
|
176 | - $this->loggerInstance->debug(5, "approveRequest Response was: \n" . $soap->__getLastResponse()); |
|
175 | + $this->loggerInstance->debug(5, "approveRequest Request was: \n".$soap->__getLastRequest()); |
|
176 | + $this->loggerInstance->debug(5, "approveRequest Response was: \n".$soap->__getLastResponse()); |
|
177 | 177 | if ($soapIssueCert === FALSE) { |
178 | 178 | throw new Exception("The locally approved request was NOT processed by the CA."); |
179 | 179 | } |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | throw new Exception("CAInfo has no root certificate for us!"); |
211 | 211 | } |
212 | 212 | } catch (SoapFault $e) { |
213 | - throw new Exception("SoapFault: Error when sending or receiving SOAP message: " . "{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n"); |
|
213 | + throw new Exception("SoapFault: Error when sending or receiving SOAP message: "."{$e->faultcode}: {$e->faultname}: {$e->faultstring}: {$e->faultactor}: {$e->detail}: {$e->headerfault}\n"); |
|
214 | 214 | } catch (Exception $e) { |
215 | - throw new Exception("Exception: Something odd happened between the SOAP requests:" . $e->getMessage()); |
|
215 | + throw new Exception("Exception: Something odd happened between the SOAP requests:".$e->getMessage()); |
|
216 | 216 | } |
217 | 217 | return [ |
218 | 218 | "CERT" => openssl_x509_read($parsedCert['pem']), |
@@ -245,12 +245,12 @@ discard block |
||
245 | 245 | // for obnoxious reasons, we have to dump the request into a file and let pkcs7_sign read from the file |
246 | 246 | // rather than just using the string. Grr. |
247 | 247 | $tempdir = \core\common\Entity::createTemporaryDirectory("test"); |
248 | - file_put_contents($tempdir['dir'] . "/content.txt", $soapRawRevRequest); |
|
248 | + file_put_contents($tempdir['dir']."/content.txt", $soapRawRevRequest); |
|
249 | 249 | // retrieve our RA cert from filesystem |
250 | 250 | // sign the data, using cmdline because openssl_pkcs7_sign produces strange results |
251 | 251 | // -binary didn't help, nor switch -md to sha1 sha256 or sha512 |
252 | 252 | $this->loggerInstance->debug(5, "Actual content to be signed is this:\n$soapRawRevRequest\n"); |
253 | - $execCmd = \config\Master::PATHS['openssl'] . " smime -sign -binary -in " . $tempdir['dir'] . "/content.txt -out " . $tempdir['dir'] . "/signature.txt -outform pem -inkey " . CertificationAuthorityEduPki::LOCATION_RA_KEY . " -signer " . CertificationAuthorityEduPki::LOCATION_RA_CERT; |
|
253 | + $execCmd = \config\Master::PATHS['openssl']." smime -sign -binary -in ".$tempdir['dir']."/content.txt -out ".$tempdir['dir']."/signature.txt -outform pem -inkey ".CertificationAuthorityEduPki::LOCATION_RA_KEY." -signer ".CertificationAuthorityEduPki::LOCATION_RA_CERT; |
|
254 | 254 | $this->loggerInstance->debug(2, "Calling openssl smime with following cmdline: $execCmd\n"); |
255 | 255 | $output = []; |
256 | 256 | $return = 999; |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | throw new Exception("Non-zero return value from openssl smime!"); |
260 | 260 | } |
261 | 261 | // and get the signature blob back from the filesystem |
262 | - $detachedSig = trim(file_get_contents($tempdir['dir'] . "/signature.txt")); |
|
262 | + $detachedSig = trim(file_get_contents($tempdir['dir']."/signature.txt")); |
|
263 | 263 | $soapIssueRev = $soap->approveRevocationRequest($soapRevocationSerial, $soapRawRevRequest, $detachedSig); |
264 | 264 | if ($soapIssueRev === FALSE) { |
265 | 265 | throw new Exception("The locally approved revocation request was NOT processed by the CA."); |
@@ -267,9 +267,9 @@ discard block |
||
267 | 267 | } catch (Exception $e) { |
268 | 268 | // PHP 7.1 can do this much better |
269 | 269 | if (is_soap_fault($e)) { |
270 | - throw new Exception("Error when sending SOAP request: " . "{$e->faultcode}: {$e->faultstring}\n"); |
|
270 | + throw new Exception("Error when sending SOAP request: "."{$e->faultcode}: {$e->faultstring}\n"); |
|
271 | 271 | } |
272 | - throw new Exception("Something odd happened while doing the SOAP request:" . $e->getMessage()); |
|
272 | + throw new Exception("Something odd happened while doing the SOAP request:".$e->getMessage()); |
|
273 | 273 | } |
274 | 274 | } |
275 | 275 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | 'http' => [ |
290 | 290 | 'timeout' => 60, |
291 | 291 | 'user_agent' => 'Stefan', |
292 | - 'header'=> array( "Accept-language: en" ), |
|
292 | + 'header'=> array("Accept-language: en"), |
|
293 | 293 | 'protocol_version' => 1.1 |
294 | 294 | ], |
295 | 295 | 'ssl' => [ |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function soapToXmlInteger($x) |
372 | 372 | { |
373 | - return '<' . $x[0] . '>' |
|
373 | + return '<'.$x[0].'>' |
|
374 | 374 | . htmlentities($x[1], ENT_NOQUOTES | ENT_XML1) |
375 | - . '</' . $x[0] . '>'; |
|
375 | + . '</'.$x[0].'>'; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -391,9 +391,9 @@ discard block |
||
391 | 391 | // dump private key into directory |
392 | 392 | $outstring = ""; |
393 | 393 | openssl_pkey_export($privateKey, $outstring); |
394 | - file_put_contents($tempdir . "/pkey.pem", $outstring); |
|
394 | + file_put_contents($tempdir."/pkey.pem", $outstring); |
|
395 | 395 | // PHP can only do one DC in the Subject. But we need three. |
396 | - $execCmd = \config\Master::PATHS['openssl'] . " req -new -sha256 -key $tempdir/pkey.pem -out $tempdir/request.csr -subj /DC=test/DC=test/DC=eduroam/C=$fed/O=" . \config\ConfAssistant::CONSORTIUM['name'] . "/OU=$fed/CN=$username/emailAddress=$username"; |
|
396 | + $execCmd = \config\Master::PATHS['openssl']." req -new -sha256 -key $tempdir/pkey.pem -out $tempdir/request.csr -subj /DC=test/DC=test/DC=eduroam/C=$fed/O=".\config\ConfAssistant::CONSORTIUM['name']."/OU=$fed/CN=$username/emailAddress=$username"; |
|
397 | 397 | $this->loggerInstance->debug(2, "Calling openssl req with following cmdline: $execCmd\n"); |
398 | 398 | $output = []; |
399 | 399 | $return = 999; |