line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright 2011, Google Inc. All Rights Reserved. |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); |
4
|
|
|
|
|
|
|
# you may not use this file except in compliance with the License. |
5
|
|
|
|
|
|
|
# You may obtain a copy of the License at |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# Unless required by applicable law or agreed to in writing, software |
10
|
|
|
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
11
|
|
|
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12
|
|
|
|
|
|
|
# See the License for the specific language governing permissions and |
13
|
|
|
|
|
|
|
# limitations under the License. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
package Google::Ads::Common::AuthHandlerInterface; |
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
977
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
58
|
|
18
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
267
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Initializes the handler with a given set of properties and the API client |
21
|
|
|
|
|
|
|
# object. |
22
|
|
|
|
|
|
|
sub initialize { |
23
|
0
|
|
|
0
|
1
|
|
my ($self, $api_client, $properties) = @_; |
24
|
0
|
|
|
|
|
|
die "Needs to be implemented by subclass"; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Method that given an HTTP:Request prepares it with the relevant |
28
|
|
|
|
|
|
|
# authorization data (i.e. headers, protected resource url, etc). |
29
|
|
|
|
|
|
|
sub prepare_request { |
30
|
0
|
|
|
0
|
1
|
|
my ($self, $endpoint, $http_headers, $envelope) = @_; |
31
|
0
|
|
|
|
|
|
die "Needs to be implemented by subclass"; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Returns true if the handler can prepare request with the appropiate |
35
|
|
|
|
|
|
|
# authorization info. |
36
|
|
|
|
|
|
|
sub is_auth_enabled { |
37
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
38
|
0
|
|
|
|
|
|
die "Needs to be implemented by subclass"; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=pod |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Google::Ads::Common::AuthHandlerInterface |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 DESCRIPTION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Interface to be implemented by concrete authorization handlers. Defines the |
52
|
|
|
|
|
|
|
necessary subroutines to build authorized request against a Google API. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 METHODS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 initialize |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Initializes the handler with a given set of properties. Used to pass parameters |
59
|
|
|
|
|
|
|
such as: client ids, access tokens, etc. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head3 Parameters |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=over |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=item * |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
A required I with a reference to the API client object handling the |
68
|
|
|
|
|
|
|
requests against the API. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
A required I with a reference to a hash of properties. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=back |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 prepare_request |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Constructs a L valid to send an authorized request to the API. |
79
|
|
|
|
|
|
|
Implementors will attach authorization headers to the request at this phase. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head3 Parameters |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=over |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
I: URL to the resource to access. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
I: a map of HTTP headers to be included in the request. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item * |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
I: a string with the payload to be send in the request. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 is_auth_enabled |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Method called to check if the authorization has already been setup, so the |
102
|
|
|
|
|
|
|
I method can be called. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head3 Returns |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
True, if the authorization is in place and the class can prepare requests. |
107
|
|
|
|
|
|
|
False, otherwise. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Copyright 2012 Google Inc. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); |
114
|
|
|
|
|
|
|
you may not use this file except in compliance with the License. |
115
|
|
|
|
|
|
|
You may obtain a copy of the License at |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0 |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software |
120
|
|
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS, |
121
|
|
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
122
|
|
|
|
|
|
|
See the License for the specific language governing permissions and |
123
|
|
|
|
|
|
|
limitations under the License. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 REPOSITORY INFORMATION |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
$Rev: $ |
128
|
|
|
|
|
|
|
$LastChangedBy: $ |
129
|
|
|
|
|
|
|
$Id: $ |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=cut |