OxdPackages/GetClientToken.pm untested

filter: Statementstmt 0.0% 0 / 64 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 22 Podpod 0.0% 0 / 17 totaltotal 0.0% 0 / 111 CC 5 SCAR 11.7
CC
5
Cov
0%
setRequestClientSecret
6.0
setRequestClientId
6.0
setRequestOpHost
6.0
CRAP 3.2
1 #!/usr/bin/perl
2 # GetClientToken.pm, a number as an object
3
4 #
5 # Gluu-oxd-library
6 #
7 # An open source application library for Perl
8 #
9 # This content is released under the MIT License (MIT)
10 #
11 # Copyright (c) 2017, Gluu inc, USA, Austin
12 #
13 # Permission is hereby granted, free of charge, to any person obtaining a copy
14 # of this software and associated documentation files (the "Software"), to deal
15 # in the Software without restriction, including without limitation the rights
16 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 # copies of the Software, and to permit persons to whom the Software is
18 # furnished to do so, subject to the following conditions:
19 #
20 # The above copyright notice and this permission notice shall be included in
21 # all copies or substantial portions of the Software.
22 #
23 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 # THE SOFTWARE.
30 #
31 # @package Gluu-oxd-library
32 # @version 3.1.0
33 # @author Sobhan Panda
34 # @author_email sobhan@centroxy.com
35 # @copyright Copyright (c) 2017, Gluu inc federation (https://gluu.org/)
36 # @license http://opensource.org/licenses/MIT MIT License
37 # @link https://gluu.org/
38 # @since Version 3.1.0
39 # @filesource
40 #/
41
42 use JSON::PP;
43
44 package GetClientToken; # This is the "Class"
45 use vars qw($VERSION);
46 $VERSION = '0.01';
47
48 use OxdPackages::OxdClient;
49 use base qw(OxdClient Class::Accessor);
50 #use base 'OxdClient';
51 use strict;
52 our @ISA = qw(OxdClient); # inherits from OxdClient
53
54 sub new {
55 my $class = shift;
56
57 my $self = {
58
59 # @var string _request_op_host Gluu server url
60 _request_op_host => shift,
61
62 # @var array _request_acr_values Gluu login acr type, can be basic, duo, u2f, gplus and etc.
63 _request_acr_values => [],
64
65 # @var string _request_authorization_redirect_uri Site authorization redirect uri
66 _request_authorization_redirect_uri => shift,
67
68 # @var string _request_post_logout_redirect_uri Site logout redirect uri
69 _request_post_logout_redirect_uri => shift,
70
71 # @var array _request_contacts
72 _request_contacts => shift,
73
74 # @var array _request_grant_types OpenID Token Request type
75 _request_grant_types => [],
76
77 #@var array _request_response_types OpenID Authentication response types
78 _request_response_types => [],
79
80 # @var array _request_scope For getting needed scopes from gluu-server
81 _request_scope => [],
82
83 # @var string _request_application_type web or mobile
84 _request_application_type => shift,
85
86 # @var string _request_client_id OpenID provider client id
87 _request_client_id => shift,
88
89 # @var string _request_client_name OpenID provider client name
90 _request_client_name => shift,
91
92 # @var string _request_client_secret OpenID provider client secret
93 _request_client_secret => shift,
94
95
96
97 # Response parameter from oxd-server
98 # It is basic parameter for other protocols
99 #
100 # @var string _response_access_token
101 _response_access_token => shift,
102
103 # @var string _response_expires_in
104 _response_expires_in => shift,
105
106 # @var string _response_refresh_token
107 _response_refresh_token => shift,
108
109 # Response parameter from oxd-server
110 #
111 # @var string _response_scope
112 _response_scope => shift,
113 };
114 #print "<br>";
115 bless $self, $class;
116 return $self;
117 }
118 sub _initialize {}
119
120 # @return string
121 sub getRequestClientSecret{
122 my( $self ) = @_;
123 return $self->{_request_client_secret};
124 }
125
126 # @param string $request_client_secret
127 sub setRequestClientSecret{
128 my ( $self, $request_client_secret ) = @_;
129 $self->{_request_client_secret} = $request_client_secret if defined($request_client_secret);
130 return $self->{_request_client_secret};
131 }
132
133 # @return string
134 sub getRequestClientId{
135 my( $self ) = @_;
136 return $self->{_request_client_id};
137 }
138
139 # @param string $request_client_id
140 sub setRequestClientId{
141 my ( $self, $request_client_id ) = @_;
142 $self->{_request_client_id} = $request_client_id if defined($request_client_id);
143 return $self->{_request_client_id};
144 }
145
146 # @param string $request_op_host
147 # @return void
148 sub setRequestOpHost {
149 my ( $self, $request_op_host ) = @_;
150 $self->{_request_op_host} = $request_op_host if defined($request_op_host);
151 return $self->{_request_op_host};
152 }
153
154 # @return string
155 sub getRequestOpHost {
156 my( $self ) = @_;
157 return $self->{_request_op_host};
158 }
159
160 # @return array
161 sub getRequestOpDiscoveryPath{
162 my( $self ) = @_;
163 return $self->{_request_op_discovery_path};
164 }
165
166 # @param array $request_op_discovery_path
167 # @return void
168 sub setRequestOpDiscoveryPath{
169 my ( $self, $request_op_discovery_path ) = @_;
170 $self->{_request_op_discovery_path} = $request_op_discovery_path if defined($request_op_discovery_path);
171 return $self->{_request_op_discovery_path};
172 }
173
174 # @return string
175 sub getResponseAccessToken {
176 my( $self ) = @_;
177 $self->{_response_access_token} = $self->getResponseData()->{access_token};
178 return $self->{_response_access_token};
179 }
180
181 # @return int
182 sub getResponseExpiresIn {
183 my( $self ) = @_;
184 $self->{_response_expires_in} = $self->getResponseData()->{expires_in};
185 return $self->{_response_expires_in};
186 }
187
188 # @return string
189 sub getResponseRefreshToken {
190 my( $self ) = @_;
191 $self->{_response_refresh_token} = $self->getResponseData()->{refresh_token};
192 return $self->{_response_refresh_token};
193 }
194
195 # @return string
196 sub getResponseScope {
197 my( $self ) = @_;
198 $self->{_response_scope} = $self->getResponseData()->{scope};
199 return $self->{_response_scope};
200 }
201
202 # Protocol command to oxd server
203 # @return void
204 sub setCommand{
205 # my $command = 'get_client_token';
206 my ( $self, $command ) = @_;
207 $self->{_command} = 'get_client_token';
208 return $self->{_command};
209 #return $command;
210 }
211
212 # Protocol command to oxd to http server
213 # @return void
214 sub sethttpCommand{
215 # my $httpCommand = 'get-client-token';
216 my ( $self, $httpCommand ) = @_;
217 $self->{_httpcommand} = 'get-client-token';
218 return $self->{_httpcommand};
219 #return $httpcommand;
220 }
221
222 # Protocol parameter to oxd server
223 # @return void
224 sub setParams{
225
226 my ( $self, $params ) = @_;
227 #use Data::Dumper;
228 my $paramsArray = {
229 "client_id"=> $self->getRequestClientId(),
230 "client_secret"=> $self->getRequestClientSecret(),
231 "op_host" => $self->getRequestOpHost(),
232 "op_discovery_path" => $self->getRequestOpDiscoveryPath()
233 };
234
235 $self->{_params} = $paramsArray;
236 return $self->{_params};
237 #print Dumper( $params );
238 #return $paramsArray;
239 }
240
241 1; # this 1; is neccessary for our class to work