line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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 PHP |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
# This content is released under the MIT License (MIT) |
10
|
|
|
|
|
|
|
# |
11
|
|
|
|
|
|
|
# Copyright (c) 2015, 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 2.4.4 |
33
|
|
|
|
|
|
|
# @author Ourdesignz |
34
|
|
|
|
|
|
|
# @author gaurav.chhabra6785@gmail.com |
35
|
|
|
|
|
|
|
# @copyright Copyright (c) 2015, Gluu inc federation (https://gluu.org/) |
36
|
|
|
|
|
|
|
# @license http://opensource.org/licenses/MIT MIT License |
37
|
|
|
|
|
|
|
# @link https://gluu.org/ |
38
|
|
|
|
|
|
|
# @since Version 2.4.4 |
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
|
|
|
1
|
|
3
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
55
|
|
|
|
|
|
|
$VERSION = '0.01'; |
56
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
30
|
|
57
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
681
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub new{ |
60
|
0
|
|
|
0
|
|
|
my $class = shift; |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $self = { |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# @static |
65
|
|
|
|
|
|
|
# @var string $op_host Gluu server url, which need to connect |
66
|
|
|
|
|
|
|
_op_host => shift, |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# @static |
69
|
|
|
|
|
|
|
# @var int $oxd_host_port Socket connection port |
70
|
|
|
|
|
|
|
_oxd_host_port => shift, |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# @static |
73
|
|
|
|
|
|
|
# @var string $authorization_redirect_uri Site authorization redirect uri |
74
|
|
|
|
|
|
|
_authorization_redirect_uri => shift, |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# @static |
77
|
|
|
|
|
|
|
# @var string $post_logout_redirect_uri Site logout redirect uri |
78
|
|
|
|
|
|
|
_post_logout_redirect_uri => shift, |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# @static |
81
|
|
|
|
|
|
|
# @var array $scope For getting needed scopes from gluu-server |
82
|
|
|
|
|
|
|
_scope => shift, |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# @static |
85
|
|
|
|
|
|
|
# @var string $application_type web or mobile |
86
|
|
|
|
|
|
|
_application_type => shift, |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# @static |
89
|
|
|
|
|
|
|
# @var array $response_types OpenID Authentication response types |
90
|
|
|
|
|
|
|
_response_types => shift, |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
# @static |
93
|
|
|
|
|
|
|
# @var array $grant_types OpenID Token Request type |
94
|
|
|
|
|
|
|
_grant_types => shift, |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
# @static |
97
|
|
|
|
|
|
|
# @var array $acr_values Gluu login acr type, can be basic, duo, u2f, gplus and etc. |
98
|
|
|
|
|
|
|
_acr_values => shift, |
99
|
|
|
|
|
|
|
}; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# Print all the values just for clarification. |
102
|
|
|
|
|
|
|
#print "OP HOST is :". $self->{_op_host}; |
103
|
|
|
|
|
|
|
#print " "; |
104
|
|
|
|
|
|
|
#print "OXD HOST PORT is :".$self->{_oxd_host_port}; |
105
|
0
|
|
|
|
|
|
our $oxdHostPort; |
106
|
0
|
|
|
|
|
|
$oxdHostPort = 'package'; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
bless $self, $class; |
109
|
0
|
|
|
|
|
|
$self->json_read; |
110
|
0
|
|
|
|
|
|
return $self; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub setOpHost { |
114
|
|
|
|
|
|
|
#my ( $self, $op_host,$oxd_host_port,$authorization_redirect_uri,$post_logout_redirect_uri,$scope,$application_type,$response_types,$grant_types,$acr_values ) = @_; |
115
|
0
|
|
|
0
|
|
|
my ( $self, $op_host ) = @_; |
116
|
0
|
0
|
|
|
|
|
$self->{_op_host} = $op_host if defined($op_host); |
117
|
0
|
|
|
|
|
|
return $self->{_op_host}; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub getOpHost { |
121
|
0
|
|
|
0
|
|
|
my( $self ) = @_; |
122
|
0
|
|
|
|
|
|
return $self->{_op_host}; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub setOxdHostPort { |
126
|
0
|
|
|
0
|
|
|
my ( $self, $oxd_host_port ) = @_; |
127
|
0
|
0
|
|
|
|
|
$self->{_oxd_host_port} = $oxd_host_port if defined($oxd_host_port); |
128
|
0
|
|
|
|
|
|
return $self->{_oxd_host_port}; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub getOxdHostPort { |
132
|
0
|
|
|
0
|
|
|
my( $self ) = @_; |
133
|
0
|
|
|
|
|
|
return $self->{_oxd_host_port}; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub setAuthorizationRedirectUrl { |
137
|
0
|
|
|
0
|
|
|
my ( $self, $authorization_redirect_uri ) = @_; |
138
|
0
|
0
|
|
|
|
|
$self->{_authorization_redirect_uri} = $authorization_redirect_uri if defined($authorization_redirect_uri); |
139
|
0
|
|
|
|
|
|
return $self->{_authorization_redirect_uri}; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub getAuthorizationRedirectUrl { |
143
|
0
|
|
|
0
|
|
|
my( $self ) = @_; |
144
|
0
|
|
|
|
|
|
return $self->{_authorization_redirect_uri}; |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub setPostLogoutRedirectUrl { |
148
|
0
|
|
|
0
|
|
|
my ( $self, $post_logout_redirect_uri ) = @_; |
149
|
0
|
0
|
|
|
|
|
$self->{_post_logout_redirect_uri} = $post_logout_redirect_uri if defined($post_logout_redirect_uri); |
150
|
0
|
|
|
|
|
|
return $self->{_post_logout_redirect_uri}; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub getPostLogoutRedirectUrl { |
154
|
0
|
|
|
0
|
|
|
my( $self ) = @_; |
155
|
0
|
|
|
|
|
|
return $self->{_post_logout_redirect_uri}; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub setScope { |
160
|
0
|
|
|
0
|
|
|
my ( $self, $scope ) = @_; |
161
|
0
|
0
|
|
|
|
|
$self->{_scope} = $scope if defined($scope); |
162
|
0
|
|
|
|
|
|
return $self->{_scope}; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub getScope { |
166
|
0
|
|
|
0
|
|
|
my( $self ) = @_; |
167
|
0
|
|
|
|
|
|
return $self->{_scope}; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
sub setApplicationType { |
171
|
0
|
|
|
0
|
|
|
my ( $self, $application_type ) = @_; |
172
|
0
|
0
|
|
|
|
|
$self->{_application_type} = $application_type if defined($application_type); |
173
|
0
|
|
|
|
|
|
return $self->{_application_type}; |
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub getApplicationType { |
177
|
0
|
|
|
0
|
|
|
my( $self ) = @_; |
178
|
0
|
|
|
|
|
|
return $self->{_application_type}; |
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub setResponseType { |
182
|
0
|
|
|
0
|
|
|
my ( $self, $response_types ) = @_; |
183
|
0
|
0
|
|
|
|
|
$self->{_response_types} = $response_types if defined($response_types); |
184
|
0
|
|
|
|
|
|
return $self->{_response_types}; |
185
|
|
|
|
|
|
|
} |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
sub getResponseType { |
188
|
0
|
|
|
0
|
|
|
my( $self ) = @_; |
189
|
0
|
|
|
|
|
|
return $self->{_response_types}; |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
sub setGrantTypes { |
193
|
0
|
|
|
0
|
|
|
my ( $self, $grant_types ) = @_; |
194
|
0
|
0
|
|
|
|
|
$self->{_grant_types} = $grant_types if defined($grant_types); |
195
|
0
|
|
|
|
|
|
return $self->{_grant_types}; |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub getGrantTypes { |
199
|
0
|
|
|
0
|
|
|
my( $self ) = @_; |
200
|
0
|
|
|
|
|
|
return $self->{_grant_types}; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
sub setAcrValues { |
204
|
0
|
|
|
0
|
|
|
my ( $self, $acr_values ) = @_; |
205
|
0
|
0
|
|
|
|
|
$self->{_acr_values} = $acr_values if defined($acr_values); |
206
|
0
|
|
|
|
|
|
return $self->{_acr_values}; |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
sub getAcrValues { |
210
|
0
|
|
|
0
|
|
|
my( $self ) = @_; |
211
|
0
|
|
|
|
|
|
return $self->{_acr_values}; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
sub json_read{ |
214
|
|
|
|
|
|
|
|
215
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
216
|
0
|
|
|
|
|
|
my $filename = 'oxd-settings.json'; |
217
|
|
|
|
|
|
|
#my $baseUrl = $self->{_base_url}; |
218
|
|
|
|
|
|
|
#print $baseUrl; |
219
|
0
|
|
|
|
|
|
my $configOBJECT; |
220
|
0
|
0
|
|
|
|
|
if (open (my $configJSON, $filename)){ |
221
|
0
|
|
|
|
|
|
local $/ = undef; |
222
|
0
|
|
|
|
|
|
my $json = JSON::PP->new; |
223
|
0
|
|
|
|
|
|
$configOBJECT = $json->decode(<$configJSON>); |
224
|
|
|
|
|
|
|
|
225
|
0
|
0
|
|
|
|
|
if(!$configOBJECT->{authorization_redirect_uri}){ |
226
|
0
|
|
|
|
|
|
my $defaultOxdSettingsJson = 'oxd-rp-settings-test.json'; |
227
|
0
|
0
|
|
|
|
|
if(open (my $configJSON, $defaultOxdSettingsJson)){ |
228
|
0
|
0
|
|
|
|
|
if(!my $configJSON){ |
229
|
|
|
|
|
|
|
#$error = error_get_last(); |
230
|
0
|
|
|
|
|
|
OxdClientSocket::log("oxd-configuration-test: ", 'Error problem with json data.'); |
231
|
0
|
|
|
|
|
|
OxdClientSocket::error_message("HTTP request failed. Error was: Testing"); |
232
|
|
|
|
|
|
|
} |
233
|
0
|
|
|
|
|
|
$configOBJECT = $json->decode(<$configJSON>); |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
#$self->define_variables($configOBJECT); |
238
|
|
|
|
|
|
|
|
239
|
0
|
|
|
|
|
|
my $OXD_HOST_PORT = $configOBJECT->{oxd_host_port}; |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
|
242
|
0
|
0
|
0
|
|
|
|
if($OXD_HOST_PORT>=0 && $OXD_HOST_PORT<=65535){ |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
}else{ |
245
|
0
|
|
|
|
|
|
OxdClientSocket::error_message($OXD_HOST_PORT." is not a valid port for socket. Port must be integer and between from 0 to 65535."); |
246
|
|
|
|
|
|
|
} |
247
|
|
|
|
|
|
|
#print $data->{authorization_redirect_uri}; |
248
|
0
|
|
|
|
|
|
close($configJSON); |
249
|
|
|
|
|
|
|
} |
250
|
0
|
|
|
|
|
|
my $op_host = $configOBJECT->{op_host}; |
251
|
0
|
|
|
|
|
|
my $oxd_host_port = $configOBJECT->{oxd_host_port}; |
252
|
0
|
|
|
|
|
|
my $authorization_redirect_uri = $configOBJECT->{authorization_redirect_uri}; |
253
|
0
|
|
|
|
|
|
my $post_logout_redirect_uri = $configOBJECT->{post_logout_redirect_uri}; |
254
|
0
|
|
|
|
|
|
my $scope = $configOBJECT->{scope}; |
255
|
0
|
|
|
|
|
|
my $application_type = $configOBJECT->{application_type}; |
256
|
0
|
|
|
|
|
|
my $response_types = $configOBJECT->{response_types}; |
257
|
0
|
|
|
|
|
|
my $grant_types = $configOBJECT->{grant_types}; |
258
|
0
|
|
|
|
|
|
my $acr_values = $configOBJECT->{acr_values}; |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
#$self->new( $op_host, $oxd_host_port ); |
261
|
0
|
|
|
|
|
|
$self->setOpHost( $op_host ); |
262
|
0
|
|
|
|
|
|
$self->setOxdHostPort( $oxd_host_port ); |
263
|
0
|
|
|
|
|
|
$self->setAuthorizationRedirectUrl( $authorization_redirect_uri ); |
264
|
0
|
|
|
|
|
|
$self->setPostLogoutRedirectUrl( $post_logout_redirect_uri ); |
265
|
0
|
|
|
|
|
|
$self->setScope( $scope ); |
266
|
0
|
|
|
|
|
|
$self->setApplicationType( $application_type ); |
267
|
0
|
|
|
|
|
|
$self->setResponseType( $response_types ); |
268
|
0
|
|
|
|
|
|
$self->setGrantTypes( $grant_types ); |
269
|
0
|
|
|
|
|
|
$self->setAcrValues( $acr_values ); |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=pod use constant OXD_HOST_PORT => $configOBJECT->{oxd_host_port}; |
278
|
|
|
|
|
|
|
use constant AUTHORIZATION_REDIRECT_URL => $configOBJECT->{authorization_redirect_uri}; |
279
|
|
|
|
|
|
|
use constant POST_LOGOUT_REDIRECT_URL => $configOBJECT->{post_logout_redirect_uri}; |
280
|
|
|
|
|
|
|
use constant SCOPE => $configOBJECT->{scope}; |
281
|
|
|
|
|
|
|
use constant APPLICATION_TYPE => $configOBJECT->{application_type}; |
282
|
|
|
|
|
|
|
use constant RESPONSE_TYPES => $configOBJECT->{response_types}; |
283
|
|
|
|
|
|
|
use constant GRANT_TYPES => $configOBJECT->{grant_types}; |
284
|
|
|
|
|
|
|
use constant ACR_VALUES => $configOBJECT->{acr_values}; |
285
|
|
|
|
|
|
|
=cut |
286
|
|
|
|
|
|
|
#return $configOBJECT; |
287
|
|
|
|
|
|
|
} |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
1; # this 1; is neccessary for our class to workk |