RobRichards\WsePhp\WSSESoapServer::processSignature PHP Method

processSignature() public method

public processSignature ( $refNode )
    public function processSignature($refNode)
    {
        $objXMLSecDSig = new XMLSecurityDSig();
        $objXMLSecDSig->idKeys[] = 'wswsu:Id';
        $objXMLSecDSig->idNS['wswsu'] = self::WSUNS;
        $objXMLSecDSig->sigNode = $refNode;
        /* Canonicalize the signed info */
        $objXMLSecDSig->canonicalizeSignedInfo();
        $retVal = $objXMLSecDSig->validateReference();
        if (!$retVal) {
            throw new Exception('Validation Failed');
        }
        $key = null;
        $objKey = $objXMLSecDSig->locateKey();
        if ($objKey) {
            if ($objKeyInfo = XMLSecEnc::staticLocateKeyInfo($objKey, $refNode)) {
                /* Handle any additional key processing such as encrypted keys here */
            }
        }
        if (empty($objKey)) {
            throw new Exception('Error loading key to handle Signature');
        }
        do {
            if (empty($objKey->key)) {
                $this->SOAPXPath->registerNamespace('xmlsecdsig', XMLSecurityDSig::XMLDSIGNS);
                $query = './xmlsecdsig:KeyInfo/wswsse:SecurityTokenReference/wswsse:Reference';
                $nodeset = $this->SOAPXPath->query($query, $refNode);
                if ($encmeth = $nodeset->item(0)) {
                    if ($uri = $encmeth->getAttribute('URI')) {
                        $arUrl = parse_url($uri);
                        if (empty($arUrl['path']) && ($identifier = $arUrl['fragment'])) {
                            $query = '//wswsse:BinarySecurityToken[@wswsu:Id="' . $identifier . '"]';
                            $nodeset = $this->SOAPXPath->query($query);
                            if ($encmeth = $nodeset->item(0)) {
                                $x509cert = $encmeth->textContent;
                                $x509cert = str_replace(array("\r", "\n"), '', $x509cert);
                                $x509cert = "-----BEGIN CERTIFICATE-----\n" . chunk_split($x509cert, 64, "\n") . "-----END CERTIFICATE-----\n";
                                $objKey->loadKey($x509cert);
                                break;
                            }
                        }
                    }
                }
                throw new Exception('Error loading key to handle Signature');
            }
        } while (0);
        if (!$objXMLSecDSig->verify($objKey)) {
            throw new Exception('Unable to validate Signature');
        }
        return true;
    }