Guest User

Untitled

a guest
Nov 25th, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.64 KB | None | 0 0
  1. [enter image description here][1]
  2. [enter image description here][2]
  3. [enter image description here][3]
  4. [enter image description here][4]
  5. [enter image description here][5]
  6. [enter image description here][6]
  7. [enter image description here][7]
  8. [enter image description here][8]
  9. [enter image description here][9]
  10. [enter image description here][10]
  11. [enter image description here][11]
  12. [enter image description here][12]
  13.  
  14.  
  15.  
  16.  
  17.  
  18. [1]: https://i.stack.imgur.com/xagv1.png
  19. [2]: https://i.stack.imgur.com/sSFMY.png
  20. [3]: https://i.stack.imgur.com/cdzzi.png
  21. [4]: https://i.stack.imgur.com/3wXF8.png
  22. [5]: https://i.stack.imgur.com/RpFAh.png
  23. [6]: https://i.stack.imgur.com/zgQCx.png
  24. [7]: https://i.stack.imgur.com/gIR2J.png
  25. [8]: https://i.stack.imgur.com/qhdng.png
  26. [9]: https://i.stack.imgur.com/Zm1ke.png
  27. [10]: https://i.stack.imgur.com/VrrKz.png
  28. [11]: https://i.stack.imgur.com/zGaUF.png
  29. [12]: https://i.stack.imgur.com/G2DbQ.png
  30.  
  31.  
  32. PHP Example Codes:
  33. $wsdl = 'http://192.168.5.234:3333/AuthWSSecurity/services/AuthHelloWS?wsdl';
  34. $local_cert = 'client_load.pem';
  35. $passphrase = 'password';
  36. $client = new SoapClient($wsdl, array('trace'=>true, 'exceptions'=>true, 'local_cert' => $local_cert, 'passphrase' => $passphrase));
  37. $request = array(
  38. "name" => 'welcome'
  39. );
  40. $results = $client->authHelloWS($request);
  41. var_dump($results);
  42. Result:
  43. Fatal error: Uncaught SoapFault exception: [wsse:InvalidSecurity] Missing wsse:Security header in request in D:wampwwwsoaptesttest_new_soap.php:98 Stack trace: #0 D:wampwwwsoaptesttest_new_soap.php(98): SoapClient->__call('authHelloWS', Array) #1 D:wampwwwsoaptesttest_new_soap.php(98): SoapClient->authHelloWS(Array) #2 {main} thrown in D:wampwwwsoaptesttest_new_soap.php on line 98
  44. --------------------------------------------------------------
  45. class WsseAuthHeader extends SoapHeader {
  46.  
  47. private $wss_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
  48.  
  49. function __construct($user, $pass, $ns = null) {
  50. if ($ns) {
  51. $this->wss_ns = $ns;
  52. }
  53.  
  54. $auth = new stdClass();
  55. $auth->Username = new SoapVar($user, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
  56. $auth->Password = new SoapVar($pass, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
  57.  
  58. $username_token = new stdClass();
  59. $username_token->UsernameToken = new SoapVar($auth, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns);
  60.  
  61. $security_sv = new SoapVar(
  62. new SoapVar($username_token, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns),
  63. SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'Security', $this->wss_ns);
  64. parent::__construct($this->wss_ns, 'Security', $security_sv, true);
  65. }
  66. }
  67.  
  68. $wsdlfile='http://192.168.5.234:3333/AuthWSSecurity/services/AuthHelloWS?wsdl';
  69. $username='apache';
  70. $password='apachepwd';
  71. $wsse_header = new WsseAuthHeader($username, $password);
  72. $x = new SoapClient($wsdlfile, array("trace" => 1, "exception" => 0));
  73. $x->__setSoapHeaders(array($wsse_header));
  74.  
  75.  
  76.  
  77. $request = array(
  78. "name" => 'welcome'
  79. );
  80. $results = $x->authHelloWS($request);
  81. var_dump($results);
  82.  
  83.  
  84. Result :
  85.  
  86. Fatal error: Uncaught SoapFault exception: [ns2Xvpn:InvalidSecurityToken] An invalid security token was provided (An error happened processing a Username Token "{0}") in D:wampwwwsoaptesttest_new_soap.php:262 Stack trace: #0 D:wampwwwsoaptesttest_new_soap.php(262): SoapClient->__call('authHelloWS', Array) #1 D:wampwwwsoaptesttest_new_soap.php(262): SoapClient->authHelloWS(Array) #2 {main} thrown in D:wampwwwsoaptesttest_new_soap.php on line 262
  87.  
  88.  
  89. -----------------------------------------------------------------------------------------------------
  90.  
  91.  
  92. class WsseAuthHeader extends SoapHeader {
  93.  
  94. private $wss_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd';
  95. private $wsu_ns = 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd';
  96.  
  97. function __construct($user, $pass) {
  98.  
  99. $created = gmdate('Y-m-dTH:i:sZ');
  100. $nonce = mt_rand();
  101. $passdigest = base64_encode( pack('H*', sha1( pack('H*', $nonce) . pack('a*',$created). pack('a*',$pass))));
  102.  
  103. $auth = new stdClass();
  104. $auth->Username = new SoapVar($user, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
  105. $auth->Password = new SoapVar($pass, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
  106. $auth->Nonce = new SoapVar($passdigest, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wss_ns);
  107. $auth->Created = new SoapVar($created, XSD_STRING, NULL, $this->wss_ns, NULL, $this->wsu_ns);
  108.  
  109. $username_token = new stdClass();
  110. $username_token->UsernameToken = new SoapVar($auth, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns);
  111.  
  112. $security_sv = new SoapVar(
  113. new SoapVar($username_token, SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'UsernameToken', $this->wss_ns),
  114. SOAP_ENC_OBJECT, NULL, $this->wss_ns, 'Security', $this->wss_ns);
  115. parent::__construct($this->wss_ns, 'Security', $security_sv, true);
  116. }
  117. }
  118.  
  119.  
  120.  
  121. $client = new SoapClient("http://192.168.5.234:3333/AuthWSSecurity/services/AuthHelloWS?wsdl");
  122. $client->__setSoapHeaders(Array(new WsseAuthHeader("apache", "apachepwd")));
  123.  
  124.  
  125. $request = array(
  126. "name" => 'welcome'
  127. );
  128. $results = $client->authHelloWS($request);
  129. var_dump($results);
  130.  
  131.  
  132.  
  133. Result :
  134.  
  135. Fatal error: Uncaught SoapFault exception: [ns2Xvpn:InvalidSecurityToken] An invalid security token was provided (An error happened processing a Username Token "{0}") in D:wampwwwsoaptesttest_new_soap.php:306 Stack trace: #0 D:wampwwwsoaptesttest_new_soap.php(306): SoapClient->__call('authHelloWS', Array) #1 D:wampwwwsoaptesttest_new_soap.php(306): SoapClient->authHelloWS(Array) #2 {main} thrown in D:wampwwwsoaptesttest_new_soap.php on line 306
Add Comment
Please, Sign In to add comment