PHP Classes
elePHPant
Icontem

WsSecurity: Create header to set password for SOAP requests

Recommend this page to a friend!

  Author Author  
Name: WsdlToPhp <contact>
Classes: 9 packages by
Country: France France
Innovation award
Innovation award
Nominee: 4x

Winner: 1x


  Detailed description   Download Download .zip .tar.gz  
This package can create header to set password for SOAP requests.

It takes the user name and a password and generate a header for sending a SOAP request to a server and authenticate on behalf of the given user.

The class takes an optional parameter to use digest authentication and the password be encrypted when the request is sent.

Details

WsdlToPhp WsSecurity

License Latest Stable Version Build Status PHP 7 ready Scrutinizer Code Quality Code Coverage Total Downloads Dependency Status StyleCI SensioLabsInsight

How to use it

This repository contains multiple classes that may be used indepdently but for now it is easier/better to only use the WsSecurity class.

The WsSecurity class provides a static method that takes the parameters that should suffice to create your Ws-Security Username Authentication header required in your SOAP request.

Concretly, you must include this repository in your project using composer (composer require wsdltophp/wssecurity:dev-master) then use it such as:

use WsdlToPhp\WsSecurity\WsSecurity;

/
 * @var \SoapHeader
 */
$soapHeader = WsSecurity::createWsSecuritySoapHeader('login', 'password', true);
/
 * Send the request
 */
$soapClient = new \SoapClient('wsdl_url');
$soapClient->__setSoapHeaders($soapHeader);
$client->__soapCall('echoVoid', null);

The WsSecurity::createWsSecuritySoapHeader parameters are defined in this order ($username, $password, $passwordDigest = false, $addCreated = 0, $addExpires = 0, $returnSoapHeader = true, $mustunderstand = false, $actor = null, $usernameId = null):

  • $username: your login/username
  • $password: your password
  • $passwordDigest: set it to true if your password must be encrypted
  • $addCreated: set it to the time you created this header using the PHP time function for example, otherwise pass 0
  • $addExpires: set it to the number of seconds in which the header will expire, 0 otherwise
  • $returnSoapHeader: set it to false if you want to get the \SoapVar object that is used to create the \SoapHeader object, then you'll have to use to create by yourself the \SoapHeader object
  • $mustunderstand: classic option of the \SoapClient class
  • $actor: classic option of the \SoapClient class
  • $usernameId: the id to attach to the UsernameToken element, optional

Unit tests

You can run the unit tests with the following command at the root directory of this project:

$ phpunit

Feedback

Any feedback is appreciated at contact@wsdltophp.com or by creating an issue on this project.


  Classes of WsdlToPhp  >  WsSecurity  >  Download Download .zip .tar.gz  >  Support forum Support forum  >  Blog Blog  >  RSS 1.0 feed RSS 2.0 feed Latest changes  
Name: WsSecurity
Base name: wssecurity
Description: Create header to set password for SOAP requests
Version: -
PHP version: 5
License: MIT/X Consortium License
 
  Groups   Applications   Files Files  

  Groups  
Group folder image PHP 5 Classes using PHP 5 specific features View top rated classes
Group folder image User Management User records, authentication and session handling View top rated classes
Group folder image Web services Web data clipping, SOAP or XML-RPC clients and servers View top rated classes


  Applications that use this package  
No pages of applications that use this class were specified.

Add link image If you know an application of this package, send a message to the author to add a link here.

  Files folder image Files  
File Role Description
Files folder imagesrc (10 files)
Files folder imagetests (2 files)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .php_cs Example Example script
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files  /  src  
File Role Description
  Plain text file Created.php Class Class source
  Plain text file Element.php Class Class source
  Plain text file Expires.php Class Class source
  Plain text file Nonce.php Class Class source
  Plain text file Password.php Class Class source
  Plain text file Security.php Class Class source
  Plain text file Timestamp.php Class Class source
  Plain text file Username.php Class Class source
  Plain text file UsernameToken.php Class Class source
  Plain text file WsSecurity.php Class Class source

  Files folder image Files  /  tests  
File Role Description
  Plain text file TestCase.php Class Class source
  Plain text file WsSecurityTest.php Class Class source

Download Download all files: wssecurity.tar.gz wssecurity.zip
NOTICE: if you are using a download manager program like 'GetRight', please Login before trying to download this archive.