| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Sakai::Nakamura::GroupMember; |
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
1154
|
use 5.008008; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
40
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
30
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
20
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
69
|
|
|
9
|
1
|
|
|
1
|
|
1187
|
use Getopt::Long qw(:config bundling); |
|
|
1
|
|
|
|
|
11429
|
|
|
|
1
|
|
|
|
|
6
|
|
|
10
|
1
|
|
|
1
|
|
203
|
use Sakai::Nakamura; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
36
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use Sakai::Nakamura::Authn; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
29
|
|
|
12
|
1
|
|
|
1
|
|
678
|
use Sakai::Nakamura::GroupMemberUtil; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
46
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
require Exporter; |
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
4
|
use base qw(Exporter); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
754
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @EXPORT_OK = (); |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#{{{sub new |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
|
25
|
1
|
|
|
1
|
1
|
15
|
my ( $class, $authn, $verbose, $log ) = @_; |
|
26
|
1
|
50
|
|
|
|
7
|
if ( !defined $authn ) { croak 'no authn provided!'; } |
|
|
0
|
|
|
|
|
0
|
|
|
27
|
1
|
|
|
|
|
1
|
my $response; |
|
28
|
1
|
50
|
|
|
|
5
|
$verbose = ( defined $verbose ? $verbose : 0 ); |
|
29
|
1
|
|
|
|
|
15
|
my $group_member = { |
|
30
|
1
|
|
|
|
|
3
|
BaseURL => ${$authn}->{'BaseURL'}, |
|
31
|
|
|
|
|
|
|
Authn => $authn, |
|
32
|
|
|
|
|
|
|
Message => q{}, |
|
33
|
|
|
|
|
|
|
Response => \$response, |
|
34
|
|
|
|
|
|
|
Verbose => $verbose, |
|
35
|
|
|
|
|
|
|
Log => $log |
|
36
|
|
|
|
|
|
|
}; |
|
37
|
1
|
|
|
|
|
3
|
bless $group_member, $class; |
|
38
|
1
|
|
|
|
|
4
|
return $group_member; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
#}}} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#{{{sub set_results |
|
44
|
|
|
|
|
|
|
sub set_results { |
|
45
|
1
|
|
|
1
|
0
|
3058
|
my ( $group, $message, $response ) = @_; |
|
46
|
1
|
|
|
|
|
4
|
$group->{'Message'} = $message; |
|
47
|
1
|
|
|
|
|
3
|
$group->{'Response'} = $response; |
|
48
|
1
|
|
|
|
|
4
|
return 1; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
#}}} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
#{{{sub add |
|
54
|
|
|
|
|
|
|
sub add { |
|
55
|
0
|
|
|
0
|
1
|
|
my ( $group, $act_on_group, $act_on_role, $add_member ) = @_; |
|
56
|
0
|
|
|
|
|
|
my $res = Apache::Sling::Request::request( |
|
57
|
|
|
|
|
|
|
\$group, |
|
58
|
|
|
|
|
|
|
Sakai::Nakamura::GroupMemberUtil::add_setup( |
|
59
|
|
|
|
|
|
|
$group->{'BaseURL'}, $act_on_group, $act_on_role, $add_member |
|
60
|
|
|
|
|
|
|
) |
|
61
|
|
|
|
|
|
|
); |
|
62
|
0
|
|
|
|
|
|
my $success = Sakai::Nakamura::GroupMemberUtil::add_eval($res); |
|
63
|
0
|
|
|
|
|
|
my $message = "Member: \"$add_member\" "; |
|
64
|
0
|
0
|
|
|
|
|
$message .= ( $success ? 'added' : 'was not added' ); |
|
65
|
0
|
|
|
|
|
|
$message .= " to role \"$act_on_role\" in group \"$act_on_group\"!"; |
|
66
|
0
|
|
|
|
|
|
$group->set_results( "$message", $res ); |
|
67
|
0
|
|
|
|
|
|
return $success; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#}}} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#{{{sub add_from_file |
|
73
|
|
|
|
|
|
|
sub add_from_file { |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# TODO implement |
|
76
|
0
|
|
|
0
|
1
|
|
return 1; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#}}} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#{{{sub check_exists |
|
82
|
|
|
|
|
|
|
sub check_exists { |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# TODO implement |
|
85
|
0
|
|
|
0
|
1
|
|
return 1; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
#}}} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
#{{{ sub command_line |
|
91
|
|
|
|
|
|
|
sub command_line { |
|
92
|
0
|
|
|
0
|
0
|
|
my ( $class, @ARGV ) = @_; |
|
93
|
0
|
|
|
|
|
|
my $nakamura = Sakai::Nakamura->new; |
|
94
|
0
|
|
|
|
|
|
my $config = $class->config( $nakamura, @ARGV ); |
|
95
|
0
|
|
|
|
|
|
my $authn = new Sakai::Nakamura::Authn( \$nakamura ); |
|
96
|
0
|
|
|
|
|
|
return $class->run( $nakamura, $config ); |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
#}}} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
#{{{sub config |
|
102
|
|
|
|
|
|
|
# TODO add config options: |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub config { |
|
105
|
0
|
|
|
0
|
0
|
|
my ( $class, $nakamura, @ARGV ) = @_; |
|
106
|
0
|
|
|
|
|
|
my $group_member_config = $class->config_hash( $nakamura, @ARGV ); |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
GetOptions( $group_member_config ) or $class->help(); |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
return $group_member_config; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
#}}} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
#{{{sub config_hash |
|
116
|
|
|
|
|
|
|
# TODO add config options: |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub config_hash { |
|
119
|
0
|
|
|
0
|
0
|
|
my ( $class, $nakamura, @ARGV ) = @_; |
|
120
|
0
|
|
|
|
|
|
my %group_member_config = (); |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
return \%group_member_config; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
#}}} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
#{{{sub del |
|
128
|
|
|
|
|
|
|
sub del { |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# TODO implement |
|
131
|
0
|
|
|
0
|
1
|
|
return 1; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
#}}} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
#{{{ sub help |
|
137
|
|
|
|
|
|
|
sub help { |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# TODO: implement |
|
140
|
|
|
|
|
|
|
|
|
141
|
0
|
|
|
0
|
0
|
|
print <<"EOF"; |
|
142
|
|
|
|
|
|
|
Usage: perl $0 [-OPTIONS [-MORE_OPTIONS]] [--] [PROGRAM_ARG1 ...] |
|
143
|
|
|
|
|
|
|
The following options are accepted: |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Options may be merged together. -- stops processing of options. |
|
146
|
|
|
|
|
|
|
Space is not required between options and their arguments. |
|
147
|
|
|
|
|
|
|
For full details run: perl $0 --man |
|
148
|
|
|
|
|
|
|
EOF |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
return 1; |
|
151
|
|
|
|
|
|
|
} |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
#}}} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
#{{{ sub man |
|
156
|
|
|
|
|
|
|
sub man { |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
# TODO: implement |
|
159
|
0
|
|
|
0
|
0
|
|
my ($group_member) = @_; |
|
160
|
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
print <<'EOF'; |
|
162
|
|
|
|
|
|
|
group membership perl script. Provides a means of managing role members in nakamura from the command |
|
163
|
|
|
|
|
|
|
line. The script also acts as a reference implementation for the Group Member perl |
|
164
|
|
|
|
|
|
|
library. |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
EOF |
|
167
|
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
$group_member->help(); |
|
169
|
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
print <<"EOF"; |
|
171
|
|
|
|
|
|
|
Example Usage |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
* TODO: add examples |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
perl $0 -U http://localhost:8080 -u admin -p admin |
|
176
|
|
|
|
|
|
|
EOF |
|
177
|
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
return 1; |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
#}}} |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
#{{{sub run |
|
184
|
|
|
|
|
|
|
sub run { |
|
185
|
0
|
|
|
0
|
0
|
|
my ( $group_member, $nakamura, $config ) = @_; |
|
186
|
0
|
0
|
|
|
|
|
if ( !defined $config ) { |
|
187
|
0
|
|
|
|
|
|
croak 'No group member config supplied!'; |
|
188
|
|
|
|
|
|
|
} |
|
189
|
0
|
|
|
|
|
|
$nakamura->check_forks; |
|
190
|
0
|
|
|
|
|
|
my $authn = |
|
191
|
|
|
|
|
|
|
defined $nakamura->{'Authn'} |
|
192
|
0
|
0
|
|
|
|
|
? ${ $nakamura->{'Authn'} } |
|
193
|
|
|
|
|
|
|
: new Sakai::Nakamura::Authn( \$nakamura ); |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
my $success = 1; |
|
196
|
|
|
|
|
|
|
|
|
197
|
0
|
0
|
|
|
|
|
if ( $nakamura->{'Help'} ) { $group_member->help(); } |
|
|
0
|
0
|
|
|
|
|
|
|
198
|
0
|
|
|
|
|
|
elsif ( $nakamura->{'Man'} ) { $group_member->man(); } |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
# TODO: implement |
|
201
|
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
|
return $success; |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
#}}} |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
#{{{sub view |
|
208
|
|
|
|
|
|
|
sub view { |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
# TODO implement |
|
211
|
0
|
|
|
0
|
1
|
|
return 1; |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
#}}} |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
1; |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
__END__ |