blib/lib/OxdPackages/GetUserInfo.pm untested

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 15 Podpod 0.0% 0 / 11 totaltotal 0.0% 0 / 79 CC 4 SCAR 12.0
CC
4
Cov
0%
setRequestAccessToken
6.0
setRequestOxdId
6.0
setRequestProtectionAccessToken
6.0
CRAP 3.3
1 #!/usr/bin/perl
2 # GetUserInfo.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) 2018, 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.2
33 # @author Sobhan Panda
34 # @author_email sobhan@centroxy.com
35 # @copyright Copyright (c) 2018, 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.2
39 # @filesource
40 #/
41
42 package GetUserInfo; # This is the "Class"
43 use OxdPackages::OxdClient;
44 use base qw(OxdClient Class::Accessor);
45 use strict;
46 our @ISA = qw(OxdClient); # inherits from OxdClient
47
48 use vars qw($VERSION);
49 $VERSION = '0.01';
50
51 sub new {
52 my $class = shift;
53 my $self = {
54 # @var string $request_oxd_id This parameter you must get after registration site in gluu-server
55 _request_oxd_id => shift,
56
57 # @var string $request_access_token This parameter you must get after using get_token_code class
58 _request_access_token => shift,
59
60 # @var array $request_protection_access_token To protect the command with access token
61 _request_protection_access_token => shift,
62
63 # Response parameter from oxd-server
64 # Showing logedin user information
65 # @var array $response_claims
66 _response_claims => shift,
67 };
68 # Print all the values just for clarification.
69 #print "setRequestOxdId is $self->{_request_oxd_id}<br>";
70 #print "setRequestCode is $self->{_request_code}<br>";
71 #print "setRequestState is $self->{_request_state}<br>";
72 bless $self, $class;
73
74 return $self;
75 }
76
77
78
79 # @return array
80
81 sub getResponseClaims
82 {
83 my( $self ) = @_;
84 $self->{_response_claims} = $self->getResponseData()->{claims};
85 return $self->{_response_claims};
86 }
87
88
89 # @return string
90
91 sub getRequestAccessToken
92 {
93 my( $self ) = @_;
94 return $self->{_request_access_token};
95 }
96
97
98 # @param string $request_access_token
99 # @return void
100
101 sub setRequestAccessToken
102 {
103 my ( $self, $request_access_token ) = @_;
104 $self->{_request_access_token} = $request_access_token if defined($request_access_token);
105 return $self->{_request_access_token};
106 }
107
108
109 # @return string
110
111 sub getRequestOxdId
112 {
113 my( $self ) = @_;
114 return $self->{_request_oxd_id};
115 }
116
117
118 # @param string $request_oxd_id
119 # @return void
120
121 sub setRequestOxdId
122 {
123 my ( $self, $request_oxd_id ) = @_;
124 $self->{_request_oxd_id} = $request_oxd_id if defined($request_oxd_id);
125 return $self->{_request_oxd_id};
126 }
127
128
129 # @return array
130 sub getRequestProtectionAccessToken
131 {
132 my( $self ) = @_;
133 return $self->{_request_protection_access_token};
134 }
135
136
137 # @param array $request_request_protection_access_token
138 # @return void
139 sub setRequestProtectionAccessToken
140 {
141 my ( $self, $request_protection_access_token ) = @_;
142 $self->{_request_protection_access_token} = $request_protection_access_token if defined($request_protection_access_token);
143 return $self->{_request_protection_access_token};
144 }
145
146
147
148 # Protocol command to oxd server
149 # @return void
150
151 sub setCommand
152 {
153 my ( $self, $command ) = @_;
154 $self->{_command} = 'get_user_info';
155 return $self->{_command};
156 }
157
158 # Protocol command to oXD to http server
159 # @return void
160
161 sub sethttpCommand
162 {
163 my ( $self, $httpCommand ) = @_;
164 $self->{_httpcommand} = 'get-user-info';
165 return $self->{_httpcommand};
166 }
167
168 # Method: setParams
169 # This method sets the parameters for get_user_info command.
170 # This module uses `request` method of OxdClient module for sending request to oxd-server
171 #
172 # Parameters:
173 #
174 # string $oxd_id - (Required) oxd Id from Client registration
175 #
176 # string $access_token - (Required) access Token from get_tokens_by_code or get_access_token_by_refresh_token command
177 #
178 # string $protection_access_token - Protection Acccess Token. OPTIONAL for `oxd-server` but REQUIRED for `oxd-https-extension`
179 #
180 # Returns:
181 # void
182 #
183 # This module uses `getResponseObject` method of OxdClient module for getting response from oxd.
184 #
185 # *Example response from getResponseObject:*
186 # --- Code
187 # { "status": "ok", "data": { "claims": { "sub": ["SGUMcFlAj3QlkOQVgwYpSozbjvynk4B2VNpr-mDnuVw"], "name": ["Jane Doe"], "given_name": ["Jane"], "family_name": ["Doe"], "preferred_username": ["j.doe"], "email": ["janedoe@example.com"], "picture": null } } }
188 # ---
189 #
190 sub setParams
191 {
192 my ( $self, $params ) = @_;
193 my $paramsArray = {
194 "oxd_id" => $self->getRequestOxdId(),
195 "access_token" => $self->getRequestAccessToken(),
196 "protection_access_token"=> $self->getRequestProtectionAccessToken()
197 };
198 $self->{_params} = $paramsArray;
199 return $self->{_params};
200 }
201
202
203 1; # this 1; is neccessary for our class to work