diff --git a/setup/config/authsources_cie_private.tpl b/setup/config/authsources_cie_private.tpl index fe2aa50..0c3cc4c 100644 --- a/setup/config/authsources_cie_private.tpl +++ b/setup/config/authsources_cie_private.tpl @@ -60,13 +60,16 @@ 'telephoneNumber' => {{ORGANIZATIONTELEPHONENUMBER}}, 'extensions' => array ( - 'Private' => NULL, - 'VATNumber' => {{ORGANIZATIONCODE}}, - 'FiscalCode' => {{ORGANIZATIONFISCALCODE}}, - 'NACE2Code' => {{ORGANIZATIONNACE2CODE}}, - 'Municipality' => {{ORGANIZATIONMUNICIPALITY}}, - 'Province' => {{ORGANIZATIONPROVINCE}}, - 'Country' => {{ORGANIZATIONCOUNTRY}}, + 'ns' => 'cie:https://www.cartaidentita.interno.gov.it/saml-extensions', + 'elements' => array( + 'cie:Private' => NULL, + 'cie:VATNumber' => {{ORGANIZATIONCODE}}, + 'cie:FiscalCode' => {{ORGANIZATIONFISCALCODE}}, + 'cie:NACE2Code' => {{ORGANIZATIONNACE2CODE}}, + 'cie:Municipality' => {{ORGANIZATIONMUNICIPALITY}}, + 'cie:Province' => {{ORGANIZATIONPROVINCE}}, + 'cie:Country' => {{ORGANIZATIONCOUNTRY}}, + ) ), ), ) diff --git a/setup/config/authsources_cie_public.tpl b/setup/config/authsources_cie_public.tpl index ca026ff..ee08064 100644 --- a/setup/config/authsources_cie_public.tpl +++ b/setup/config/authsources_cie_public.tpl @@ -60,11 +60,14 @@ 'telephoneNumber' => {{ORGANIZATIONTELEPHONENUMBER}}, 'extensions' => array ( - 'Public' => NULL, - 'IPACode' => {{ORGANIZATIONCODE}}, - 'Municipality' => {{ORGANIZATIONMUNICIPALITY}}, - 'Province' => {{ORGANIZATIONPROVINCE}}, - 'Country' => {{ORGANIZATIONCOUNTRY}}, + 'ns' => 'cie:https://www.cartaidentita.interno.gov.it/saml-extensions', + 'elements' => array( + 'cie:Public' => NULL, + 'cie:IPACode' => {{ORGANIZATIONCODE}}, + 'cie:Municipality' => {{ORGANIZATIONMUNICIPALITY}}, + 'cie:Province' => {{ORGANIZATIONPROVINCE}}, + 'cie:Country' => {{ORGANIZATIONCOUNTRY}}, + ) ), ), ) diff --git a/setup/simplesamlphp/saml2/src/SAML2/XML/md/ContactPerson.php b/setup/simplesamlphp/saml2/src/SAML2/XML/md/ContactPerson.php index 0100c48..2737d08 100644 --- a/setup/simplesamlphp/saml2/src/SAML2/XML/md/ContactPerson.php +++ b/setup/simplesamlphp/saml2/src/SAML2/XML/md/ContactPerson.php @@ -102,9 +102,13 @@ public function __construct(DOMElement $xml = null) $this->setContactType($xml->getAttribute('contactType')); if ($xml->hasAttribute('entityType')) { - // SPID Entity Type (Avviso SPID n.19 v.4) + // SPID Entity Type (Avviso SPID n.19 v.4) if(substr($xml->getAttribute('entityType'), 0, 5)=='spid:') { $this->setEntityType($xml->getAttribute('entityType'), 'spid:https://spid.gov.it/saml-extensions'); + + } else if(substr($xml->getAttribute('entityType'), 0, 4)=='cie:') { + $this->setEntityType($xml->getAttribute('entityType'), 'cie:https://www.cartaidentita.interno.gov.it/saml-extensions'); + } else { $this->setEntityType($xml->getAttribute('entityType')); } @@ -452,7 +456,17 @@ public function toXML(DOMElement $parent) : DOMElement $e->setAttribute('contactType', $this->getContactType()); if ($this->entityType != null) { - $attribute = ($this->entityTypeNS=='spid:https://spid.gov.it/saml-extensions')? 'spid:entityType' : 'entityType'; + + if($this->entityTypeNS=='spid:https://spid.gov.it/saml-extensions') { + $attribute = 'spid:entityType'; + + } else if($this->entityTypeNS=='cie:https://www.cartaidentita.interno.gov.it/saml-extensions') { + $attribute = 'cie:entityType'; + + } else { + $attribute = 'entityType'; + } + $e->setAttribute($attribute, $this->entityType); } diff --git a/setup/simplesamlphp/saml2/src/SAML2/XML/md/EntityDescriptor.php b/setup/simplesamlphp/saml2/src/SAML2/XML/md/EntityDescriptor.php index fd41e52..911fe53 100644 --- a/setup/simplesamlphp/saml2/src/SAML2/XML/md/EntityDescriptor.php +++ b/setup/simplesamlphp/saml2/src/SAML2/XML/md/EntityDescriptor.php @@ -107,6 +107,11 @@ public function __construct(DOMElement $xml = null) $this->ns['spid'] = $xml->getAttribute('xmlns:spid'); } + // get cie namespace if exists + if($xml->hasAttribute('xmlns:cie')) { + $this->ns['cie'] = $xml->getAttribute('xmlns:cie'); + } + if (!$xml->hasAttribute('entityID')) { throw new \Exception('Missing required attribute entityID on EntityDescriptor.'); } @@ -506,6 +511,11 @@ public function toXML(DOMElement $parent = null) : DOMElement $e->setAttribute('xmlns:spid', $this->ns['spid']); } + // set cie namespace if exists + if ($this->ns['cie'] !== null) { + $e->setAttribute('xmlns:cie', $this->ns['cie']); + } + $e->setAttribute('entityID', $this->entityID); if ($this->ID !== null) { diff --git a/setup/simplesamlphp/simplesamlphp/lib/SimpleSAML/Metadata/SAMLBuilder.php b/setup/simplesamlphp/simplesamlphp/lib/SimpleSAML/Metadata/SAMLBuilder.php index 5d9715e..5a38742 100644 --- a/setup/simplesamlphp/simplesamlphp/lib/SimpleSAML/Metadata/SAMLBuilder.php +++ b/setup/simplesamlphp/simplesamlphp/lib/SimpleSAML/Metadata/SAMLBuilder.php @@ -823,6 +823,7 @@ public function addContact($type, $details) $e = new \SAML2\XML\md\ContactPerson(); $e->setContactType($type); + // OLD if(isset($details['spidEntityType'])) { $this->entityDescriptor->setNamespace('spid', 'https://spid.gov.it/saml-extensions'); $e->setEntityType('spid:'.$details['spidEntityType'], 'spid:https://spid.gov.it/saml-extensions'); @@ -897,8 +898,11 @@ public function addContact($type, $details) if (isset($details['extensions'])) { $ns = $details['extensions']['ns']; - if(substr($ns, 0, 5)=='spid:') { - $this->entityDescriptor->setNamespace('spid', 'https://spid.gov.it/saml-extensions'); + + if($ns!=null) { + $nsval = explode(':', $ns, 2); + if(count($nsval)!=2) throw new \Exception('ns must be of type ns:val'); + $this->entityDescriptor->setNamespace($nsval[0], $nsval[1]); } foreach($details['extensions']['elements'] as $e_key => $e_val) {