function signAssertion($responseXmlString,$privKey,$cert) 
   {
      if (file_exists("/tmp/xml")) {
         $tempFileDir="/tmp/xml/";          
      
      } else {
             mkdir("/tmp/xml",0777);   
         $tempFileDir="/tmp/xml/";
      }
      $tempName = 'saml-response-' . $this->samlCreateId() . '.xml';
      $tempFileName=$tempFileDir.$tempName;
      while (file_exists($tempFileName)) 
         $tempFileName = 'saml-response-' . $this->samlCreateId() . '.xml';

      if (!$handle = fopen($tempFileName, 'w')) {
         return null;
      }
      if (fwrite($handle, $responseXmlString) === false) {
         return null;
      }
      fclose($handle);
      $cmd = 'xmlsec1 --sign --privkey-pem ' . $privKey . 
         ',' . $cert . ' --output ' . $tempFileName . 
         '.out ' . $tempFileName;
      exec($cmd, $resp);
      unlink($tempFileName);

      $xmlResult = @file_get_contents($tempFileName . '.out');
      if (!$xmlResult) { 
         return null;
      } else {
         unlink($tempFileName . '.out');
         return $xmlResult;
      }
   }
function signAssertion($responseXmlString,$privKey,$cert) 
   {
      if (file_exists("/tmp/xml")) {
         $tempFileDir="/tmp/xml/";          
      
      } else {
             mkdir("/tmp/xml",0777);   
         $tempFileDir="/tmp/xml/";
      }
      $tempName = 'saml-response-' . $this->samlCreateId() . '.xml';
      $tempFileName=$tempFileDir.$tempName;
      while (file_exists($tempFileName)) 
         $tempFileName = 'saml-response-' . $this->samlCreateId() . '.xml';

      if (!$handle = fopen($tempFileName, 'w')) {
         return null;
      }
      if (fwrite($handle, $responseXmlString) === false) {
         return null;
      }
      fclose($handle);
      $cmd = 'xmlsec1 --sign --privkey-pem ' . $privKey . 
         ',' . $cert . ' --output ' . $tempFileName . 
         '.out ' . $tempFileName;
      exec($cmd, $resp);
      unlink($tempFileName);

      $xmlResult = @file_get_contents($tempFileName . '.out');
      if (!$xmlResult) { 
         return null;
      } else {
         unlink($tempFileName . '.out');
         return $xmlResult;
      }
   }
function signAssertion ( $ responseXmlString , $ privKey , $ cert ) { if ( file_exists ( "/tmp/xml" ) ) { $ tempFileDir = "/tmp/xml/" ; } else { mkdir ( "/tmp/xml" , 0777 ) ; $ tempFileDir = "/tmp/xml/" ; } $ tempName = 'saml-response-' . $ this -> samlCreateId ( ) . '.xml' ; $ tempFileName = $ tempFileDir . $ tempName ; while ( file_exists ( $ tempFileName ) ) $ tempFileName = 'saml-response-' . $ this -> samlCreateId ( ) . '.xml' ; if ( ! $ handle = fopen ( $ tempFileName , 'w' ) ) { return null ; } if ( fwrite ( $ handle , $ responseXmlString ) === false ) { return null ; } fclose ( $ handle ) ; $ cmd = 'xmlsec1 --sign --privkey-pem ' . $ privKey . ',' . $ cert . ' --output ' . $ tempFileName . '.out ' . $ tempFileName ; exec ( $ cmd , $ resp ) ; unlink ( $ tempFileName ) ; $ xmlResult = @ file_get_contents ( $ tempFileName . '.out' ) ; if ( ! $ xmlResult ) { return null ; } else { unlink ( $ tempFileName . '.out' ) ; return $ xmlResult ; } }
Signs a SAML response with the given private key, and embeds the public key.
@param string $responseXmlString The unsigned Assertion which will be signed
@param string $priKey Private key to sign the certificate
@param string $cert Public key certificate of signee
@return string Signed Assertion
Signs a SAML response with the given private key and embeds the public key .