Wsse listener aiuto

Syd Chino Barrett

Nuovo Utente
22 Ott 2015
3
0
0
Buongiorno,

dovrei creare un WSSE Listener, ma non riesco.

Questa à la chiamata

PHP:
<?php
class TokenGenerator {
	public static function generateToken($username, $password) {
		$nonce = self::generateNonce ();

		$created = date ( 'Y-m-d\TH:i:sP' );
		$digest = base64_encode ( sha1 ( $nonce . $created . $password, TRUE ) );
		$token = sprintf ( 'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"', $username, $digest, $nonce, $created );
		return $token;
	}

	private static function generateNonce($bits = 256) {
		$bytes = ceil ( $bits / 8 ) * microtime ();
		$return = '';

		for($i = 0; $i < $bytes; $i ++)
			$return .= chr ( mt_rand ( 0, 255 ) );

		return md5 ( $return );
	}
}

$xwsse = TokenGenerator::generateToken ( 'username', 'RC&EWoiQ7#!!' ); // ### GENERO IL TOKEN
$httpRequest = new \HttpRequest (
	'http://XXXX/',
	\HttpRequest::METH_POST, [
		'headers' => [
			'Content-Type' => 'application/x-www-form-urlencoded; charset=UTF-8',
			'Accept-Charset' => 'UTF-8',
			'X-Wsse' => $xwsse
		],
		'protocol' => HTTP_VERSION_1_2
	]
);

$httpRequest->setPostFields ( [
	'userName' => 'testAgentnip',
	'phoneNumber' => '32896980502',
	'customer' => '112233'
] ) or die ( 'Errore' );

try {
	$result = $httpRequest->send()->getBody ();
	echo $result;
} catch ( \HttpException $ex ) {
	error_log ( 'ERRORE CHIAMATA HTTP => ' . $ex->getMessage () );
}
 

Discussioni simili