line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Sakai::Nakamura::AuthnUtil; |
4
|
|
|
|
|
|
|
|
5
|
8
|
|
|
8
|
|
65484
|
use 5.008008; |
|
8
|
|
|
|
|
43
|
|
|
8
|
|
|
|
|
355
|
|
6
|
8
|
|
|
8
|
|
46
|
use strict; |
|
8
|
|
|
|
|
16
|
|
|
8
|
|
|
|
|
304
|
|
7
|
8
|
|
|
8
|
|
45
|
use warnings; |
|
8
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
267
|
|
8
|
8
|
|
|
8
|
|
52
|
use Carp; |
|
8
|
|
|
|
|
17
|
|
|
8
|
|
|
|
|
694
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
|
12
|
8
|
|
|
8
|
|
55
|
use base qw(Exporter); |
|
8
|
|
|
|
|
14
|
|
|
8
|
|
|
|
|
3812
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @EXPORT_OK = (); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#{{{sub form_login_setup |
19
|
|
|
|
|
|
|
sub form_login_setup { |
20
|
4
|
|
|
4
|
1
|
7527
|
my ( $base_url, $username, $password ) = @_; |
21
|
4
|
100
|
|
|
|
16
|
if ( !defined $base_url ) { croak 'No base url defined!'; } |
|
1
|
|
|
|
|
25
|
|
22
|
3
|
100
|
|
|
|
13
|
if ( !defined $username ) { |
23
|
1
|
|
|
|
|
14
|
croak 'No username supplied to attempt logging in with!'; |
24
|
|
|
|
|
|
|
} |
25
|
2
|
100
|
|
|
|
15
|
if ( !defined $password ) { |
26
|
1
|
|
|
|
|
19
|
croak |
27
|
|
|
|
|
|
|
"No password supplied to attempt logging in with for user name: $username!"; |
28
|
|
|
|
|
|
|
} |
29
|
1
|
|
|
|
|
5
|
my $post_variables = |
30
|
|
|
|
|
|
|
"\$post_variables = ['sakaiauth:un','$username','sakaiauth:pw','$password','sakaiauth:login','1']"; |
31
|
1
|
|
|
|
|
10
|
return "post $base_url/system/sling/formlogin $post_variables"; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#}}} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
#{{{sub form_login_eval |
37
|
|
|
|
|
|
|
sub form_login_eval { |
38
|
1
|
|
|
1
|
1
|
4
|
my ($res) = @_; |
39
|
1
|
|
|
|
|
2
|
return ( ${$res}->code eq '200' ); |
|
1
|
|
|
|
|
5
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#}}} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#{{{sub form_logout_setup |
45
|
|
|
|
|
|
|
sub form_logout_setup { |
46
|
2
|
|
|
2
|
1
|
2647
|
my ($base_url) = @_; |
47
|
2
|
100
|
|
|
|
8
|
if ( !defined $base_url ) { croak 'No base url defined!'; } |
|
1
|
|
|
|
|
14
|
|
48
|
1
|
|
|
|
|
22
|
return "get $base_url/system/sling/logout?resource=/index"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#}}} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#{{{sub form_logout_eval |
54
|
|
|
|
|
|
|
sub form_logout_eval { |
55
|
1
|
|
|
1
|
1
|
282
|
my ($res) = @_; |
56
|
1
|
|
|
|
|
2
|
return ( ${$res}->code eq '200' ); |
|
1
|
|
|
|
|
4
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
#}}} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |