18declare(strict_types=1);
78 $this->db =
$DIC->database();
79 $this->log =
$DIC->logger()->wsrv();
80 $this->objDataCache =
$DIC[
'ilObjDataCache'];
81 $this->tree =
$DIC->repositoryTree();
83 $this->server_id = $a_server_id;
94 return self::$instances[$a_server_id] ?? (self::$instances[$a_server_id] =
new ilECSSetting($a_server_id));
119 $this->title = $a_title;
136 $this->auth_type = $a_auth_type;
152 $this->auth_user = $a_user;
168 $this->auth_pass = $a_pass;
193 $this->active = $status;
209 $this->server = $a_server;
236 if (strpos($this->
getServer(),
'/') !==
false) {
238 foreach ((array) explode(
'/', $this->
getServer()) as
$key => $part) {
241 $uri .=
':' . $this->
getPort();
246 $uri = substr($uri, 0, -1);
249 $uri .= (
':' . $this->
getPort());
260 $this->protocol = $a_prot;
276 $this->port = $a_port;
289 $this->client_cert_path = $a_path;
307 $this->ca_cert_path = $a_ca;
333 $this->key_path = $a_path;
351 $this->key_password = $a_pass;
360 $this->import_id = $a_id;
376 $this->cert_serial_number = $a_cert_serial;
400 $this->global_role = $a_role_id;
408 $this->duration = $a_duration;
432 return implode(
',', $this->user_recipients);
443 $this->user_recipients = $a_logins;
459 return implode(
',', $this->econtent_recipients);
469 $this->econtent_recipients = $a_logins;
485 return implode(
',', $this->approval_recipients);
493 $this->approval_recipients = $a_rcp;
508 if ($this->
getAuthType() === self::AUTH_CERTIFICATE) {
547 if ($this->objDataCache->lookupType($this->objDataCache->lookupObjId($this->getImportId())) !==
'cat') {
550 if ($this->tree->isDeleted($this->getImportId())) {
561 $this->server_id = $this->db->nextId(
'ecs_server');
562 $this->db->manipulate(
563 'INSERT INTO ecs_server (server_id,active,title,protocol,server,port,auth_type,client_cert_path,ca_cert_path,' .
564 'key_path,key_password,cert_serial,import_id,global_role,econtent_rcp,user_rcp,approval_rcp,duration,auth_user,auth_pass) ' .
566 $this->db->quote($this->getServerId(),
'integer') .
', ' .
567 $this->db->quote((
int) $this->isEnabled(),
'integer') .
', ' .
568 $this->db->quote($this->getTitle(),
'text') .
', ' .
569 $this->db->quote($this->getProtocol(),
'integer') .
', ' .
570 $this->db->quote($this->getServer(),
'text') .
', ' .
571 $this->db->quote($this->getPort(),
'integer') .
', ' .
572 $this->db->quote($this->getAuthType(),
'integer') .
', ' .
573 $this->db->quote($this->getClientCertPath(),
'text') .
', ' .
574 $this->db->quote($this->getCACertPath(),
'text') .
', ' .
575 $this->db->quote($this->getKeyPath(),
'text') .
', ' .
576 $this->db->quote($this->getKeyPassword(),
'text') .
', ' .
577 $this->db->quote($this->getCertSerialNumber(),
'text') .
', ' .
578 $this->db->quote($this->getImportId(),
'integer') .
', ' .
579 $this->db->quote($this->getGlobalRole(),
'integer') .
', ' .
580 $this->db->quote($this->getEContentRecipientsAsString(),
'text') .
', ' .
581 $this->db->quote($this->getUserRecipientsAsString(),
'text') .
', ' .
582 $this->db->quote($this->getApprovalRecipientsAsString(),
'text') .
', ' .
583 $this->db->quote($this->getDuration(),
'integer') .
', ' .
584 $this->db->quote($this->getAuthUser(),
'text') .
', ' .
585 $this->db->quote($this->getAuthPass(),
'text') .
' ' .
595 $this->db->manipulate(
596 'UPDATE ecs_server SET ' .
597 'server_id = ' . $this->db->quote($this->getServerId(),
'integer') .
', ' .
598 'active = ' . $this->db->quote((
int) $this->isEnabled(),
'integer') .
', ' .
599 'title = ' . $this->db->quote($this->getTitle(),
'text') .
', ' .
600 'protocol = ' . $this->db->quote($this->getProtocol(),
'integer') .
', ' .
601 'server = ' . $this->db->quote($this->getServer(),
'text') .
', ' .
602 'port = ' . $this->db->quote($this->getPort(),
'integer') .
', ' .
603 'auth_type = ' . $this->db->quote($this->getAuthType(),
'integer') .
', ' .
604 'client_cert_path = ' . $this->db->quote($this->getClientCertPath(),
'text') .
', ' .
605 'ca_cert_path = ' . $this->db->quote($this->getCACertPath(),
'text') .
', ' .
606 'key_path = ' . $this->db->quote($this->getKeyPath(),
'text') .
', ' .
607 'key_password = ' . $this->db->quote($this->getKeyPassword(),
'text') .
', ' .
608 'cert_serial = ' . $this->db->quote($this->getCertSerialNumber(),
'text') .
', ' .
609 'import_id = ' . $this->db->quote($this->getImportId(),
'integer') .
', ' .
610 'global_role = ' . $this->db->quote($this->getGlobalRole(),
'integer') .
', ' .
611 'econtent_rcp = ' . $this->db->quote($this->getEContentRecipientsAsString(),
'text') .
', ' .
612 'user_rcp = ' . $this->db->quote($this->getUserRecipientsAsString(),
'text') .
', ' .
613 'approval_rcp = ' . $this->db->quote($this->getApprovalRecipientsAsString(),
'text') .
', ' .
614 'duration = ' . $this->db->quote($this->getDuration(),
'integer') .
', ' .
615 'auth_user = ' . $this->db->quote($this->getAuthUser(),
'text') .
', ' .
616 'auth_pass = ' . $this->db->quote($this->getAuthPass(),
'text') .
', ' .
617 'auth_type = ' . $this->db->quote($this->getAuthType(),
'integer') .
' ' .
618 'WHERE server_id = ' . $this->db->quote($this->getServerId(),
'integer')
625 public function delete():
bool
639 $query =
'DELETE FROM ecs_events' .
640 ' WHERE server_id = ' . $this->db->quote($this->
getServerId(),
'integer');
641 $this->db->manipulate(
$query);
651 $this->db->manipulate(
652 'DELETE FROM ecs_server ' .
653 'WHERE server_id = ' . $this->db->quote($this->getServerId(),
'integer')
656 $this->server_id = 0;
666 if ($this->
getAuthType() !== self::AUTH_CERTIFICATE) {
670 if ((function_exists(
'openssl_x509_parse') &&
672 $cert && isset($cert[
'validTo_time_t'])) && $cert[
'validTo_time_t']) {
686 if (function_exists(
'openssl_x509_parse') && ($cert = openssl_x509_parse(
'file://' . $this->
getClientCertPath())) && $cert && isset($cert[
'serialNumber']) && $cert[
'serialNumber']) {
688 $this->log->debug(
'Searial number is: ' . $cert[
'serialNumber']);
697 foreach ($lines as $line) {
698 if (strpos($line,
'Serial Number:') !==
false) {
700 $serial_line = explode(
':', $line);
701 $serial = trim($serial_line[1]);
705 if ($found && isset($serial)) {
721 $query =
'SELECT * FROM ecs_server ' .
722 'WHERE server_id = ' . $this->db->quote($this->
getServerId(),
'integer');
728 $this->
setPort((
int) $row[
'port']);
735 if ($row[
'cert_serial']) {
739 $this->econtent_recipients = explode(
',', $row[
'econtent_rcp']);
740 $this->approval_recipients = explode(
',', $row[
'approval_rcp']);
741 $this->user_recipients = explode(
',', $row[
'user_rcp']);
755 $this->server_id = 0;
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
static deleteByServerId($a_server_id)
static getInstanceByServerId(int $a_server_id)
Get singleton instance.
Reads ECS events and stores them in the database.
static getInstance()
Get the singelton instance of this ilECSExportManager.
static getInstance()
Get the singleton instance of this ilECSImportManager.
static deleteByServerId($a_server_id)
static getInstance()
Get singleton instance.
checkImportId()
check import id
setAuthPass($a_pass)
Set Apache auth password.
setAuthType($a_auth_type)
Set auth type.
getAuthType()
Get auth type.
getServerId()
Get current server id.
setDuration(int $a_duration)
set Duration
getApprovalRecipientsAsString()
get approval recipients as string
getApprovalRecipients()
get approval recipients
fetchSerialID()
Fetch serial ID from cert.
array $econtent_recipients
setApprovalRecipients(array $a_rcp)
set approval recipients
setKeyPassword(string $a_pass)
set key password
setTitle(string $a_title)
Set title.
setPort(int $a_port)
set port
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
getAuthUser()
Get apache auth user.
getAuthPass()
Get auth password.
getUserRecipientsAsString()
Get new user recipients.
setProtocol(int $a_prot)
set protocol
string $cert_serial_number
__construct($a_server_id=0)
Singleton contructor.
getCertSerialNumber()
get cert serial number
setKeyPath(string $a_path)
set key path
static ecsConfigured()
Checks if an ecs server is configured.
getKeyPassword()
get key password
setAuthUser($a_user)
Set apache auth user.
getDuration()
get duration
setEnabledStatus(bool $status)
en/disable ecs functionality
getCACertPath()
get ca cert path
fetchCertificateExpiration()
Fetch validity (expired date)
getUserRecipients()
Get new user recipients.
setGlobalRole(int $a_role_id)
set default global role
setCertSerialNumber(string $a_cert_serial)
set cert serial number
setEContentRecipients(array $a_logins)
set EContent recipients
getServerURI()
get complete server uri
const ERROR_EXTRACT_SERIAL
setClientCertPath($a_path)
setImportId(int $a_id)
set import id Object of category, that store new remote courses
setServer(string $a_server)
set server
static lookupAuthMode()
Lookup auth mode.
getClientCertPath()
get certificate path
getEContentRecipientsAsString()
get EContent recipients as string
array $approval_recipients
getEContentRecipients()
get Econtent recipients
validate()
Validate settings.
getGlobalRole()
get global role
setCACertPath(string $a_ca)
set ca cert path
getProtocol()
get protocol
const ERROR_INVALID_IMPORT_ID
__clone()
Overwritten clone method Reset all connection settings.
getImportId()
get import id
ilObjectDataCache $objDataCache
setUserRecipients(array $a_logins)
set user recipients
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...