Skip to content

Commit

Permalink
Allow for multiple signing keys in metadata documents if entity has C…
Browse files Browse the repository at this point in the history
…ertData2 and/or CertData3 defined. Fixed #27.
  • Loading branch information
Boy Baukema committed Apr 11, 2014
1 parent d748737 commit 5cf8f96
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 38 deletions.
6 changes: 2 additions & 4 deletions library/EngineBlock/Corto/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,10 +413,8 @@ protected function _configureProxyServer(EngineBlock_Corto_ProxyServer $proxySer
$remoteEntities[$idpEntityId] = array();
}
$remoteEntities[$idpEntityId]['EntityID'] = $idpEntityId;
$remoteEntities[$idpEntityId]['certificates'] = array(
'public' => $application->getConfiguration()->encryption->key->public,
'private' => $application->getConfiguration()->encryption->key->private,
);
$remoteEntities[$idpEntityId]['certificates']['public'] = $application->getConfiguration()->encryption->key->public;
$remoteEntities[$idpEntityId]['certificates']['private'] = $application->getConfiguration()->encryption->key->private;
$remoteEntities[$idpEntityId]['NameIDFormats'] = array(
EngineBlock_Urn::SAML2_0_NAMEID_FORMAT_PERSISTENT,
EngineBlock_Urn::SAML2_0_NAMEID_FORMAT_TRANSIENT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,37 @@ public function mapTo(array $rootElement)
if (empty($publicCertificate)) {
return $rootElement;
}
$rootElement['md:KeyDescriptor'] = array(
array(
EngineBlock_Corto_XmlToArray::ATTRIBUTE_PFX . 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#',
EngineBlock_Corto_XmlToArray::ATTRIBUTE_PFX . 'use' => 'signing',
'ds:KeyInfo' => array(
'ds:X509Data' => array(
'ds:X509Certificate' => array(
EngineBlock_Corto_XmlToArray::VALUE_PFX => $this->_mapPem($publicCertificate),
),
),
),
),
/**
* https://jira.surfconext.nl/jira/browse/BACKLOG-874
*
* Encryption key is no longer provided to prevent the idp returning an encrypted response

array(
EngineBlock_Corto_XmlToArray::ATTRIBUTE_PFX . 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#',
EngineBlock_Corto_XmlToArray::ATTRIBUTE_PFX . 'use' => 'encryption',
'ds:KeyInfo' => array(
'ds:X509Data' => array(
'ds:X509Certificate' => array(
EngineBlock_Corto_XmlToArray::VALUE_PFX => $this->_mapPem($publicCertificate),
),
),
),
'md:EncryptionMethod' => array(
array(
EngineBlock_Corto_XmlToArray::ATTRIBUTE_PFX . 'Algorithm' => 'http://www.w3.org/2001/04/xmlenc#rsa-1_5',
$rootElement['md:KeyDescriptor'] = array($this->getSigningKeyMetadataForCert($publicCertificate));

if (isset($this->_entity['certificates']['public-fallback'])) {
$rootElement['md:KeyDescriptor'][] = $this->getSigningKeyMetadataForCert(
$this->_entity['certificates']['public-fallback']
);
}

if (isset($this->_entity['certificates']['public-fallback2'])) {
$rootElement['md:KeyDescriptor'][] = $this->getSigningKeyMetadataForCert(
$this->_entity['certificates']['public-fallback2']
);
}

return $rootElement;
}

protected function getSigningKeyMetadataForCert($publicCertificate)
{
return array(
EngineBlock_Corto_XmlToArray::ATTRIBUTE_PFX . 'xmlns:ds' => 'http://www.w3.org/2000/09/xmldsig#',
EngineBlock_Corto_XmlToArray::ATTRIBUTE_PFX . 'use' => 'signing',
'ds:KeyInfo' => array(
'ds:X509Data' => array(
'ds:X509Certificate' => array(
EngineBlock_Corto_XmlToArray::VALUE_PFX => $this->_mapPem($publicCertificate),
),
),
),
*/
);
return $rootElement;
}

protected function _mapPem($pemKey)
Expand Down
7 changes: 4 additions & 3 deletions library/EngineBlock/Corto/ServiceRegistry/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,10 @@ protected static function convertServiceRegistryEntityToCortoEntity($serviceRegi
}

// In general
$cortoEntity['certificates'] = array();
if (isset($serviceRegistryEntity['certData']) && $serviceRegistryEntity['certData']) {
$cortoEntity['certificates'] = array(
'public' => EngineBlock_X509Certificate::getPublicPemCertFromCertData($serviceRegistryEntity['certData']),
$cortoEntity['certificates']['public'] = EngineBlock_X509Certificate::getPublicPemCertFromCertData(
$serviceRegistryEntity['certData']
);
if (isset($serviceRegistryEntity['certData2']) && $serviceRegistryEntity['certData2']) {
$cortoEntity['certificates']['public-fallback'] = EngineBlock_X509Certificate::getPublicPemCertFromCertData(
Expand Down Expand Up @@ -436,4 +437,4 @@ protected static function _multiLang(&$cortoEntity, $serviceRegistryEntity, $map
}
}
}
}
}

0 comments on commit 5cf8f96

Please sign in to comment.