line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package W3C::SOAP::Header::Security::Username; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2012-05-23 14:38:06 |
4
|
|
|
|
|
|
|
# Create by: dev |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
846
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
10
|
1
|
|
|
1
|
|
4782
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
11
|
1
|
|
|
1
|
|
4
|
use version; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
12
|
1
|
|
|
1
|
|
51
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
13
|
1
|
|
|
1
|
|
4
|
use Scalar::Util; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
14
|
1
|
|
|
1
|
|
4
|
use List::Util; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
44
|
|
15
|
|
|
|
|
|
|
#use List::MoreUtils; |
16
|
1
|
|
|
1
|
|
5
|
use Data::Dumper qw/Dumper/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
17
|
1
|
|
|
1
|
|
865
|
use DateTime; |
|
1
|
|
|
|
|
91755
|
|
|
1
|
|
|
|
|
39
|
|
18
|
1
|
|
|
1
|
|
511
|
use Time::HiRes qw/gettimeofday/; |
|
1
|
|
|
|
|
1285
|
|
|
1
|
|
|
|
|
4
|
|
19
|
1
|
|
|
1
|
|
170
|
use English qw/ -no_match_vars /; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
extends 'W3C::SOAP::Header::Security'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = version->new('0.11'); |
24
|
|
|
|
|
|
|
my $id = 0; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has username => ( |
27
|
|
|
|
|
|
|
is => 'rw', |
28
|
|
|
|
|
|
|
isa => 'Str', |
29
|
|
|
|
|
|
|
required => 1, |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
has password => ( |
32
|
|
|
|
|
|
|
is => 'rw', |
33
|
|
|
|
|
|
|
isa => 'Str', |
34
|
|
|
|
|
|
|
required => 1, |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Moose 2 |
38
|
|
|
|
|
|
|
#argument to_xml => sub { |
39
|
|
|
|
|
|
|
sub to_xml { |
40
|
0
|
|
|
0
|
1
|
|
my ($self, $xml) = @_; |
41
|
0
|
|
|
|
|
|
my $uname_token = $xml->createElement('wsse:UsernameToken'); |
42
|
0
|
|
|
|
|
|
$uname_token->setAttribute('xmlns:wsu' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd'); |
43
|
0
|
|
|
|
|
|
$uname_token->setAttribute('wsu:Id', 'UsernameToken-' . $id++); |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $username = $xml->createElement('wsse:Username'); |
46
|
0
|
|
|
|
|
|
$username->appendChild( $xml->createTextNode($self->username) ); |
47
|
0
|
|
|
|
|
|
$uname_token->appendChild($username); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $password = $xml->createElement('wsse:Password'); |
50
|
0
|
|
|
|
|
|
$password->appendChild( $xml->createTextNode($self->password) ); |
51
|
0
|
|
|
|
|
|
$password->setAttribute('Type' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText'); |
52
|
0
|
|
|
|
|
|
$uname_token->appendChild($password); |
53
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my $nonce_text = ''; |
55
|
0
|
|
|
|
|
|
$nonce_text .= ('a'..'z','A'..'Z',0..9)[rand 62] for 1 .. 24; |
56
|
0
|
|
|
|
|
|
my $nonce = $xml->createElement('wsse:Nonce'); |
57
|
0
|
|
|
|
|
|
$nonce->appendChild( $xml->createTextNode($nonce_text.'==') ); |
58
|
0
|
|
|
|
|
|
$nonce->setAttribute('EncodingType' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary'); |
59
|
0
|
|
|
|
|
|
$uname_token->appendChild($nonce); |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my ($seconds, $microseconds) = gettimeofday; |
62
|
|
|
|
|
|
|
#TODO is the following nessesary? |
63
|
0
|
|
|
|
|
|
$microseconds =~ s{^(\d\d\d).*}{$1}; |
64
|
0
|
|
|
|
|
|
my $date_text = DateTime->now->set_time_zone("Z") . ".${microseconds}Z"; |
65
|
0
|
|
|
|
|
|
my $date = $xml->createElement('wsu:Created'); |
66
|
0
|
|
|
|
|
|
$date->appendChild( $xml->createTextNode($date_text) ); |
67
|
0
|
|
|
|
|
|
$uname_token->appendChild($date); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Moose 1 |
70
|
0
|
|
|
|
|
|
my $sec = $self->SUPER::to_xml($xml); |
71
|
0
|
|
|
|
|
|
$sec->appendChild($uname_token); |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
return $sec; |
74
|
|
|
|
|
|
|
# Moose 2 |
75
|
|
|
|
|
|
|
#return $uname_token; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
__END__ |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 NAME |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
W3C::SOAP::Header::Security::Username - Creates a WS-Security User name object |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 VERSION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
This documentation refers to W3C::SOAP::Header::Security::Username version 0.11. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SYNOPSIS |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
use W3C::SOAP::Header::Security::Username; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Brief but working code example(s) here showing the most common usage(s) |
95
|
|
|
|
|
|
|
# This section will be as far as many users bother reading, so make it as |
96
|
|
|
|
|
|
|
# educational and exemplary as possible. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 DESCRIPTION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=over 4 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=item C<to_xml ($xml)> |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Coverts this object to XML |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=back |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 DIAGNOSTICS |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 CONFIGURATION AND ENVIRONMENT |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
There are no known bugs in this module. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Please report problems to Ivan Wills - (ivan.wills@gmail.com) |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Patches are welcome. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head1 AUTHOR |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Ivan Wills - (ivan.wills@gmail.com) |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Copyright (c) 2012 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). |
135
|
|
|
|
|
|
|
All rights reserved. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
138
|
|
|
|
|
|
|
the same terms as Perl itself. See L<perlartistic>. This program is |
139
|
|
|
|
|
|
|
distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
140
|
|
|
|
|
|
|
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
141
|
|
|
|
|
|
|
PARTICULAR PURPOSE. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |