protected function execute(InputInterface $input, OutputInterface $output) { /** @var $dialog DialogHelper */ $dialog = $this->getHelperSet()->get('dialog'); $entityID = $this->askForEntityID($dialog, $output); $ed = new EntityDescriptor($entityID); $this->askForCertificate($dialog, $output, $ed); $sp = new SpSsoDescriptor(); $ed->addItem($sp); $output->writeln(''); $wantAssertionsSigned = (bool) $dialog->select($output, 'Want assertions signed [yes]: ', array('no', 'yes'), 1); $sp->setWantAssertionsSigned($wantAssertionsSigned); $output->writeln(''); $this->askForSLO($dialog, $output, $sp); $output->writeln(''); $this->askForACS($dialog, $output, $sp); $output->writeln(''); $filename = $this->askForFilename($dialog, $output); $formatOutput = $dialog->select($output, 'Format output xml [no]: ', array('no', 'yes'), 0); $context = new SerializationContext(); $context->getDocument()->formatOutput = (bool) $formatOutput; $ed->getXml($context->getDocument(), $context); $xml = $context->getDocument()->saveXML(); file_put_contents($filename, $xml); }
/** * @param \DOMNode $parent * @param SerializationContext $context * @return \DOMElement */ public function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_METADATA, 'md:NameIDFormat'); $parent->appendChild($result); $result->nodeValue = $this->value; return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_METADATA, 'md:' . $this->getXmlNodeName()); $parent->appendChild($result); $result->setAttribute('Binding', $this->getBinding()); $result->setAttribute('Location', $this->getLocation()); return $result; }
/** * @param \DOMNode $parent * @param SerializationContext $context * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $this->prepareForXml(); $result = $context->getDocument()->createElementNS(Protocol::SAML2, 'samlp:StatusCode'); $result->setAttribute('Value', $this->getValue()); if ($this->getChild()) { $this->getChild()->getXml($result, $context); } return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $this->prepareForXml(); $result = $context->getDocument()->createElementNS(Protocol::SAML2, 'samlp:Status'); $parent->appendChild($result); $result->appendChild($this->getStatusCode()->getXml($result, $context)); if ($this->getMessage()) { $statusMessageNode = $context->getDocument()->createElementNS(Protocol::SAML2, 'samlp:StatusMessage', $this->getMessage()); $result->appendChild($statusMessageNode); } return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ public function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:Subject'); $parent->appendChild($result); if ($this->getNameID()) { $this->getNameID()->getXml($result, $context); } foreach ($this->getSubjectConfirmations() as $sc) { $sc->getXml($result, $context); } return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $this->prepareForXml(); $result = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:SubjectConfirmation'); $parent->appendChild($result); $result->setAttribute('Method', $this->getMethod()); if ($this->getNameID()) { $this->getNameID()->getXml($result, $context); } $this->getData()->getXml($result, $context); return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:AuthnStatement'); $parent->appendChild($result); $result->setAttribute('AuthnInstant', Helper::time2string($this->getAuthnInstant())); if ($this->getSessionIndex()) { $result->setAttribute('SessionIndex', $this->getSessionIndex()); } $authnContextNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:AuthnContext'); $result->appendChild($authnContextNode); $refNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:AuthnContextClassRef', $this->getAuthnContext()); $authnContextNode->appendChild($refNode); return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMNode */ function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_METADATA, 'md:KeyDescriptor'); $parent->appendChild($result); if ($this->getUse()) { $result->setAttribute('use', $this->getUse()); } $keyInfo = $parent->ownerDocument->createElementNS(Protocol::NS_XMLDSIG, 'ds:KeyInfo'); $result->appendChild($keyInfo); $xData = $parent->ownerDocument->createElementNS(Protocol::NS_XMLDSIG, 'ds:X509Data'); $keyInfo->appendChild($xData); $xCert = $parent->ownerDocument->createElementNS(Protocol::NS_XMLDSIG, 'ds:X509Certificate'); $xData->appendChild($xCert); $xCert->nodeValue = $this->getCertificate()->getData(); return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ public function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:Attribute'); $parent->appendChild($result); $result->setAttribute('Name', $this->getName()); if ($this->getNameFormat()) { $result->setAttribute('NameFormat', $this->getNameFormat()); } if ($this->getFriendlyName()) { $result->setAttribute('FriendlyName', $this->getFriendlyName()); } foreach ($this->getValues() as $v) { $valueNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:AttributeValue', $v); $result->appendChild($valueNode); } return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @throws \AerialShip\LightSaml\Error\InvalidAssertionException * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $this->prepareForXml(); $result = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:Assertion'); $parent->appendChild($result); $result->setAttribute('ID', $this->getID()); $result->setAttribute('Version', $this->getVersion()); $result->setAttribute('IssueInstant', Helper::time2string($this->getIssueInstant())); $issuerNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:Issuer', $this->getIssuer()); $result->appendChild($issuerNode); $this->getSubject()->getXml($result, $context); $conditionsNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:Conditions'); $result->appendChild($conditionsNode); $conditionsNode->setAttribute('NotBefore', Helper::time2string($this->getNotBefore())); $conditionsNode->setAttribute('NotOnOrAfter', Helper::time2string($this->getNotOnOrAfter())); if ($this->getValidAudience()) { $audienceRestrictionNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'AudienceRestriction'); $conditionsNode->appendChild($audienceRestrictionNode); foreach ($this->getValidAudience() as $v) { $audienceNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'Audience', $v); $audienceRestrictionNode->appendChild($audienceNode); } } $attributeStatementNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:AttributeStatement'); $result->appendChild($attributeStatementNode); foreach ($this->getAllAttributes() as $attribute) { $attribute->getXml($attributeStatementNode, $context); } $this->getAuthnStatement()->getXml($result, $context); if ($signature = $this->getSignature()) { if (!$signature instanceof SignatureCreator) { throw new InvalidAssertionException('Signature must be SignatureCreator'); } $signature->getXml($result, $context); } return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ public function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:NameID', $this->getValue()); $parent->appendChild($result); if ($this->getSPNameQualifier()) { $result->setAttribute('SPNameQualifier', $this->getSPNameQualifier()); } if ($this->getNameQualifier()) { $result->setAttribute('NameQualifier', $this->getNameQualifier()); } if ($this->getSPProvidedID()) { $result->setAttribute('SPProvidedID', $this->getSPProvidedID()); } if ($this->getFormat()) { $result->setAttribute('Format', $this->getFormat()); } return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ public function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_METADATA, 'md:' . $this->getXmlNodeName()); $parent->appendChild($result); $result->setAttribute('protocolSupportEnumeration', $this->getProtocolSupportEnumeration()); foreach ($this->getKeyDescriptors() as $kd) { $kd->getXml($result, $context); } foreach ($this->getServices() as $service) { $service->getXml($result, $context); } foreach ($this->getNameIdFormats() as $nameIdFormat) { $nameIdFormat->getXml($result, $context); } return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_METADATA, 'md:EntityDescriptor'); $result->setAttribute('entityID', $this->getEntityID()); $parent->appendChild($result); foreach ($this->items as $item) { $item->getXml($result, $context); } return $result; }
/** * @param \DOMNode $parent * @param SerializationContext $context * @throws \RuntimeException * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_METADATA, 'md:EntitiesDescriptor'); $parent->appendChild($result); if ($this->getValidUntil()) { $result->setAttribute('validUntil', Helper::time2string($this->getValidUntil())); } if ($this->getCacheDuration()) { $result->setAttribute('cacheDuration', $this->getCacheDuration()); } if ($this->getId()) { $result->setAttribute('ID', $this->getId()); } if ($this->getName()) { $result->setAttribute('Name', $this->getName()); } if ($signature = $this->getSignature()) { if ($signature instanceof SignatureCreator) { $signature->getXml($result, $context); } else { throw new \RuntimeException('Signature must be SignatureCreator'); } } foreach ($this->items as $item) { $item->getXml($result, $context); } return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ function getXml(\DOMNode $parent, SerializationContext $context) { $result = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:SubjectConfirmationData'); $parent->appendChild($result); if ($this->getNotBefore()) { $result->setAttribute('NotBefore', Helper::time2string($this->getNotBefore())); } if ($this->getNotOnOrAfter()) { $result->setAttribute('NotOnOrAfter', Helper::time2string($this->getNotOnOrAfter())); } foreach (array('Recipient', 'InResponseTo', 'Address') as $name) { $method = "get{$name}"; if ($this->{$method}()) { $result->setAttribute($name, $this->{$method}()); } } return $result; }
/** * @param \DOMNode $parent * @param \AerialShip\LightSaml\Meta\SerializationContext $context * @return \DOMElement */ public function getXml(\DOMNode $parent, SerializationContext $context) { $this->prepareForXml(); if ($this->getXmlNodeNamespace()) { $result = $context->getDocument()->createElementNS($this->getXmlNodeNamespace(), $this->getXmlNodeLocalName()); } else { $result = $context->getDocument()->createElement($this->getXmlNodeLocalName()); } $parent->appendChild($result); $result->setAttribute('ID', $this->getID()); $result->setAttribute('Version', $this->getVersion()); $result->setAttribute('IssueInstant', Helper::time2string($this->getIssueInstant())); if ($this->getDestination()) { $result->setAttribute('Destination', $this->getDestination()); } $issuerNode = $context->getDocument()->createElementNS(Protocol::NS_ASSERTION, 'saml:Issuer', $this->getIssuer()); $result->appendChild($issuerNode); return $result; }