Advertisement
Guest User

Untitled

a guest
Jan 25th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.74 KB | None | 0 0
  1. <?php
  2.  
  3. class TERYT_SoapClient extends SoapClient {
  4.     protected $user;
  5.     protected $pass;
  6.  
  7.     public function __construct ($wsdl, $options) {
  8.         $this->user = $options['ws-security-login'];
  9.         $this->pass = $options['ws-security-password'];
  10.         parent::__construct($wsdl, $options);
  11.     }
  12.  
  13.     public function __doRequest ($request , $location , $action , $version, $one_way = 0)
  14.     {
  15.         $nonce_encoded = base64_encode( bin2hex( openssl_random_pseudo_bytes( 16 ) ) );
  16.         $header = '
  17.    <SOAP-ENV:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
  18.        <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
  19.            <wsse:UsernameToken wsu:Id="UsernameToken-'. date('c') .'">
  20.                <wsse:Username>'. $this->user .'</wsse:Username>
  21.                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">'. $this->pass .'</wsse:Password>
  22.                <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">'. $nonce_encoded .'</wsse:Nonce>
  23.                <wsu:Created>'. date('c') .'</wsu:Created>
  24.            </wsse:UsernameToken>
  25.        </wsse:Security>
  26.        <wsa:Action>'. $action .'</wsa:Action>
  27.    </SOAP-ENV:Header>
  28.    ';
  29.         $xml = explode('<SOAP-ENV:Body>', $request);
  30.         $request = str_replace('SOAP-ENV', 'soapenv', $xml[0] . $header . '<SOAP-ENV:Body>' . $xml[1]);
  31.         return parent::__doRequest($request , $location, $action, $version, $one_way);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement