Ejemplo n.º 1
2
 function __doRequest($request, $location, $saction, $version, $one_way = null)
 {
     include_once 'WSSESoap.php';
     include_once 'WSASoap.php';
     $dom = new DOMDocument('1.0');
     $dom->loadXML($request);
     $objWSA = new WSASoap($dom);
     $objWSA->addAction($saction);
     $objWSA->addTo($location);
     $objWSA->addMessageID();
     $objWSA->addReplyTo();
     $dom = $objWSA->getDoc();
     $objWSSE = new WSSESoap($dom);
     if (isset($this->_username) && isset($this->_password)) {
         $objWSSE->addUserToken($this->_username, $this->_password);
     }
     /* Sign all headers to include signing the WS-Addressing headers */
     $objWSSE->signAllHeaders = TRUE;
     $objWSSE->addTimestamp(300);
     // if you need to do binary certificate signing you can uncomment this (and provide the path to the cert)
     /* create new XMLSec Key using RSA SHA-1 and type is private key */
     // $objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type'=>'private'));
     /* load the private key from file - last arg is bool if key in file (TRUE) or is string (FALSE) */
     /* Sign the message - also signs appropraite WS-Security items */
     // $objWSSE->signSoapDoc($objKey);
     /* Add certificate (BinarySecurityToken) to the message and attach pointer to Signature */
     // $token = $objWSSE->addBinaryToken(file_get_contents(CERT_FILE));
     // $objWSSE->attachTokentoSig($token);
     $request = $objWSSE->saveXML();
     $this->_lastRequest = $request;
     return parent::__doRequest($request, $location, $saction, $version);
 }
Ejemplo n.º 2
1
 function __doRequest($request, $location, $saction, $version)
 {
     $dom = new DOMDocument();
     $dom->loadXML($request);
     $objWSSE = new WSSESoap($dom);
     /* Sign all headers to include signing the WS-Addressing headers */
     $objWSSE->signAllHeaders = TRUE;
     $objWSSE->addTimestamp();
     /* create new XMLSec Key using RSA SHA-1 and type is private key */
     $objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private'));
     /* load the private key from file - last arg is bool if key in file (TRUE) or is string (FALSE) */
     $objKey->loadKey(PRIVATE_KEY, TRUE);
     // Sign the message - also signs appropraite WS-Security items
     $objWSSE->signSoapDoc($objKey);
     /* Add certificate (BinarySecurityToken) to the message and attach pointer to Signature */
     $token = $objWSSE->addBinaryToken(file_get_contents(CERT_FILE));
     $objWSSE->attachTokentoSig($token);
     $request = $objWSSE->saveXML();
     $dom = new DOMDocument();
     $dom->loadXML($request);
     $objWSA = new WSASoap($dom);
     $objWSA->addAction($saction);
     $objWSA->addTo($location);
     $objWSA->addMessageID();
     $objWSA->addReplyTo();
     $request = $objWSA->getDoc()->saveXML();
     return parent::__doRequest($request, $location, $saction, $version);
 }
	function __doRequest($request, $location, $saction, $version) {
		$doc = new DOMDocument();
		$doc->loadXML($request);
		$objWSSE = new WSSESoap($doc);
		$objWSSE->addUserToken($this->username, $this->password, FALSE);
		return parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version);
   }
Ejemplo n.º 4
0
 function __doRequest($request, $location, $action, $version, $one_way = 0)
 {
     global $username, $password;
     $doc = new DOMDocument('1.0');
     $doc->loadXML($request);
     $objWSSE = new WSSESoap($doc);
     $objWSSE->addUserToken($username, $password);
     $objWSSE->addTimestamp();
     return parent::__doRequest($objWSSE->saveXML(), $location, $action, $version, $one_way);
 }
Ejemplo n.º 5
0
 /**
  * @param bool $retryAttempt Is this call a repeated attempt to send data. Needs to be available for warning
  * handler that decides whether to requeue request.
  */
 function __doRequest($request, $location, $saction, $version, $one_way = 0, $retryAttempt = false)
 {
     $doc = new DOMDocument();
     $doc->loadXML($request);
     $objWSSE = new WSSESoap($doc);
     $objWSSE->addUserToken($this->username, $this->password, FALSE);
     set_error_handler('\\Wikia\\ExactTarget\\ExactTargetSoapErrorHandler::requeueConnectionResetWarning', E_USER_WARNING);
     $response = parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version);
     restore_error_handler();
     return $response;
 }
Ejemplo n.º 6
0
 public function __doRequest($request, $location, $saction, $version)
 {
     $doc = new DOMDocument('1.0');
     $doc->loadXML($request);
     $objWSSE = new WSSESoap($doc);
     /* add Timestamp with no expiration timestamp */
     //$objWSSE->addTimestamp();
     $objWSSE->addUserToken($this->_username, $this->_password, true);
     //Zend_Debug::dump($objWSSE->saveXML());
     return parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version);
 }
Ejemplo n.º 7
0
 function __doRequest($request, $location, $saction, $version)
 {
     $doc = new DOMDocument('1.0');
     $doc->loadXML($request);
     $objWSSE = new WSSESoap($doc);
     $objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private'));
     $objKey->loadKey(PRIVATE_KEY, TRUE);
     $options = array("insertBefore" => TRUE);
     $objWSSE->signSoapDoc($objKey, $options);
     $objWSSE->addIssuerSerial(CERT_FILE);
     $objKey = new XMLSecurityKey(XMLSecurityKey::AES256_CBC);
     $objKey->generateSessionKey();
     #está wea está rara, no pasa el wsdl y cambía el puerto o.O
     $location = "https://201.238.207.130:7200/WSWebpayTransaction/cxf/WSWebpayService?wsdl";
     #die($location);
     #die(CERT_FILE." ".PRIVATE_KEY);
     $retVal = parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version);
     $doc = new DOMDocument();
     $doc->loadXML($retVal);
     return $doc->saveXML();
     /*
     if ($this->useSSL){ 
             $locationparts = parse_url($location); 
             $location = 'https://'; 
             if(isset($locationparts['host']))  $location .= $locationparts['host']; 
             if(isset($locationparts['port']))  $location .= ':'.$locationparts['port']; 
             if(isset($locationparts['path']))  $location .= $locationparts['path']; 
             if(isset($locationparts['query'])) $location .= '?'.$locationparts['query']; 
     }
     
     $doc = new DOMDocument('1.0'); 
     $doc->loadXML($request); 
     
     $objWSSE = new WSSESoap($doc); 
     $objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1,array('type' => 'private')); 
     $objKey->loadKey(PRIVATE_KEY, TRUE);
     
     $options = array("insertBefore" => TRUE); 
     
     $objWSSE->signSoapDoc($objKey, $options); 
     $objWSSE->addIssuerSerial(CERT_FILE);
     
     $objKey = new XMLSecurityKey(XMLSecurityKey::AES256_CBC); 
     $objKey->generateSessionKey(); 
     
     $retVal = parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version); 
     
     $doc = new DOMDocument(); 
     $doc->loadXML($retVal); 
     return $doc->saveXML(); 
     */
 }
 function __doRequest($request, $location, $saction, $version, $one_way = null)
 {
     $doc = new DOMDocument();
     $doc->loadXML($request);
     $objWSSE = new WSSESoap($doc);
     $objWSSE->addUserToken($this->username, $this->password, FALSE);
     //        echo "<pre> ";
     //        echo $objWSSE->saveXML();
     //        echo "</pre> ";
     //        print "\n \n";
     //file_put_contents('debug.xml', $objWSSE->saveXML());
     return parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version, $one_way);
 }
Ejemplo n.º 9
0
 public function __doRequest($request, $location, $saction, $version)
 {
     $doc = new DOMDocument('1.0');
     $doc->loadXML($request);
     $objWSSE = new WSSESoap($doc);
     /* add Timestamp with no expiration timestamp */
     $objWSSE->addTimestamp();
     /* create new XMLSec Key using AES256_CBC and type is private key */
     $objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private'));
     /* load the private key from file - last arg is bool if key in file (true) or is string (false) */
     $objKey->loadKey(PRIVATE_KEY, true);
     /* Sign the message - also signs appropiate WS-Security items */
     $options = array("insertBefore" => false);
     $objWSSE->signSoapDoc($objKey, $options);
     /* Add certificate (BinarySecurityToken) to the message */
     $token = $objWSSE->addBinaryToken(file_get_contents(CERT_FILE));
     /* Attach pointer to Signature */
     $objWSSE->attachTokentoSig($token);
     $objKey = new XMLSecurityKey(XMLSecurityKey::AES256_CBC);
     $objKey->generateSessionKey();
     $siteKey = new XMLSecurityKey(XMLSecurityKey::RSA_OAEP_MGF1P, array('type' => 'public'));
     $siteKey->loadKey(SERVICE_CERT, true, true);
     $options = array("KeyInfo" => array("X509SubjectKeyIdentifier" => true));
     $objWSSE->encryptSoapDoc($siteKey, $objKey, $options);
     $retVal = parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version);
     $doc = new DOMDocument();
     $doc->loadXML($retVal);
     $options = array("keys" => array("private" => array("key" => PRIVATE_KEY, "isFile" => true, "isCert" => false)));
     $objWSSE->decryptSoapDoc($doc, $options);
     return $doc->saveXML();
 }
Ejemplo n.º 10
0
 public function __doRequest($request, $location, $saction, $version, $one_way = 0)
 {
     $doc = new DOMDocument('1.0');
     $doc->loadXML($request);
     $objWSSE = new WSSESoap($doc);
     /* Sign all headers to include signing the WS-Addressing headers */
     $objWSSE->signAllHeaders = true;
     $objWSSE->addTimestamp();
     $objWSSE->addUserToken($this->_username, $this->_password, $this->_digest);
     /* create new XMLSec Key using RSA SHA-1 and type is private key */
     $objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private'));
     /* load the private key from file - last arg is bool if key in file (true) or is string (FALSE) */
     $objKey->loadKey(PRIVATE_KEY, true);
     /* Sign the message - also signs appropraite WS-Security items */
     $objWSSE->signSoapDoc($objKey);
     /* Add certificate (BinarySecurityToken) to the message and attach pointer to Signature */
     $token = $objWSSE->addBinaryToken(file_get_contents(CERT_FILE));
     $objWSSE->attachTokentoSig($token);
     $request = $objWSSE->saveXML();
     return parent::__doRequest($request, $location, $saction, $version);
 }
Ejemplo n.º 11
0
 function __doRequest($request, $location, $saction, $version)
 {
     $doc = new DOMDocument('1.0');
     $doc->loadXML($request);
     $objWSSE = new WSSESoap($doc);
     /* add Timestamp with no expiration timestamp */
     $objWSSE->addTimestamp();
     /* create new XMLSec Key using RSA SHA-1 and type is private key */
     $objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private'));
     /* load the private key from file - last arg is bool if key in file (TRUE) or is string (FALSE) */
     $objKey->loadKey(PRIVATE_KEY, TRUE);
     /* Sign the message - also signs appropraite WS-Security items */
     $objWSSE->signSoapDoc($objKey);
     /* Add certificate (BinarySecurityToken) to the message and attach pointer to Signature */
     $token = $objWSSE->addBinaryToken(file_get_contents(CERT_FILE));
     $objWSSE->attachTokentoSig($token);
     return parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version);
 }
Ejemplo n.º 12
0
 function __doRequest($request, $location, $saction, $version)
 {
     $doc = new DOMDocument('1.0');
     $doc->loadXML($request);
     $objWSSE = new WSSESoap($doc);
     #echo "<pre>"; var_dump($request); #die();
     /* add Timestamp with no expiration timestamp */
     $objWSSE->addTimestamp();
     try {
         /* Sign the message - also signs appropraite WS-Security items */
         $objWSSE->signSoapDoc($this->ObjKey);
     } catch (Exception $e) {
         throw new Exception("[" . __METHOD__ . "] " . $e->getMessage() . " (Please, check your keys)", E_ERROR);
     }
     /* Add certificate (BinarySecurityToken) to the message and attach pointer to Signature */
     $token = $objWSSE->addBinaryToken($this->BinaryToken);
     $objWSSE->attachTokentoSig($token);
     for ($retry = 1; $retry <= 3; $retry++) {
         try {
             $retval = parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version);
             if ($retval instanceof SoapFault && stristr($retval->faultstring, "Could not connect to host")) {
                 throw new Exception("[{$retry}] " . $retval->getMessage());
             }
             if ($retval) {
                 return $retval;
             }
             $headers = $this->__getLastResponseHeaders();
             if ($headers && stristr($headers, "HTTP/1.1 200 OK")) {
                 return $retval;
             }
             if ($this->__soap_fault && stristr($this->__soap_fault->faultstring, "Could not connect to host")) {
                 throw new Exception("[{$retry}] " . $this->__soap_fault->faultstring);
             }
         } catch (Exception $e) {
             $exept = $e;
         }
         // Sleep for 2 seconds
         sleep(1);
     }
     if ($exept) {
         throw new $exept();
     }
 }
Ejemplo n.º 13
0
		function __doRequest($request, $location, $saction, $version) 
		{		    
		    $doc = new DOMDocument('1.0');
			$doc->loadXML($request);
			
			$objWSSE = new WSSESoap($doc);
			#echo "<pre>"; var_dump($request); #die();
			/* add Timestamp with no expiration timestamp */
		 	$objWSSE->addTimestamp();
		
			/* create new XMLSec Key using RSA SHA-1 and type is private key */
			$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type'=>'private'));
		
			/* load the private key from file - last arg is bool if key in file (TRUE) or is string (FALSE) */
			$objKey->loadKey($this->KeyPath, TRUE);
		
			try
			{
                /* Sign the message - also signs appropraite WS-Security items */
                $objWSSE->signSoapDoc($objKey);
			}
			catch (Exception $e)
			{
			    Core::RaiseError("[".__METHOD__."] ".$e->getMessage(), E_ERROR);
			}
		
			/* Add certificate (BinarySecurityToken) to the message and attach pointer to Signature */
			$token = $objWSSE->addBinaryToken(file_get_contents($this->CertPath));
			$objWSSE->attachTokentoSig($token);
					
			try
			{
				return parent::__doRequest($objWSSE->saveXML(), $location, $saction, $version);
			}
			catch (Exception $e)
			{
				Core::RaiseError("[".__METHOD__."] ".$e->__toString(), E_ERROR);
			}
		}
Ejemplo n.º 14
0
 function __doRequest($request, $location, $saction, $version, $one_way = null)
 {
     $doc = new DOMDocument();
     $doc->loadXML($request);
     $objWSSE = new WSSESoap($doc);
     $objWSSE->addUserToken("*", "*", FALSE);
     $objWSSE->addOAuth($this->getInternalAuthToken($this->tenantKey));
     $content = utf8_encode($objWSSE->saveXML());
     $content_length = strlen($content);
     if ($this->debugSOAP) {
         error_log('FuelSDK SOAP Request: ');
         error_log(str_replace($this->getInternalAuthToken($this->tenantKey), "REMOVED", $content));
     }
     $headers = array("Content-Type: text/xml", "SOAPAction: " . $saction, "User-Agent: " . getSDKVersion());
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $location);
     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $content);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_USERAGENT, "FuelSDK-PHP-v0.9");
     $output = curl_exec($ch);
     $this->lastHTTPCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
     curl_close($ch);
     return $output;
 }