19declare(strict_types=1);
79 $this->db =
$DIC->database();
80 $this->log =
$DIC->logger()->wsrv();
81 $this->objDataCache =
$DIC[
'ilObjDataCache'];
82 $this->tree =
$DIC->repositoryTree();
84 $this->server_id = $a_server_id;
95 return self::$instances[$a_server_id] ?? (self::$instances[$a_server_id] =
new ilECSSetting($a_server_id));
120 $this->title = $a_title;
137 $this->auth_type = $a_auth_type;
153 $this->auth_user = $a_user;
169 $this->auth_pass = $a_pass;
194 $this->active = $status;
210 $this->
server = $a_server;
237 if (strpos($this->
getServer(),
'/') !==
false) {
239 foreach ((array) explode(
'/', $this->
getServer()) as $key => $part) {
242 $uri .=
':' . $this->
getPort();
247 $uri = substr($uri, 0, -1);
250 $uri .= (
':' . $this->
getPort());
261 $this->protocol = $a_prot;
277 $this->port = $a_port;
290 $this->client_cert_path = $a_path;
308 $this->ca_cert_path = $a_ca;
334 $this->key_path = $a_path;
352 $this->key_password = $a_pass;
361 $this->import_id = $a_id;
377 $this->cert_serial_number = $a_cert_serial;
401 $this->global_role = $a_role_id;
409 $this->duration = $a_duration;
433 return implode(
',', $this->user_recipients);
444 $this->user_recipients = $a_logins;
460 return implode(
',', $this->econtent_recipients);
470 $this->econtent_recipients = $a_logins;
486 return implode(
',', $this->approval_recipients);
494 $this->approval_recipients = $a_rcp;
509 if ($this->
getAuthType() === self::AUTH_CERTIFICATE) {
548 if ($this->objDataCache->lookupType($this->objDataCache->lookupObjId($this->getImportId())) !==
'cat') {
551 if ($this->tree->isDeleted($this->getImportId())) {
562 $this->server_id = $this->db->nextId(
'ecs_server');
563 $this->db->manipulate(
564 'INSERT INTO ecs_server (server_id,active,title,protocol,server,port,auth_type,client_cert_path,ca_cert_path,' .
565 'key_path,key_password,cert_serial,import_id,global_role,econtent_rcp,user_rcp,approval_rcp,duration,auth_user,auth_pass) ' .
567 $this->db->quote($this->getServerId(),
'integer') .
', ' .
568 $this->db->quote((
int) $this->isEnabled(),
'integer') .
', ' .
569 $this->db->quote($this->getTitle(),
'text') .
', ' .
570 $this->db->quote($this->getProtocol(),
'integer') .
', ' .
571 $this->db->quote($this->getServer(),
'text') .
', ' .
572 $this->db->quote($this->getPort(),
'integer') .
', ' .
573 $this->db->quote($this->getAuthType(),
'integer') .
', ' .
574 $this->db->quote($this->getClientCertPath(),
'text') .
', ' .
575 $this->db->quote($this->getCACertPath(),
'text') .
', ' .
576 $this->db->quote($this->getKeyPath(),
'text') .
', ' .
577 $this->db->quote($this->getKeyPassword(),
'text') .
', ' .
578 $this->db->quote($this->getCertSerialNumber(),
'text') .
', ' .
579 $this->db->quote($this->getImportId(),
'integer') .
', ' .
580 $this->db->quote($this->getGlobalRole(),
'integer') .
', ' .
581 $this->db->quote($this->getEContentRecipientsAsString(),
'text') .
', ' .
582 $this->db->quote($this->getUserRecipientsAsString(),
'text') .
', ' .
583 $this->db->quote($this->getApprovalRecipientsAsString(),
'text') .
', ' .
584 $this->db->quote($this->getDuration(),
'integer') .
', ' .
585 $this->db->quote($this->getAuthUser(),
'text') .
', ' .
586 $this->db->quote($this->getAuthPass(),
'text') .
' ' .
596 $this->db->manipulate(
597 'UPDATE ecs_server SET ' .
598 'server_id = ' . $this->db->quote($this->getServerId(),
'integer') .
', ' .
599 'active = ' . $this->db->quote((
int) $this->isEnabled(),
'integer') .
', ' .
600 'title = ' . $this->db->quote($this->getTitle(),
'text') .
', ' .
601 'protocol = ' . $this->db->quote($this->getProtocol(),
'integer') .
', ' .
602 'server = ' . $this->db->quote($this->getServer(),
'text') .
', ' .
603 'port = ' . $this->db->quote($this->getPort(),
'integer') .
', ' .
604 'auth_type = ' . $this->db->quote($this->getAuthType(),
'integer') .
', ' .
605 'client_cert_path = ' . $this->db->quote($this->getClientCertPath(),
'text') .
', ' .
606 'ca_cert_path = ' . $this->db->quote($this->getCACertPath(),
'text') .
', ' .
607 'key_path = ' . $this->db->quote($this->getKeyPath(),
'text') .
', ' .
608 'key_password = ' . $this->db->quote($this->getKeyPassword(),
'text') .
', ' .
609 'cert_serial = ' . $this->db->quote($this->getCertSerialNumber(),
'text') .
', ' .
610 'import_id = ' . $this->db->quote($this->getImportId(),
'integer') .
', ' .
611 'global_role = ' . $this->db->quote($this->getGlobalRole(),
'integer') .
', ' .
612 'econtent_rcp = ' . $this->db->quote($this->getEContentRecipientsAsString(),
'text') .
', ' .
613 'user_rcp = ' . $this->db->quote($this->getUserRecipientsAsString(),
'text') .
', ' .
614 'approval_rcp = ' . $this->db->quote($this->getApprovalRecipientsAsString(),
'text') .
', ' .
615 'duration = ' . $this->db->quote($this->getDuration(),
'integer') .
', ' .
616 'auth_user = ' . $this->db->quote($this->getAuthUser(),
'text') .
', ' .
617 'auth_pass = ' . $this->db->quote($this->getAuthPass(),
'text') .
', ' .
618 'auth_type = ' . $this->db->quote($this->getAuthType(),
'integer') .
' ' .
619 'WHERE server_id = ' . $this->db->quote($this->getServerId(),
'integer')
626 public function delete():
bool
640 $query =
'DELETE FROM ecs_events' .
641 ' WHERE server_id = ' . $this->db->quote($this->
getServerId(),
'integer');
642 $this->db->manipulate($query);
652 $this->db->manipulate(
653 'DELETE FROM ecs_server ' .
654 'WHERE server_id = ' . $this->db->quote($this->getServerId(),
'integer')
657 $this->server_id = 0;
667 if ($this->
getAuthType() !== self::AUTH_CERTIFICATE) {
671 if ((function_exists(
'openssl_x509_parse') &&
673 $cert && isset($cert[
'validTo_time_t'])) && $cert[
'validTo_time_t']) {
687 if (function_exists(
'openssl_x509_parse') && ($cert = openssl_x509_parse(
'file://' . $this->
getClientCertPath())) && $cert && isset($cert[
'serialNumber']) && $cert[
'serialNumber']) {
689 $this->log->debug(
'Searial number is: ' . $cert[
'serialNumber']);
698 foreach ($lines as $line) {
699 if (strpos($line,
'Serial Number:') !==
false) {
701 $serial_line = explode(
':', $line);
702 $serial = trim($serial_line[1]);
706 if ($found && isset($serial)) {
722 $query =
'SELECT * FROM ecs_server ' .
723 'WHERE server_id = ' . $this->db->quote($this->
getServerId(),
'integer');
724 $res = $this->db->query($query);
729 $this->
setPort((
int) $row[
'port']);
736 if ($row[
'cert_serial']) {
740 $this->econtent_recipients = explode(
',', $row[
'econtent_rcp']);
741 $this->approval_recipients = explode(
',', $row[
'approval_rcp']);
742 $this->user_recipients = explode(
',', $row[
'user_rcp']);
756 $this->server_id = 0;
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@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.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...