public function addBinaryToken($cert, $isPEMFormat = true) { $security = $this->locateSecurityHeader(); $data = XMLSecurityDSig::get509XCert($cert, $isPEMFormat); $token = $this->soapDoc->createElementNS(WSSESoap::WSSENS, WSSESoap::WSSEPFX . ':BinarySecurityToken', $data); $security->insertBefore($token, $security->firstChild); $token->setAttribute('EncodingType', 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'); $token->setAttributeNS(WSSESoap::WSUNS, WSSESoap::WSUPFX . ':Id', XMLSecurityDSig::generateGUID()); $token->setAttribute('ValueType', 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3'); return $token; }
public function add509Cert($cert, $isPEMFormat = true) { $data = XMLSecurityDSig::get509XCert($cert, $isPEMFormat); if ($xpath = $this->getXPathObj()) { $query = "./secdsig:KeyInfo"; $nodeset = $xpath->query($query, $this->sigNode); $keyInfo = $nodeset->item(0); if (!$keyInfo) { $inserted = false; $keyInfo = $this->createNewSignNode('KeyInfo'); if ($xpath = $this->getXPathObj()) { $query = "./secdsig:Object"; $nodeset = $xpath->query($query, $this->sigNode); if ($sObject = $nodeset->item(0)) { $sObject->parentNode->insertBefore($keyInfo, $sObject); $inserted = true; } } if (!$inserted) { $this->sigNode->appendChild($keyInfo); } } $x509DataNode = $this->createNewSignNode('X509Data'); $keyInfo->appendChild($x509DataNode); $x509CertNode = $this->createNewSignNode('X509Certificate', $data); $x509DataNode->appendChild($x509CertNode); } }