'.PHP_EOL;
$xml .= ''.PHP_EOL;
$xml .= '' . PHP_EOL;
$xml .= $this->getSiteControl($configuration);
$xml .= $this->getAllowAccess($configuration);
$xml .= $this->getAllowIdentity($configuration);
$xml .= $this->getAllowHeader($configuration);
$xml .= "";
return $xml;
}
private function getSiteControl(array $conf)
{
$xml = '';
if (isset($conf['site-control'])) {
$xml = "\t".''.PHP_EOL;
}
return $xml;
}
private function getAllowAccess(array $conf)
{
$xml = '';
if (!isset($conf['allow-access-from'])) {
return $xml;
}
$allowAccess = $conf['allow-access-from'];
if (!is_array($allowAccess)) {
return $xml;
}
foreach ($allowAccess as $access) {
// domain is mandatory
if (!isset($access['domain'])) {
continue;
}
$domain = $access['domain'];
$secure = isset($access['secure']) ? $access['secure'] : false;
$ports = isset($access['to-ports']) ? $access['to-ports'] : false;
$xml .= "\t".''.PHP_EOL;
}
return $xml;
}
private function getAllowIdentity(array $conf)
{
$xml = '';
if (!isset($conf['allow-access-from-identity'])) {
return $xml;
}
$allowAccess = $conf['allow-access-from-identity'];
if (!is_array($allowAccess)) {
return $xml;
}
foreach ($allowAccess as $access) {
$algorithm = isset($access['fingerprint-algorithm']) ? $access['fingerprint-algorithm'] : false;
$fingerprint = isset($access['fingerprint']) ? $access['fingerprint'] : false;
// both are mandatory
if (!$algorithm || !$fingerprint) {
continue;
}
$xml .= "\t".''.PHP_EOL;
}
return $xml;
}
private function getAllowHeader(array $conf)
{
$xml = '';
if (!isset($conf['allow-http-request-headers-from'])) {
return $xml;
}
$allowHeaders = $conf['allow-http-request-headers-from'];
if (!is_array($allowHeaders)) {
return $xml;
}
foreach ($allowHeaders as $access) {
// domain & headers are mandatory
if (!isset($access['domain']) && !isset($access['headers'])) {
continue;
}
$secure = isset($access['secure']) ? $access['secure'] : false;
$xml .= "\t".''.PHP_EOL;
}
return $xml;
}
}