OneLogin_Saml2_Auth::buildResponseSignature PHP Метод

buildResponseSignature() публичный Метод

Generates the Signature for a SAML Response
public buildResponseSignature ( string $samlResponse, string $relayState, string $signAlgorithm = XMLSecurityKey::RSA_SHA1 ) : string
$samlResponse string The SAML Response
$relayState string The RelayState
$signAlgorithm string Signature algorithm method
Результат string A base64 encoded signature
    public function buildResponseSignature($samlResponse, $relayState, $signAlgorithm = XMLSecurityKey::RSA_SHA1)
    {
        if (!$this->_settings->checkSPCerts()) {
            throw new OneLogin_Saml2_Error("Trying to sign the SAML Response but can't load the SP certs", OneLogin_Saml2_Error::SP_CERTS_NOT_FOUND);
        }
        $key = $this->_settings->getSPkey();
        $objKey = new XMLSecurityKey($signAlgorithm, array('type' => 'private'));
        $objKey->loadKey($key, false);
        $security = $this->_settings->getSecurityData();
        if ($security['lowercaseUrlencoding']) {
            $msg = 'SAMLResponse=' . rawurlencode($samlResponse);
            if (isset($relayState)) {
                $msg .= '&RelayState=' . rawurlencode($relayState);
            }
            $msg .= '&SigAlg=' . rawurlencode($signAlgorithm);
        } else {
            $msg = 'SAMLResponse=' . urlencode($samlResponse);
            if (isset($relayState)) {
                $msg .= '&RelayState=' . urlencode($relayState);
            }
            $msg .= '&SigAlg=' . urlencode($signAlgorithm);
        }
        $signature = $objKey->signData($msg);
        return base64_encode($signature);
    }