LDAP Account Manager

LAMCfgMain
in package

This class manages config.cfg.

Table of Contents

DATABASE_FILE_SYSTEM  = 'files'
store configuration on local file system
DATABASE_MYSQL  = 'mysql'
store configuration in MySQL database
ERROR_REPORTING_ALL  = 'all'
PHP error reporting setting as E_ALL
ERROR_REPORTING_DEFAULT  = 'default'
PHP error reporting setting as E_ALL & ~E_NOTICE
ERROR_REPORTING_SYSTEM  = 'system'
PHP error reporting setting from php.ini
LICENSE_WARNING_ALL  = 'all'
send license warnings via email + display on screen
LICENSE_WARNING_EMAIL  = 'email'
send license warnings via email
LICENSE_WARNING_NONE  = 'none'
no license warning
LICENSE_WARNING_SCREEN  = 'screen'
display license warnings on screen
MAIL_ATTRIBUTE_DEFAULT  = 'mail'
MAIL_BACKUP_ATTRIBUTE_DEFAULT  = 'passwordselfresetbackupmail'
SMS_ATTRIBUTES_DEFAULT  = 'mobileTelephoneNumber;mobile'
SMTP_NONE  = 'NONE'
No encryption for mail sending
SMTP_SSL  = 'SSL'
SSL encryption for mail sending
SMTP_TLS  = 'TLS'
TLS encryption for mail sending
$allowedHosts  : string
list of hosts which may access LAM
$allowedHostsSelfService  : string
list of hosts which may access LAM Pro self-service
$checkedRulesCount  : int
number of password rules that must match (-1 = all)
$configDatabaseName  : string
database name
$configDatabasePassword  : string
database password
$configDatabasePort  : string
database port
$configDatabaseServer  : string
database server name
$configDatabaseSSLCA  : string
database options
$configDatabaseType  : string
database type
$configDatabaseUser  : string
database user
$default  : string|null
Default profile
$errorReporting  : string
error reporting
$externalPwdCheckUrl  : string|null
external URL for password checking (e.g. https://domain.com/url/{SHA1})
$hideLoginErrorDetails  : string
$licenseEmailDateSent  : string
the license warning email was last sent for this expiration date
$licenseEmailFrom  : string
license warning email from address
$licenseEmailTo  : string
license warning email TO address(es) separated by ";"
$licenseWarningType  : string
type of license warning (email/screen/both/none)
$logDestination  : string
log destination ("SYSLOG":syslog, "/...":file, "NONE":none, "REMOTE":server:port)
$logLevel  : int
log level
$mailAttribute  : string
$mailBackupAttribute  : string
$mailEncryption  : string
$mailPassword  : string
mail server password
$mailServer  : string
mail server (server:port)
$mailUser  : string
mail server user
$passwordMinClasses  : int
minimum character classes (upper, lower, numeric, symbols)
$passwordMinLength  : int
minimum length for passwords
$passwordMinLower  : int
minimum lowercase characters
$passwordMinNumeric  : int
minimum numeric characters
$passwordMinSymbol  : int
minimum symbol characters
$passwordMinUpper  : int
minimum uppercase characters
$passwordMustNotContain3Chars  : string
password may contain more than 2 characters of user/first/last name
$passwordMustNotContainUser  : string
password may contain the user name
$sessionTimeout  : int
Time of inactivity before session times out (minutes)
$smsAccountId  : string
$smsApiKey  : string
$smsAttributes  : string
$smsDefaultCountryPrefix  : string
$smsFrom  : string
$smsProvider  : string
$smsRegion  : string
$smsSubject  : string
$smsToken  : string
$conffile  : string
path to config file
$delSSLCaCert  : bool
SSL certificate should be deleted on save()
$license  : string
license data
$moduleSettings  : string
database password
$password  : string|null
Password to change config.cfg
$persistenceSettings  : array<string|int, mixed>
$settings  : array<string|int, mixed>
$uploadedSSLCaCert  : string|null
uploaded SSL certificate that is stored to disk on save()
__construct()  : mixed
Loads preferences from config file
checkPassword()  : bool
Checks if the given password matches.
deleteSSLCaCert()  : void
Marks a single or all SSL CA certificate files for deletion.
exportCertificates()  : null|string
Returns the content of the server certificates file
exportData()  : array<string, string|string[]|int|bool|null>
Exports the configuration data.
getLicenseLines()  : array<string|int, string>
Returns the license key as multiple lines.
getLicenseWarningType()  : string
Returns the license warning type (screen/email/both/none).
getMailAttribute()  : string
Returns the mail attribute.
getMailBackupAttribute()  : string
Returns the mail backup attribute.
getModuleSettings()  : array<string, array<string, string>>
Returns a list of module settings.
getSmsAttributes()  : array<string|int, string>
Returns the SMS attributes.
getSSLCaCertificates()  : array<int, array<string, array<string|int, array<string|int, string>>>>
Returns a list of all CA certificates.
getSSLCaCertPath()  : string|null
Returns the path to the SSL CA certificate file that overrides the system certificates.
getSSLCaCertTempFileName()  : string|null
Returns the name of a temporary file in tmp that contains the SSL certificate.
hasPasswordSet()  : bool
Returns if the main config has a password set.
importCertificates()  : void
Imports the server certificates.
importData()  : void
Imports configuration data.
installSampleConfig()  : bool
Tries to copy the config file from sample config.
isConfigFileExisting()  : bool
Returns if the configuration file is existing.
isHideLoginErrorDetails()  : bool
Hide error details for failed logins.
isValidLogFilename()  : bool
Checks if the log filename is valid.
isWritable()  : bool
Returns if the configuration file is writable.
save()  : void
Saves the configuration to the persistence layer.
saveLocal()  : void
Saves preferences to config file config.cfg
sendLicenseWarningByEmail()  : bool
Returns if the license warning should be sent via email.
setLicenseLines()  : void
Sets the license key as multiple lines.
setModuleSettings()  : void
Sets the module settings.
setPassword()  : void
Sets a new config password.
showLicenseWarningOnScreen()  : bool
Returns if the license warning should be shown on screen.
uploadSSLCaCert()  : true|string
Uploads a new SSL CA cert.
wasLicenseWarningSent()  : bool
Returns if the license warning was already sent.
exportPersistenceData()  : array<string, string|string[]|int|bool|null>
Exports the configuration data, persistence settings only.
getInternalSSLCaCertFileName()  : string
Returns the file name that will be used internally to store the CA file.
getSSLCaCertificateContent()  : string|null
Returns the content of the certificate file or uploaded data.
hashPassword()  : string
Returns the hashed password.
loadFromDb()  : void
Loads the settings from the database.
reload()  : void
Reloads preferences from config file config.cfg
saveDb()  : void
Saves the config data to the database.
splitSSLCaCertificateContent()  : array<int, string>
Splits the certificate content into single PEM data chunks.

Constants

DATABASE_FILE_SYSTEM

store configuration on local file system

public mixed DATABASE_FILE_SYSTEM = 'files'

DATABASE_MYSQL

store configuration in MySQL database

public mixed DATABASE_MYSQL = 'mysql'

ERROR_REPORTING_ALL

PHP error reporting setting as E_ALL

public mixed ERROR_REPORTING_ALL = 'all'

ERROR_REPORTING_DEFAULT

PHP error reporting setting as E_ALL & ~E_NOTICE

public mixed ERROR_REPORTING_DEFAULT = 'default'

ERROR_REPORTING_SYSTEM

PHP error reporting setting from php.ini

public mixed ERROR_REPORTING_SYSTEM = 'system'

LICENSE_WARNING_ALL

send license warnings via email + display on screen

public mixed LICENSE_WARNING_ALL = 'all'

LICENSE_WARNING_EMAIL

send license warnings via email

public mixed LICENSE_WARNING_EMAIL = 'email'

LICENSE_WARNING_NONE

no license warning

public mixed LICENSE_WARNING_NONE = 'none'

LICENSE_WARNING_SCREEN

display license warnings on screen

public mixed LICENSE_WARNING_SCREEN = 'screen'

MAIL_ATTRIBUTE_DEFAULT

public mixed MAIL_ATTRIBUTE_DEFAULT = 'mail'

MAIL_BACKUP_ATTRIBUTE_DEFAULT

public mixed MAIL_BACKUP_ATTRIBUTE_DEFAULT = 'passwordselfresetbackupmail'

SMS_ATTRIBUTES_DEFAULT

public mixed SMS_ATTRIBUTES_DEFAULT = 'mobileTelephoneNumber;mobile'

SMTP_NONE

No encryption for mail sending

public mixed SMTP_NONE = 'NONE'

SMTP_SSL

SSL encryption for mail sending

public mixed SMTP_SSL = 'SSL'

SMTP_TLS

TLS encryption for mail sending

public mixed SMTP_TLS = 'TLS'

Properties

$allowedHosts

list of hosts which may access LAM

public string $allowedHosts = ""

$allowedHostsSelfService

list of hosts which may access LAM Pro self-service

public string $allowedHostsSelfService = ''

$checkedRulesCount

number of password rules that must match (-1 = all)

public int $checkedRulesCount = -1

$configDatabaseName

database name

public string $configDatabaseName = ''

$configDatabasePassword

database password

public string $configDatabasePassword = ''

$configDatabasePort

database port

public string $configDatabasePort = ''

$configDatabaseServer

database server name

public string $configDatabaseServer = ''

$configDatabaseSSLCA

database options

public string $configDatabaseSSLCA = ''

$configDatabaseType

database type

public string $configDatabaseType = self::DATABASE_FILE_SYSTEM

$configDatabaseUser

database user

public string $configDatabaseUser = ''

$default

Default profile

public string|null $default = \null

$errorReporting

error reporting

public string $errorReporting = self::ERROR_REPORTING_DEFAULT

$externalPwdCheckUrl

external URL for password checking (e.g. https://domain.com/url/{SHA1})

public string|null $externalPwdCheckUrl = \null

$hideLoginErrorDetails

public string $hideLoginErrorDetails = 'false'

hides detail messages for login errors

$licenseEmailDateSent

the license warning email was last sent for this expiration date

public string $licenseEmailDateSent = '0'

$licenseEmailFrom

license warning email from address

public string $licenseEmailFrom = ''

$licenseEmailTo

license warning email TO address(es) separated by ";"

public string $licenseEmailTo = ''

$licenseWarningType

type of license warning (email/screen/both/none)

public string $licenseWarningType = ''

$logDestination

log destination ("SYSLOG":syslog, "/...":file, "NONE":none, "REMOTE":server:port)

public string $logDestination = "SYSLOG"

$logLevel

log level

public int $logLevel = \LOG_NOTICE

$mailAttribute

public string $mailAttribute = self::MAIL_ATTRIBUTE_DEFAULT

attribute to use for user mail address

$mailBackupAttribute

public string $mailBackupAttribute = self::MAIL_BACKUP_ATTRIBUTE_DEFAULT

attribute to use for user backup mail address

$mailEncryption

public string $mailEncryption = ''

encryption type for SMTP connection

$mailPassword

mail server password

public string $mailPassword = ''

$mailServer

mail server (server:port)

public string $mailServer = ''

$mailUser

mail server user

public string $mailUser = ''

$passwordMinClasses

minimum character classes (upper, lower, numeric, symbols)

public int $passwordMinClasses = 0

$passwordMinLength

minimum length for passwords

public int $passwordMinLength = 0

$passwordMinLower

minimum lowercase characters

public int $passwordMinLower = 0

$passwordMinNumeric

minimum numeric characters

public int $passwordMinNumeric = 0

$passwordMinSymbol

minimum symbol characters

public int $passwordMinSymbol = 0

$passwordMinUpper

minimum uppercase characters

public int $passwordMinUpper = 0

$passwordMustNotContain3Chars

password may contain more than 2 characters of user/first/last name

public string $passwordMustNotContain3Chars = 'false'

$passwordMustNotContainUser

password may contain the user name

public string $passwordMustNotContainUser = 'false'

$sessionTimeout

Time of inactivity before session times out (minutes)

public int $sessionTimeout = 30

$smsAccountId

public string $smsAccountId = ''

SMS account ID

$smsApiKey

public string $smsApiKey = ''

SMS API key

$smsAttributes

public string $smsAttributes = self::SMS_ATTRIBUTES_DEFAULT

SMS number attributes

$smsDefaultCountryPrefix

public string $smsDefaultCountryPrefix = ''

default country prefix

$smsFrom

public string $smsFrom = ''

SMS from

$smsProvider

public string $smsProvider = ''

SMS provider ID

$smsRegion

public string $smsRegion = ''

SMS region

$smsSubject

public string $smsSubject = ''

SMS subject line

$smsToken

public string $smsToken = ''

SMS token

$conffile

path to config file

private string $conffile

$delSSLCaCert

SSL certificate should be deleted on save()

private bool $delSSLCaCert = \false

$license

license data

private string $license = ''

$moduleSettings

database password

private string $moduleSettings = ''

$password

Password to change config.cfg

private string|null $password = \null

$persistenceSettings

private array<string|int, mixed> $persistenceSettings = ['configDatabaseType', 'configDatabaseServer', 'configDatabasePort', 'configDatabaseName', 'configDatabaseUser', 'configDatabasePassword', 'configDatabaseSSLCA', 'license']

persistence settings are always stored on local file system

$settings

private array<string|int, mixed> $settings = ["password", "default", "sessionTimeout", "hideLoginErrorDetails", "logLevel", "logDestination", "allowedHosts", "passwordMinLength", "passwordMinUpper", "passwordMinLower", "passwordMinNumeric", "passwordMinClasses", "passwordMinSymbol", 'checkedRulesCount', 'passwordMustNotContainUser', 'passwordMustNotContain3Chars', 'externalPwdCheckUrl', 'errorReporting', 'allowedHostsSelfService', 'license', 'licenseEmailFrom', 'licenseEmailTo', 'licenseWarningType', 'licenseEmailDateSent', 'mailServer', 'mailUser', 'mailPassword', 'mailEncryption', 'mailAttribute', 'mailBackupAttribute', 'configDatabaseType', 'configDatabaseServer', 'configDatabasePort', 'configDatabaseName', 'configDatabaseUser', 'configDatabasePassword', 'configDatabaseSSLCA', 'moduleSettings', 'smsProvider', 'smsApiKey', 'smsToken', 'smsAccountId', 'smsRegion', 'smsFrom', 'smsSubject', 'smsAttributes', 'smsDefaultCountryPrefix']

list of data fields to save in config file

$uploadedSSLCaCert

uploaded SSL certificate that is stored to disk on save()

private string|null $uploadedSSLCaCert = \null

Methods

__construct()

Loads preferences from config file

public __construct([string|null $fileName = null ]) : mixed
Parameters
$fileName : string|null = null

file path for config file

Return values
mixed

checkPassword()

Checks if the given password matches.

public checkPassword(string $password) : bool
Parameters
$password : string

password

Return values
bool

true, if password matches

deleteSSLCaCert()

Marks a single or all SSL CA certificate files for deletion.

public deleteSSLCaCert([int|null $index = null ]) : void

The changes take effect on save().

Parameters
$index : int|null = null

certificate index, null deletes all certificates (default: null)

Return values
void

exportCertificates()

Returns the content of the server certificates file

public exportCertificates() : null|string
Return values
null|string

certificates

exportData()

Exports the configuration data.

public exportData([bool $skipPersistenceSettings = false ]) : array<string, string|string[]|int|bool|null>
Parameters
$skipPersistenceSettings : bool = false

do not include persistence settings

Return values
array<string, string|string[]|int|bool|null>

config data

getLicenseLines()

Returns the license key as multiple lines.

public getLicenseLines() : array<string|int, string>
Return values
array<string|int, string>

license

getLicenseWarningType()

Returns the license warning type (screen/email/both/none).

public getLicenseWarningType() : string
Return values
string

warning type

getMailAttribute()

Returns the mail attribute.

public getMailAttribute() : string
Return values
string

attribute name

getMailBackupAttribute()

Returns the mail backup attribute.

public getMailBackupAttribute() : string
Return values
string

attribute name

getModuleSettings()

Returns a list of module settings.

public getModuleSettings() : array<string, array<string, string>>
Return values
array<string, array<string, string>>

module settings

getSmsAttributes()

Returns the SMS attributes.

public getSmsAttributes() : array<string|int, string>
Return values
array<string|int, string>

attribute names

getSSLCaCertificates()

Returns a list of all CA certificates.

public getSSLCaCertificates() : array<int, array<string, array<string|int, array<string|int, string>>>>
Return values
array<int, array<string, array<string|int, array<string|int, string>>>>

list of certificates as output of openssl_x509_parse()

getSSLCaCertPath()

Returns the path to the SSL CA certificate file that overrides the system certificates.

public getSSLCaCertPath() : string|null
Return values
string|null

path to certificate file or null if certificate is not overridden

getSSLCaCertTempFileName()

Returns the name of a temporary file in tmp that contains the SSL certificate.

public getSSLCaCertTempFileName() : string|null

The file contains either the stored data in serverCerts or the uploaded data.

Return values
string|null

file name or null if no certificate was set

hasPasswordSet()

Returns if the main config has a password set.

public hasPasswordSet() : bool
Return values
bool

password is set

importCertificates()

Imports the server certificates.

public importCertificates(null|string $certsContent) : void
Parameters
$certsContent : null|string

certificates

Tags
throws
LAMException

write to file failed

Return values
void

importData()

Imports configuration data.

public importData(array<string, string|string[]|int|bool|null|object> $data) : void
Parameters
$data : array<string, string|string[]|int|bool|null|object>

config data

Tags
throws
LAMException

import error

Return values
void

installSampleConfig()

Tries to copy the config file from sample config.

public installSampleConfig() : bool
Return values
bool

copied

isConfigFileExisting()

Returns if the configuration file is existing.

public isConfigFileExisting() : bool
Return values
bool

exists

isHideLoginErrorDetails()

Hide error details for failed logins.

public isHideLoginErrorDetails() : bool
Return values
bool

hide details

isValidLogFilename()

Checks if the log filename is valid.

public static isValidLogFilename(string $path) : bool
Parameters
$path : string

path

Return values
bool

is valid

isWritable()

Returns if the configuration file is writable.

public isWritable() : bool
Return values
bool

writable

save()

Saves the configuration to the persistence layer.

public save() : void
Tags
throws
LAMException

error saving config

Return values
void

saveLocal()

Saves preferences to config file config.cfg

public saveLocal(bool $persistenceOnly) : void
Parameters
$persistenceOnly : bool

store only persistence related data

Tags
throws
LAMException

error saving config

Return values
void

sendLicenseWarningByEmail()

Returns if the license warning should be sent via email.

public sendLicenseWarningByEmail() : bool
Return values
bool

send via email

setLicenseLines()

Sets the license key as multiple lines.

public setLicenseLines(array<string|int, string> $licenseLines) : void
Parameters
$licenseLines : array<string|int, string>

license lines

Return values
void

setModuleSettings()

Sets the module settings.

public setModuleSettings(array<string, array<string, string>> $settings) : void
Parameters
$settings : array<string, array<string, string>>

module settings

Return values
void

setPassword()

Sets a new config password.

public setPassword(string $password) : void
Parameters
$password : string

new password

Return values
void

showLicenseWarningOnScreen()

Returns if the license warning should be shown on screen.

public showLicenseWarningOnScreen() : bool
Return values
bool

show on screen

uploadSSLCaCert()

Uploads a new SSL CA cert.

public uploadSSLCaCert(string $cert) : true|string
Parameters
$cert : string

file content in DER/PEM format

Return values
true|string

true if format is correct, error message if file is not accepted

wasLicenseWarningSent()

Returns if the license warning was already sent.

public wasLicenseWarningSent(int $timeStamp) : bool
Parameters
$timeStamp : int

time stamp

Return values
bool

exportPersistenceData()

Exports the configuration data, persistence settings only.

private exportPersistenceData() : array<string, string|string[]|int|bool|null>
Return values
array<string, string|string[]|int|bool|null>

config data

getInternalSSLCaCertFileName()

Returns the file name that will be used internally to store the CA file.

private getInternalSSLCaCertFileName() : string
Return values
string

file name

getSSLCaCertificateContent()

Returns the content of the certificate file or uploaded data.

private getSSLCaCertificateContent() : string|null
Return values
string|null

null or certificate content

hashPassword()

Returns the hashed password.

private hashPassword(string $password, string $salt) : string
Parameters
$password : string

password

$salt : string

salt

Return values
string

hash value

loadFromDb()

Loads the settings from the database.

private loadFromDb() : void

Persistence settings are ignored as they must be on local file system.

Tags
throws
LAMException

error reading config

Return values
void

reload()

Reloads preferences from config file config.cfg

private reload() : void
Tags
throws
LAMException

error reading config

Return values
void

saveDb()

Saves the config data to the database.

private saveDb() : void
Return values
void

splitSSLCaCertificateContent()

Splits the certificate content into single PEM data chunks.

private splitSSLCaCertificateContent(string $content) : array<int, string>
Parameters
$content : string

PEM file content

Return values
array<int, string>

one element for each certificate chunk

Search results