line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: /mirror/coderepos/lang/perl/Atomik/trunk/lib/Atomik/WSSE.pm 67913 2008-08-06T02:30:36.602415Z daisuke $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Atomik::WSSE; |
4
|
1
|
|
|
1
|
|
5
|
use Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
5
|
1
|
|
|
1
|
|
6686
|
use Moose::Util::TypeConstraints; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
6
|
1
|
|
|
1
|
|
4269
|
use DateTime; |
|
1
|
|
|
|
|
208608
|
|
|
1
|
|
|
|
|
45
|
|
7
|
1
|
|
|
1
|
|
1081
|
use Digest::SHA1 (); |
|
1
|
|
|
|
|
1120
|
|
|
1
|
|
|
|
|
27
|
|
8
|
1
|
|
|
1
|
|
909
|
use MIME::Base64 (); |
|
1
|
|
|
|
|
768
|
|
|
1
|
|
|
|
|
105
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
coerce 'Atomik::WSSE' |
11
|
|
|
|
|
|
|
=> from 'HashRef' |
12
|
|
|
|
|
|
|
=> via { |
13
|
|
|
|
|
|
|
return Atomik::WSSE->new(%$_) |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has 'username' => ( |
18
|
|
|
|
|
|
|
is => 'rw', |
19
|
|
|
|
|
|
|
isa => 'Str', |
20
|
|
|
|
|
|
|
required => 1, |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'password' => ( |
24
|
|
|
|
|
|
|
is => 'rw', |
25
|
|
|
|
|
|
|
isa => 'Str', |
26
|
|
|
|
|
|
|
required => 1, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
|
6
|
no Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
11
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub nonce { |
34
|
0
|
|
|
0
|
0
|
|
Digest::SHA1::sha1( Digest::SHA1::sha1(time(), {}, rand(), $$) ) |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub set_headers { |
38
|
0
|
|
|
0
|
0
|
|
my ($self, $request) = @_; |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $nonce = $self->nonce; |
41
|
0
|
|
|
|
|
|
my $encoded = MIME::Base64::encode_base64($nonce, ''); |
42
|
0
|
|
|
|
|
|
my $now = DateTime->now(time_zone => 'UTC')->iso8601; |
43
|
0
|
|
0
|
|
|
|
my $digest = MIME::Base64::encode_base64( |
44
|
|
|
|
|
|
|
Digest::SHA1::sha1($nonce, $now, $self->password || ''), '' |
45
|
|
|
|
|
|
|
); |
46
|
0
|
|
0
|
|
|
|
$request->header('X-WSSE', sprintf |
47
|
|
|
|
|
|
|
qq(UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"), |
48
|
|
|
|
|
|
|
$self->username || '', $digest, $encoded, $now); |
49
|
0
|
|
|
|
|
|
$request->header('Authorization', 'WSSE profile="UsernameToken"'); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
53
|
|
|
|
|
|
|
|