Open Journal Systems
3.3.0
Wsse.php
1
<?php
2
3
namespace
Http\Message\Authentication
;
4
5
use
Http\Message\Authentication
;
6
use
Psr\Http\Message\RequestInterface
;
7
13
final
class
Wsse
implements
Authentication
14
{
18
private
$username;
19
23
private
$password;
24
29
public
function
__construct
($username, $password)
30
{
31
$this->username = $username;
32
$this->password = $password;
33
}
34
38
public
function
authenticate
(
RequestInterface
$request)
39
{
40
// TODO: generate better nonce?
41
$nonce = substr(md5(uniqid(uniqid().
'_'
,
true
)), 0, 16);
42
$created = date(
'c'
);
43
$digest = base64_encode(sha1(base64_decode($nonce).$created.$this->password,
true
));
44
45
$wsse = sprintf(
46
'UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"'
,
47
$this->username,
48
$digest,
49
$nonce,
50
$created
51
);
52
53
return
$request
54
->
withHeader
(
'Authorization'
,
'WSSE profile="UsernameToken"'
)
55
->withHeader(
'X-WSSE'
, $wsse)
56
;
57
}
58
}
Http\Message\Authentication
Definition:
AutoBasicAuth.php:3
Psr\Http\Message\RequestInterface
Definition:
vendor/psr/http-message/src/RequestInterface.php:24
Http\Message\Authentication
Definition:
Authentication.php:12
Http\Message\Authentication\Wsse
Definition:
Wsse.php:13
Http\Message\Authentication\Wsse\authenticate
authenticate(RequestInterface $request)
Definition:
Wsse.php:44
Http\Message\Authentication\Wsse\__construct
__construct($username, $password)
Definition:
Wsse.php:35
Psr\Http\Message\MessageInterface\withHeader
withHeader($name, $value)
plugins
paymethod
paypal
vendor
php-http
message
src
Authentication
Wsse.php
Generated on Fri Aug 28 2020 14:53:56 for Open Journal Systems by
1.8.17