OxdPackages/OxdConfig.pm

filter: Statementstmt 9.1% 14 / 153 Branchbran 0.0% 0 / 46 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 10.5% 4 / 38 Podpod n/a totaltotal 7.4% 18 / 242 CC 25 SCAR 28.2
CC
25
Cov
7%
json_read
90.0
setOpHost
6.0
setOxdHostPort
6.0
CRAP 16.8
↑ Summary OxdPackages/UpdateRegistration.pm »
1 #!/usr/bin/perl
2 # OxdConfig.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 Ourdesignz, Sobhan Panda
34 # @author gaurav.chhabra6785@gmail.com, 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 #
43 # Oxd RP config
44 #
45 # Class OxdConfig, setting all configuration
46 #
47 # @package Gluu-oxd-library
48 # @subpackage Libraries
49 # @category Base class for all protocols
50 # @author Ourdesignz
51 # @author gaurav.chhabra6785@gmail.com
52 #/
53 package OxdConfig;
54 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
55 1 $VERSION = '0.01';
56 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 1 ▶use JSON::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
59
60 0 ▶sub new{
Subroutine new: not called CC=1 SCAR=6.9
61 0 my $class = shift;
62
63 0 my $self = {
64
65 # @static
66 # @var string $op_host Gluu server url, which need to connect
67 _op_host => shift,
68
69 # @static
70 # @var int $oxd_host_port Socket connection port
71 _oxd_host_port => shift,
72
73 # @static
74 # @var string $authorization_redirect_uri Site authorization redirect uri
75 _authorization_redirect_uri => shift,
76
77 # @static
78 # @var string $post_logout_redirect_uri Site logout redirect uri
79 _post_logout_redirect_uri => shift,
80
81 # @static
82 # @var string $client_frontchannel_logout_uris Client logout uri
83 _client_frontchannel_logout_uris => shift,
84 # @static
85 # @var array $scope For getting needed scopes from gluu-server
86 _scope => shift,
87
88 # @static
89 # @var string $application_type web or mobile
90 _application_type => shift,
91
92 # @static
93 # @var array $response_types OpenID Authentication response types
94 _response_types => shift,
95
96 # @static
97 # @var array $grant_types OpenID Token Request type
98 _grant_types => shift,
99
100 # @static
101 # @var array $acr_values Gluu login acr type, can be basic, duo, u2f, gplus and etc.
102 _acr_values => shift,
103
104 # @static
105 # @var array $rest_service_url Gluu rest service url
106 _rest_service_url => shift,
107
108 # @static
109 # @var array $connection_type Connection type, can be Socket or http.
110 _connection_type => shift,
111
112 _oxd_id => shift,
113 _client_name => shift,
114 _client_id => shift,
115 _client_secret => shift,
116 };
117
118 # Print all the values just for clarification.
119 #print "OP HOST is :". $self->{_op_host};
120 #print "<br>";
121 #print "OXD HOST PORT is :".$self->{_oxd_host_port};
122 0 our $oxdHostPort;
123 0 $oxdHostPort = 'package';
124
125 0 bless $self, $class;
126 0 $self->json_read;
127 0 return $self;
128 }
129
130 0 ▶sub setOpHost {
Subroutine setOpHost: not called CC=2 SCAR=17.9
131 #my ( $self, $op_host,$oxd_host_port,$authorization_redirect_uri,$post_logout_redirect_uri,$scope,$application_type,$response_types,$grant_types,$acr_values ) = @_;
132 0 my ( $self, $op_host ) = @_;
133 0 ▶ $self->{_op_host} = $op_host if defined($op_host);
Branch: 1 branch
BranchTrueFalseTotal
if defined $op_host 0 0 0
134 0 return $self->{_op_host};
135 }
136
137 0 ▶sub getOpHost {
Subroutine getOpHost: not called CC=1 SCAR=6.9
138 0 my( $self ) = @_;
139 0 return $self->{_op_host};
140 }
141
142 0 ▶sub setOxdHostPort {
Subroutine setOxdHostPort: not called CC=2 SCAR=17.9
143 0 my ( $self, $oxd_host_port ) = @_;
144 0 ▶ $self->{_oxd_host_port} = $oxd_host_port if defined($oxd_host_port);
Branch: 1 branch
BranchTrueFalseTotal
if defined $oxd_host_port 0 0 0
145 0 return $self->{_oxd_host_port};
146 }
147
148 0 ▶sub getOxdHostPort {
Subroutine getOxdHostPort: not called CC=1 SCAR=6.9
149 0 my( $self ) = @_;
150 0 return $self->{_oxd_host_port};
151 }
152
153 0 ▶sub setAuthorizationRedirectUrl {
Subroutine setAuthorizationRedirectUrl: not called CC=2 SCAR=17.9
154 0 my ( $self, $authorization_redirect_uri ) = @_;
155 0 ▶ $self->{_authorization_redirect_uri} = $authorization_redirect_uri if defined($authorization_redirect_uri);
Branch: 1 branch
BranchTrueFalseTotal
if defined $authorization_redirect_uri 0 0 0
156 0 return $self->{_authorization_redirect_uri};
157 }
158
159 0 ▶sub getAuthorizationRedirectUrl {
Subroutine getAuthorizationRedirectUrl: not called CC=1 SCAR=6.9
160 0 my( $self ) = @_;
161 0 return $self->{_authorization_redirect_uri};
162 }
163
164 0 ▶sub setPostLogoutRedirectUrl {
Subroutine setPostLogoutRedirectUrl: not called CC=2 SCAR=17.9
165 0 my ( $self, $post_logout_redirect_uri ) = @_;
166 0 ▶ $self->{_post_logout_redirect_uri} = $post_logout_redirect_uri if defined($post_logout_redirect_uri);
Branch: 1 branch
BranchTrueFalseTotal
if defined $post_logout_redirect_uri 0 0 0
167 0 return $self->{_post_logout_redirect_uri};
168 }
169
170 0 ▶sub getPostLogoutRedirectUrl {
Subroutine getPostLogoutRedirectUrl: not called CC=1 SCAR=6.9
171 0 my( $self ) = @_;
172 0 return $self->{_post_logout_redirect_uri};
173 }
174
175
176 0 ▶sub setClientFrontChannelLogoutUris {
Subroutine setClientFrontChannelLogoutUris: not called CC=2 SCAR=17.9
177 0 my ( $self, $client_frontchannel_logout_uris ) = @_;
178 0 ▶ $self->{_client_frontchannel_logout_uris} = $client_frontchannel_logout_uris if defined($client_frontchannel_logout_uris);
Branch: 1 branch
BranchTrueFalseTotal
if defined $client_frontchannel_logout_uris 0 0 0
179 0 return $self->{_client_frontchannel_logout_uris};
180 }
181
182 0 ▶sub getClientFrontChannelLogoutUris {
Subroutine getClientFrontChannelLogoutUris: not called CC=1 SCAR=6.9
183 0 my( $self ) = @_;
184 0 return $self->{_client_frontchannel_logout_uris};
185 }
186
187
188 0 ▶sub setScope {
Subroutine setScope: not called CC=2 SCAR=17.9
189 0 my ( $self, $scope ) = @_;
190 0 ▶ $self->{_scope} = $scope if defined($scope);
Branch: 1 branch
BranchTrueFalseTotal
if defined $scope 0 0 0
191 0 return $self->{_scope};
192 }
193
194 0 ▶sub getScope {
Subroutine getScope: not called CC=1 SCAR=6.9
195 0 my( $self ) = @_;
196 0 return $self->{_scope};
197 }
198
199 0 ▶sub setApplicationType {
Subroutine setApplicationType: not called CC=2 SCAR=17.9
200 0 my ( $self, $application_type ) = @_;
201 0 ▶ $self->{_application_type} = $application_type if defined($application_type);
Branch: 1 branch
BranchTrueFalseTotal
if defined $application_type 0 0 0
202 0 return $self->{_application_type};
203 }
204
205 0 ▶sub getApplicationType {
Subroutine getApplicationType: not called CC=1 SCAR=6.9
206 0 my( $self ) = @_;
207 0 return $self->{_application_type};
208 }
209
210 0 ▶sub setResponseType {
Subroutine setResponseType: not called CC=2 SCAR=17.9
211 0 my ( $self, $response_types ) = @_;
212 0 ▶ $self->{_response_types} = $response_types if defined($response_types);
Branch: 1 branch
BranchTrueFalseTotal
if defined $response_types 0 0 0
213 0 return $self->{_response_types};
214 }
215
216 0 ▶sub getResponseType {
Subroutine getResponseType: not called CC=1 SCAR=6.9
217 0 my( $self ) = @_;
218 0 return $self->{_response_types};
219 }
220
221 0 ▶sub setGrantTypes {
Subroutine setGrantTypes: not called CC=2 SCAR=17.9
222 0 my ( $self, $grant_types ) = @_;
223 0 ▶ $self->{_grant_types} = $grant_types if defined($grant_types);
Branch: 1 branch
BranchTrueFalseTotal
if defined $grant_types 0 0 0
224 0 return $self->{_grant_types};
225 }
226
227 0 ▶sub getGrantTypes {
Subroutine getGrantTypes: not called CC=1 SCAR=6.9
228 0 my( $self ) = @_;
229 0 return $self->{_grant_types};
230 }
231
232 0 ▶sub setAcrValues {
Subroutine setAcrValues: not called CC=2 SCAR=17.9
233 0 my ( $self, $acr_values ) = @_;
234 0 ▶ $self->{_acr_values} = $acr_values if defined($acr_values);
Branch: 1 branch
BranchTrueFalseTotal
if defined $acr_values 0 0 0
235 0 return $self->{_acr_values};
236 }
237
238 0 ▶sub getAcrValues {
Subroutine getAcrValues: not called CC=1 SCAR=6.9
239 0 my( $self ) = @_;
240 0 return $self->{_acr_values};
241 }
242
243 0 ▶sub setRestServiceUrl {
Subroutine setRestServiceUrl: not called CC=2 SCAR=17.9
244 0 my ( $self, $rest_service_url ) = @_;
245 0 ▶ $self->{_rest_service_url} = $rest_service_url if defined($rest_service_url);
Branch: 1 branch
BranchTrueFalseTotal
if defined $rest_service_url 0 0 0
246 0 return $self->{_rest_service_url};
247 }
248
249 0 ▶sub getRestServiceUrl {
Subroutine getRestServiceUrl: not called CC=1 SCAR=6.9
250 0 my( $self ) = @_;
251 0 return $self->{_rest_service_url};
252 }
253
254 0 ▶sub setConnectionType {
Subroutine setConnectionType: not called CC=2 SCAR=17.9
255 0 my ( $self, $connection_type ) = @_;
256 0 ▶ $self->{_connection_type} = $connection_type if defined($connection_type);
Branch: 1 branch
BranchTrueFalseTotal
if defined $connection_type 0 0 0
257 0 return $self->{_connection_type};
258 }
259
260 0 ▶sub getConnectionType {
Subroutine getConnectionType: not called CC=1 SCAR=6.9
261 0 my( $self ) = @_;
262 0 return $self->{_connection_type};
263 }
264
265
266 0 ▶sub setOxdId {
Subroutine setOxdId: not called CC=2 SCAR=17.9
267 0 my ( $self, $oxd_id ) = @_;
268 0 ▶ $self->{_oxd_id} = $oxd_id if defined($oxd_id);
Branch: 1 branch
BranchTrueFalseTotal
if defined $oxd_id 0 0 0
269 0 return $self->{_oxd_id};
270 }
271
272 0 ▶sub getOxdId {
Subroutine getOxdId: not called CC=1 SCAR=6.9
273 0 my( $self ) = @_;
274 0 return $self->{_oxd_id};
275 }
276
277
278 0 ▶sub setClientName {
Subroutine setClientName: not called CC=2 SCAR=17.9
279 0 my ( $self, $clientName ) = @_;
280 0 ▶ $self->{_client_name} = $clientName if defined($clientName);
Branch: 1 branch
BranchTrueFalseTotal
if defined $clientName 0 0 0
281 0 return $self->{_client_name};
282 }
283
284 0 ▶sub getClientName {
Subroutine getClientName: not called CC=1 SCAR=6.9
285 0 my( $self ) = @_;
286 0 return $self->{_client_name};
287 }
288
289
290 0 ▶sub setClientId {
Subroutine setClientId: not called CC=2 SCAR=17.9
291 0 my ( $self, $client_id ) = @_;
292 0 ▶ $self->{_client_id} = $client_id if defined($client_id);
Branch: 1 branch
BranchTrueFalseTotal
if defined $client_id 0 0 0
293 0 return $self->{_client_id};
294 }
295
296 0 ▶sub getClientId {
Subroutine getClientId: not called CC=1 SCAR=6.9
297 0 my( $self ) = @_;
298 0 return $self->{_client_id};
299 }
300
301
302 0 ▶sub setClientSecret {
Subroutine setClientSecret: not called CC=2 SCAR=17.9
303 0 my ( $self, $client_secret ) = @_;
304 0 ▶ $self->{_client_secret} = $client_secret if defined($client_secret);
Branch: 1 branch
BranchTrueFalseTotal
if defined $client_secret 0 0 0
305 0 return $self->{_client_secret};
306 }
307
308 0 ▶sub getClientSecret {
Subroutine getClientSecret: not called CC=1 SCAR=6.9
309 0 my( $self ) = @_;
310 0 return $self->{_client_secret};
311 }
312
313
314
315 0 ▶sub json_read{
Subroutine json_read: not called CC=9 SCAR=45.0
316
317 0 my ($self) = @_;
318 0 my $filename = 'oxd-settings.json';
319 #my $baseUrl = $self->{_base_url};
320 #print $baseUrl;
321 0 my $configOBJECT;
322 0 ▶ if (open (my $configJSON, $filename)){
Branch: 1 branch
BranchTrueFalseTotal
if (open my $configJSON, $filename) 0 0 0
323 0 local $/ = undef;
324 0 my $json = JSON::PP->new;
325 0 $configOBJECT = $json->decode(<$configJSON>);
326
327 0 ▶ if(!$configOBJECT->{authorization_redirect_uri}){
Branch: 1 branch
BranchTrueFalseTotal
unless ($configOBJECT->{"authorization_redirect_uri"}) 0 0 0
328 0 my $defaultOxdSettingsJson = 'oxd-rp-settings-test.json';
329 0 ▶ if(open (my $configJSON, $defaultOxdSettingsJson)){
Branch: 1 branch
BranchTrueFalseTotal
if (open my $configJSON, $defaultOxdSettingsJson) 0 0 0
330 0 ▶ if(!my $configJSON){
Branch: 1 branch
BranchTrueFalseTotal
unless (my $configJSON) 0 0 0
331 #$error = error_get_last();
332 0 OxdClientSocket::log("oxd-configuration-test: ", 'Error problem with json data.');
333 0 OxdClientSocket::error_message("HTTP request failed. Error was: Testing");
334 }
335 0 $configOBJECT = $json->decode(<$configJSON>);
336 }
337 }
338
339 #$self->define_variables($configOBJECT);
340
341 0 my $OXD_HOST_PORT = $configOBJECT->{oxd_host_port};
342
343
344 0 ▶ if($OXD_HOST_PORT>=0 && $OXD_HOST_PORT<=65535){
Branch: 1 branch
BranchTrueFalseTotal
if ($OXD_HOST_PORT >= 0 and $OXD_HOST_PORT <= 65535) { } 0 0 0
Condition0%0/3
$OXD_HOST_PORT >= 0 and $OXD_HOST_PORT <= 65535
!ll&&!rl&&r
000
MC/DC0%0/2
$OXD_HOST_PORT >= 0 and $OXD_HOST_PORT <= 65535
$OXD_HOST_PORT >= 0 $OXD_HOST_PORT <= 65535
Truth table0%0/3
A and B
A= $OXD_HOST_PORT >= 0B= $OXD_HOST_PORT <= 65535
ABresult
0X0
100
111
345
346 }else{
347 0 OxdClientSocket::error_message($OXD_HOST_PORT." is not a valid port for socket. Port must be integer and between from 0 to 65535.");
348 }
349 #print $data->{authorization_redirect_uri};
350 0 close($configJSON);
351 }
352 0 my $op_host = $configOBJECT->{op_host};
353 0 my $oxd_host_port = $configOBJECT->{oxd_host_port};
354 0 my $authorization_redirect_uri = $configOBJECT->{authorization_redirect_uri};
355 0 my $post_logout_redirect_uri = $configOBJECT->{post_logout_redirect_uri};
356 0 my $client_frontchannel_logout_uris = $configOBJECT->{client_frontchannel_logout_uris};
357 0 my $scope = $configOBJECT->{scope};
358 0 my $application_type = $configOBJECT->{application_type};
359 0 my $response_types = $configOBJECT->{response_types};
360 0 my $grant_types = $configOBJECT->{grant_types};
361 0 my $acr_values = $configOBJECT->{acr_values};
362 0 my $rest_service_url = $configOBJECT->{rest_service_url};
363 0 my $connection_type = $configOBJECT->{connection_type};
364 0 my $oxd_id = $configOBJECT->{oxd_id};
365 0 my $clientName = $configOBJECT->{client_name};
366
367 #$self->new( $op_host, $oxd_host_port );
368 0 $self->setOpHost( $op_host );
369 0 $self->setOxdHostPort( $oxd_host_port );
370 0 $self->setAuthorizationRedirectUrl( $authorization_redirect_uri );
371 0 $self->setPostLogoutRedirectUrl( $post_logout_redirect_uri );
372 0 $self->setClientFrontChannelLogoutUris( $client_frontchannel_logout_uris );
373 0 $self->setScope( $scope );
374 0 $self->setApplicationType( $application_type );
375 0 $self->setResponseType( $response_types );
376 0 $self->setGrantTypes( $grant_types );
377 0 $self->setAcrValues( $acr_values );
378 0 $self->setRestServiceUrl( $rest_service_url );
379 0 $self->setConnectionType( $connection_type );
380 0 $self->setOxdId( $oxd_id );
381 0 $self->setClientName( $clientName );
382
383 0 ▶ if($configOBJECT->{client_id}){
Branch: 1 branch
BranchTrueFalseTotal
if ($configOBJECT->{"client_id"}) 0 0 0
384 0 my $client_id = $configOBJECT->{client_id};
385 0 $self->setClientId( $client_id );
386 }
387 0 ▶ if($configOBJECT->{client_secret}){
Branch: 1 branch
BranchTrueFalseTotal
if ($configOBJECT->{"client_secret"}) 0 0 0
388 0 my $client_secret = $configOBJECT->{client_secret};
389 0 $self->setClientSecret( $client_secret );
390 }
391
392
393
394
395
396 =pod use constant OXD_HOST_PORT => $configOBJECT->{oxd_host_port};
397 use constant AUTHORIZATION_REDIRECT_URL => $configOBJECT->{authorization_redirect_uri};
398 use constant POST_LOGOUT_REDIRECT_URL => $configOBJECT->{post_logout_redirect_uri};
399 use constant SCOPE => $configOBJECT->{scope};
400 use constant APPLICATION_TYPE => $configOBJECT->{application_type};
401 use constant RESPONSE_TYPES => $configOBJECT->{response_types};
402 use constant GRANT_TYPES => $configOBJECT->{grant_types};
403 use constant ACR_VALUES => $configOBJECT->{acr_values};
404 =cut
405 #return $configOBJECT;
406 }
407
408 1 1; # this 1; is neccessary for our class to workk
↑ Summary OxdPackages/UpdateRegistration.pm »