chinoknot Posted December 21, 2015 Share Posted December 21, 2015 Hello,I'm in trouble with WSSE Authentication in PHP. I found a good client and server file for my tests and works fine, but I receive the call in other way, so I must configure my serverside for receiving the right header with username, psw, nonce and created time.The call: <?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' => '3474875366', 'customer' => '112233' ] ) or die ( 'Errore' ); try { $result = $httpRequest->send()->getBody (); echo $result; } catch ( \HttpException $ex ) { error_log ( 'ERRORE CHIAMATA HTTP => ' . $ex->getMessage () ); } Now I need a page which receive this kind of header.I've been looking for getallheaders() function, but still doesn't workHelp me! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.