예제 #1
0
 /**
  * Add this IDPSSODescriptor to an EntityDescriptor.
  *
  * @param \DOMElement $parent The EntityDescriptor we should append this AuthnAuthorityDescriptor to.
  * @return \DOMElement
  */
 public function toXML(\DOMElement $parent)
 {
     assert('is_array($this->AuthnQueryService)');
     assert('!empty($this->AuthnQueryService)');
     assert('is_array($this->AssertionIDRequestService)');
     assert('is_array($this->NameIDFormat)');
     $e = parent::toXML($parent);
     foreach ($this->AuthnQueryService as $ep) {
         $ep->toXML($e, 'md:AuthnQueryService');
     }
     foreach ($this->AssertionIDRequestService as $ep) {
         $ep->toXML($e, 'md:AssertionIDRequestService');
     }
     Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', false, $this->NameIDFormat);
     return $e;
 }
예제 #2
0
 /**
  * Convert this element to XML.
  *
  * @param \DOMElement $parent The element we should append to.
  * @return \DOMElement
  */
 public function toXML(\DOMElement $parent)
 {
     assert('is_string($this->registrationAuthority)');
     assert('is_int($this->registrationInstant) || is_null($this->registrationInstant)');
     assert('is_array($this->RegistrationPolicy)');
     if (empty($this->registrationAuthority)) {
         throw new \Exception('Missing required registration authority.');
     }
     $doc = $parent->ownerDocument;
     $e = $doc->createElementNS(Common::NS_MDRPI, 'mdrpi:RegistrationInfo');
     $parent->appendChild($e);
     $e->setAttribute('registrationAuthority', $this->registrationAuthority);
     if ($this->registrationInstant !== null) {
         $e->setAttribute('registrationInstant', gmdate('Y-m-d\\TH:i:s\\Z', $this->registrationInstant));
     }
     Utils::addStrings($e, Common::NS_MDRPI, 'mdrpi:RegistrationPolicy', true, $this->RegistrationPolicy);
     return $e;
 }
예제 #3
0
 /**
  * Convert this Organization to XML.
  *
  * @param  \DOMElement $parent The element we should add this organization to.
  * @return \DOMElement This Organization-element.
  */
 public function toXML(\DOMElement $parent)
 {
     assert('is_array($this->Extensions)');
     assert('is_array($this->OrganizationName)');
     assert('!empty($this->OrganizationName)');
     assert('is_array($this->OrganizationDisplayName)');
     assert('!empty($this->OrganizationDisplayName)');
     assert('is_array($this->OrganizationURL)');
     assert('!empty($this->OrganizationURL)');
     $doc = $parent->ownerDocument;
     $e = $doc->createElementNS(Constants::NS_MD, 'md:Organization');
     $parent->appendChild($e);
     Extensions::addList($e, $this->Extensions);
     Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationName', true, $this->OrganizationName);
     Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationDisplayName', true, $this->OrganizationDisplayName);
     Utils::addStrings($e, Constants::NS_MD, 'md:OrganizationURL', true, $this->OrganizationURL);
     return $e;
 }
예제 #4
0
 /**
  * Convert this element to XML.
  *
  * @param \DOMElement $parent The element we should append to.
  * @return \DOMElement
  */
 public function toXML(\DOMElement $parent)
 {
     assert('is_string($this->publisher)');
     assert('is_int($this->creationInstant) || is_null($this->creationInstant)');
     assert('is_string($this->publicationId) || is_null($this->publicationId)');
     assert('is_array($this->UsagePolicy)');
     $doc = $parent->ownerDocument;
     $e = $doc->createElementNS(Common::NS_MDRPI, 'mdrpi:PublicationInfo');
     $parent->appendChild($e);
     $e->setAttribute('publisher', $this->publisher);
     if ($this->creationInstant !== null) {
         $e->setAttribute('creationInstant', gmdate('Y-m-d\\TH:i:s\\Z', $this->creationInstant));
     }
     if ($this->publicationId !== null) {
         $e->setAttribute('publicationId', $this->publicationId);
     }
     Utils::addStrings($e, Common::NS_MDRPI, 'mdrpi:UsagePolicy', true, $this->UsagePolicy);
     return $e;
 }
예제 #5
0
 /**
  * Convert this DiscoHints to XML.
  *
  * @param \DOMElement $parent The element we should append to.
  * @return \DOMElement|null
  */
 public function toXML(\DOMElement $parent)
 {
     assert('is_array($this->IPHint)');
     assert('is_array($this->DomainHint)');
     assert('is_array($this->GeolocationHint)');
     assert('is_array($this->children)');
     if (!empty($this->IPHint) || !empty($this->DomainHint) || !empty($this->GeolocationHint) || !empty($this->children)) {
         $doc = $parent->ownerDocument;
         $e = $doc->createElementNS(self::NS, 'mdui:DiscoHints');
         $parent->appendChild($e);
         if (!empty($this->children)) {
             foreach ($this->children as $child) {
                 $child->toXML($e);
             }
         }
         Utils::addStrings($e, self::NS, 'mdui:IPHint', false, $this->IPHint);
         Utils::addStrings($e, self::NS, 'mdui:DomainHint', false, $this->DomainHint);
         Utils::addStrings($e, self::NS, 'mdui:GeolocationHint', false, $this->GeolocationHint);
         return $e;
     }
     return null;
 }
예제 #6
0
 /**
  * Convert this ContactPerson to XML.
  *
  * @param  \DOMElement $parent The element we should add this contact to.
  * @return \DOMElement The new ContactPerson-element.
  */
 public function toXML(\DOMElement $parent)
 {
     assert('is_string($this->contactType)');
     assert('is_array($this->Extensions)');
     assert('is_null($this->Company) || is_string($this->Company)');
     assert('is_null($this->GivenName) || is_string($this->GivenName)');
     assert('is_null($this->SurName) || is_string($this->SurName)');
     assert('is_array($this->EmailAddress)');
     assert('is_array($this->TelephoneNumber)');
     $doc = $parent->ownerDocument;
     $e = $doc->createElementNS(Constants::NS_MD, 'md:ContactPerson');
     $parent->appendChild($e);
     $e->setAttribute('contactType', $this->contactType);
     Extensions::addList($e, $this->Extensions);
     if (isset($this->Company)) {
         Utils::addString($e, Constants::NS_MD, 'md:Company', $this->Company);
     }
     if (isset($this->GivenName)) {
         Utils::addString($e, Constants::NS_MD, 'md:GivenName', $this->GivenName);
     }
     if (isset($this->SurName)) {
         Utils::addString($e, Constants::NS_MD, 'md:SurName', $this->SurName);
     }
     if (!empty($this->EmailAddress)) {
         Utils::addStrings($e, Constants::NS_MD, 'md:EmailAddress', false, $this->EmailAddress);
     }
     if (!empty($this->TelephoneNumber)) {
         Utils::addStrings($e, Constants::NS_MD, 'md:TelephoneNumber', false, $this->TelephoneNumber);
     }
     return $e;
 }
예제 #7
0
 /**
  * Add this SSODescriptorType to an EntityDescriptor.
  *
  * @param  \DOMElement $parent The EntityDescriptor we should append this SSODescriptorType to.
  * @return \DOMElement The generated SSODescriptor DOMElement.
  */
 protected function toXML(\DOMElement $parent)
 {
     assert('is_array($this->ArtifactResolutionService)');
     assert('is_array($this->SingleLogoutService)');
     assert('is_array($this->ManageNameIDService)');
     assert('is_array($this->NameIDFormat)');
     $e = parent::toXML($parent);
     foreach ($this->ArtifactResolutionService as $ep) {
         $ep->toXML($e, 'md:ArtifactResolutionService');
     }
     foreach ($this->SingleLogoutService as $ep) {
         $ep->toXML($e, 'md:SingleLogoutService');
     }
     foreach ($this->ManageNameIDService as $ep) {
         $ep->toXML($e, 'md:ManageNameIDService');
     }
     Utils::addStrings($e, Constants::NS_MD, 'md:NameIDFormat', false, $this->NameIDFormat);
     return $e;
 }
예제 #8
0
 /**
  * Add a AuthnStatement-node to the assertion.
  *
  * @param \DOMElement $root The assertion element we should add the authentication statement to.
  */
 private function addAuthnStatement(\DOMElement $root)
 {
     if ($this->authnInstant === null || $this->authnContextClassRef === null && $this->authnContextDecl === null && $this->authnContextDeclRef === null) {
         /* No authentication context or AuthnInstant => no authentication statement. */
         return;
     }
     $document = $root->ownerDocument;
     $authnStatementEl = $document->createElementNS(Constants::NS_SAML, 'saml:AuthnStatement');
     $root->appendChild($authnStatementEl);
     $authnStatementEl->setAttribute('AuthnInstant', gmdate('Y-m-d\\TH:i:s\\Z', $this->authnInstant));
     if ($this->sessionNotOnOrAfter !== null) {
         $authnStatementEl->setAttribute('SessionNotOnOrAfter', gmdate('Y-m-d\\TH:i:s\\Z', $this->sessionNotOnOrAfter));
     }
     if ($this->sessionIndex !== null) {
         $authnStatementEl->setAttribute('SessionIndex', $this->sessionIndex);
     }
     $authnContextEl = $document->createElementNS(Constants::NS_SAML, 'saml:AuthnContext');
     $authnStatementEl->appendChild($authnContextEl);
     if (!empty($this->authnContextClassRef)) {
         Utils::addString($authnContextEl, Constants::NS_SAML, 'saml:AuthnContextClassRef', $this->authnContextClassRef);
     }
     if (!empty($this->authnContextDecl)) {
         $this->authnContextDecl->toXML($authnContextEl);
     }
     if (!empty($this->authnContextDeclRef)) {
         Utils::addString($authnContextEl, Constants::NS_SAML, 'saml:AuthnContextDeclRef', $this->authnContextDeclRef);
     }
     Utils::addStrings($authnContextEl, Constants::NS_SAML, 'saml:AuthenticatingAuthority', false, $this->AuthenticatingAuthority);
 }
예제 #9
0
 /**
  * Convert this authentication request to an XML element.
  *
  * @return \DOMElement This authentication request.
  */
 public function toUnsignedXML()
 {
     $root = parent::toUnsignedXML();
     if ($this->forceAuthn) {
         $root->setAttribute('ForceAuthn', 'true');
     }
     if ($this->ProviderName !== null) {
         $root->setAttribute('ProviderName', $this->ProviderName);
     }
     if ($this->isPassive) {
         $root->setAttribute('IsPassive', 'true');
     }
     if ($this->assertionConsumerServiceIndex !== null) {
         $root->setAttribute('AssertionConsumerServiceIndex', $this->assertionConsumerServiceIndex);
     } else {
         if ($this->assertionConsumerServiceURL !== null) {
             $root->setAttribute('AssertionConsumerServiceURL', $this->assertionConsumerServiceURL);
         }
         if ($this->protocolBinding !== null) {
             $root->setAttribute('ProtocolBinding', $this->protocolBinding);
         }
     }
     if ($this->attributeConsumingServiceIndex !== null) {
         $root->setAttribute('AttributeConsumingServiceIndex', $this->attributeConsumingServiceIndex);
     }
     $this->addSubject($root);
     if (!empty($this->nameIdPolicy)) {
         $nameIdPolicy = $this->document->createElementNS(Constants::NS_SAMLP, 'NameIDPolicy');
         if (array_key_exists('Format', $this->nameIdPolicy)) {
             $nameIdPolicy->setAttribute('Format', $this->nameIdPolicy['Format']);
         }
         if (array_key_exists('SPNameQualifier', $this->nameIdPolicy)) {
             $nameIdPolicy->setAttribute('SPNameQualifier', $this->nameIdPolicy['SPNameQualifier']);
         }
         if (array_key_exists('AllowCreate', $this->nameIdPolicy) && is_bool($this->nameIdPolicy['AllowCreate'])) {
             $nameIdPolicy->setAttribute('AllowCreate', $this->nameIdPolicy['AllowCreate'] ? 'true' : 'false');
         }
         $root->appendChild($nameIdPolicy);
     }
     $rac = $this->requestedAuthnContext;
     if (!empty($rac) && !empty($rac['AuthnContextClassRef'])) {
         $e = $this->document->createElementNS(Constants::NS_SAMLP, 'RequestedAuthnContext');
         $root->appendChild($e);
         if (isset($rac['Comparison']) && $rac['Comparison'] !== Constants::COMPARISON_EXACT) {
             $e->setAttribute('Comparison', $rac['Comparison']);
         }
         foreach ($rac['AuthnContextClassRef'] as $accr) {
             Utils::addString($e, Constants::NS_SAML, 'AuthnContextClassRef', $accr);
         }
     }
     if ($this->ProxyCount !== null || count($this->IDPList) > 0 || count($this->RequesterID) > 0) {
         $scoping = $this->document->createElementNS(Constants::NS_SAMLP, 'Scoping');
         $root->appendChild($scoping);
         if ($this->ProxyCount !== null) {
             $scoping->setAttribute('ProxyCount', $this->ProxyCount);
         }
         if (count($this->IDPList) > 0) {
             $idplist = $this->document->createElementNS(Constants::NS_SAMLP, 'IDPList');
             foreach ($this->IDPList as $provider) {
                 $idpEntry = $this->document->createElementNS(Constants::NS_SAMLP, 'IDPEntry');
                 if (is_string($provider)) {
                     $idpEntry->setAttribute('ProviderID', $provider);
                 } elseif (is_array($provider)) {
                     foreach ($provider as $attribute => $value) {
                         if (in_array($attribute, array('ProviderID', 'Loc', 'Name'))) {
                             $idpEntry->setAttribute($attribute, $value);
                         }
                     }
                 }
                 $idplist->appendChild($idpEntry);
             }
             $scoping->appendChild($idplist);
         }
         if (count($this->RequesterID) > 0) {
             Utils::addStrings($scoping, Constants::NS_SAMLP, 'RequesterID', false, $this->RequesterID);
         }
     }
     return $root;
 }
예제 #10
0
 /**
  * Convert to \DOMElement.
  *
  * @param \DOMElement $parent The element we should append this AttributeConsumingService to.
  * @return \DOMElement
  */
 public function toXML(\DOMElement $parent)
 {
     assert('is_int($this->index)');
     assert('is_null($this->isDefault) || is_bool($this->isDefault)');
     assert('is_array($this->ServiceName)');
     assert('is_array($this->ServiceDescription)');
     assert('is_array($this->RequestedAttribute)');
     $doc = $parent->ownerDocument;
     $e = $doc->createElementNS(Constants::NS_MD, 'md:AttributeConsumingService');
     $parent->appendChild($e);
     $e->setAttribute('index', (string) $this->index);
     if ($this->isDefault === true) {
         $e->setAttribute('isDefault', 'true');
     } elseif ($this->isDefault === false) {
         $e->setAttribute('isDefault', 'false');
     }
     Utils::addStrings($e, Constants::NS_MD, 'md:ServiceName', true, $this->ServiceName);
     Utils::addStrings($e, Constants::NS_MD, 'md:ServiceDescription', true, $this->ServiceDescription);
     foreach ($this->RequestedAttribute as $ra) {
         $ra->toXML($e);
     }
     return $e;
 }
예제 #11
0
 /**
  * Add this IDPSSODescriptor to an EntityDescriptor.
  *
  * @param \DOMElement $parent The EntityDescriptor we should append this IDPSSODescriptor to.
  * @return \DOMElement
  */
 public function toXML(\DOMElement $parent)
 {
     assert('is_null($this->WantAuthnRequestsSigned) || is_bool($this->WantAuthnRequestsSigned)');
     assert('is_array($this->SingleSignOnService)');
     assert('is_array($this->NameIDMappingService)');
     assert('is_array($this->AssertionIDRequestService)');
     assert('is_array($this->AttributeProfile)');
     assert('is_array($this->Attribute)');
     $e = parent::toXML($parent);
     if ($this->WantAuthnRequestsSigned === true) {
         $e->setAttribute('WantAuthnRequestsSigned', 'true');
     } elseif ($this->WantAuthnRequestsSigned === false) {
         $e->setAttribute('WantAuthnRequestsSigned', 'false');
     }
     foreach ($this->SingleSignOnService as $ep) {
         $ep->toXML($e, 'md:SingleSignOnService');
     }
     foreach ($this->NameIDMappingService as $ep) {
         $ep->toXML($e, 'md:NameIDMappingService');
     }
     foreach ($this->AssertionIDRequestService as $ep) {
         $ep->toXML($e, 'md:AssertionIDRequestService');
     }
     Utils::addStrings($e, Constants::NS_MD, 'md:AttributeProfile', false, $this->AttributeProfile);
     foreach ($this->Attribute as $a) {
         $a->toXML($e);
     }
     return $e;
 }
예제 #12
0
파일: UIInfo.php 프로젝트: SysBind/saml2
 /**
  * Convert this UIInfo to XML.
  *
  * @param \DOMElement $parent The element we should append to.
  * @return \DOMElement|null
  */
 public function toXML(\DOMElement $parent)
 {
     assert('is_array($this->DisplayName)');
     assert('is_array($this->InformationURL)');
     assert('is_array($this->PrivacyStatementURL)');
     assert('is_array($this->Keywords)');
     assert('is_array($this->Logo)');
     assert('is_array($this->children)');
     $e = null;
     if (!empty($this->DisplayName) || !empty($this->Description) || !empty($this->InformationURL) || !empty($this->PrivacyStatementURL) || !empty($this->Keywords) || !empty($this->Logo) || !empty($this->children)) {
         $doc = $parent->ownerDocument;
         $e = $doc->createElementNS(self::NS, 'mdui:UIInfo');
         $parent->appendChild($e);
         Utils::addStrings($e, self::NS, 'mdui:DisplayName', true, $this->DisplayName);
         Utils::addStrings($e, self::NS, 'mdui:Description', true, $this->Description);
         Utils::addStrings($e, self::NS, 'mdui:InformationURL', true, $this->InformationURL);
         Utils::addStrings($e, self::NS, 'mdui:PrivacyStatementURL', true, $this->PrivacyStatementURL);
         if (!empty($this->Keywords)) {
             foreach ($this->Keywords as $child) {
                 $child->toXML($e);
             }
         }
         if (!empty($this->Logo)) {
             foreach ($this->Logo as $child) {
                 $child->toXML($e);
             }
         }
         if (!empty($this->children)) {
             foreach ($this->children as $child) {
                 $child->toXML($e);
             }
         }
     }
     return $e;
 }
예제 #13
0
 /**
  * Add this AffiliationDescriptor to an EntityDescriptor.
  *
  * @param \DOMElement $parent The EntityDescriptor we should append this endpoint to.
  * @return \DOMElement
  */
 public function toXML(\DOMElement $parent)
 {
     assert('is_string($this->affiliationOwnerID)');
     assert('is_null($this->ID) || is_string($this->ID)');
     assert('is_null($this->validUntil) || is_int($this->validUntil)');
     assert('is_null($this->cacheDuration) || is_string($this->cacheDuration)');
     assert('is_array($this->Extensions)');
     assert('is_array($this->AffiliateMember)');
     assert('!empty($this->AffiliateMember)');
     assert('is_array($this->KeyDescriptor)');
     $e = $parent->ownerDocument->createElementNS(Constants::NS_MD, 'md:AffiliationDescriptor');
     $parent->appendChild($e);
     $e->setAttribute('affiliationOwnerID', $this->affiliationOwnerID);
     if (isset($this->ID)) {
         $e->setAttribute('ID', $this->ID);
     }
     if (isset($this->validUntil)) {
         $e->setAttribute('validUntil', gmdate('Y-m-d\\TH:i:s\\Z', $this->validUntil));
     }
     if (isset($this->cacheDuration)) {
         $e->setAttribute('cacheDuration', $this->cacheDuration);
     }
     Extensions::addList($e, $this->Extensions);
     Utils::addStrings($e, Constants::NS_MD, 'md:AffiliateMember', false, $this->AffiliateMember);
     foreach ($this->KeyDescriptor as $kd) {
         $kd->toXML($e);
     }
     $this->signElement($e, $e->firstChild);
     return $e;
 }