OxdPackages/UmaRsProtect.pm untested

filter: Statementstmt 0.0% 0 / 47 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 14 Podpod 0.0% 0 / 9 totaltotal 0.0% 0 / 72 CC 2 SCAR 9.3
CC
2
Cov
0%
setRequestOxdId
6.0
new
2.0
getRequestOxdId
2.0
CRAP 2.5
1 #!/usr/bin/perl
2 ##
3 # Gluu-oxd-library
4 #
5 # An open source application library for PHP
6 #
7 # This content is released under the MIT License (MIT)
8 #
9 # Copyright (c) 2016, Gluu inc, USA, Austin
10 #
11 # Permission is hereby granted, free of charge, to any person obtaining a copy
12 # of this software and associated documentation files (the "Software"), to deal
13 # in the Software without restriction, including without limitation the rights
14 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 # copies of the Software, and to permit persons to whom the Software is
16 # furnished to do so, subject to the following conditions:
17 #
18 # The above copyright notice and this permission notice shall be included in
19 # all copies or substantial portions of the Software.
20 #
21 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 # THE SOFTWARE.
28 #
29 # @package Gluu-oxd-library
30 # @version 2.4.4
31 # @author Inderpal Singh
32 # @author inderpal@ourdesignz.com
33 # @copyright Copyright (c) 2016, Gluu inc federation (https://gluu.org/)
34 # @license http://opensource.org/licenses/MIT MIT License
35 # @link https://gluu.org/
36 # @since Version 2.4.4
37 # @filesource
38 #
39  
40 ##
41 # UMA RS Protect resources package
42 #
43 # Package is connecting to oxd-server via socket, and adding resources in gluu-server.
44 #
45 # @package Gluu-oxd-library
46 # @subpackage Libraries
47 # @category Relying Party (RP) and User Managed Access (UMA)
48 # @author Inderpal Singh
49 # @author inderpal@ourdesignz.com
50 # @see OxdClientSocket
51 # @see OxdClient
52 # @see OxdConfig.pm
53 ##
54  
55 package UmaRsProtect;
56 use vars qw($VERSION);
57 $VERSION = '0.01';
58 use OxdPackages::OxdClient;
59 use base qw(OxdClient Class::Accessor);
60 use strict;
61 our @ISA = qw(OxdClient); # inherits from OxdClient
62 use Data::Dumper;
63
64 sub new {
65 my $class = shift;
66 my $self = {
67 # @var string $request_oxd_id This parameter you must get after registration site in gluu-server
68 _request_oxd_id => shift,
69  
70 # @var array $request_resources This parameter your resources parameter
71 _request_resources => [],
72 _request_resource => [],
73 _request_condition => [],
74 };
75 # Print all the values just for clarification.
76 #print "First Name is $self->{_request_oxd_id}\n";
77
78 #print "<br>";
79 bless $self, $class;
80 return $self;
81 }
82  
83 # @return string
84 sub getRequestOxdId{
85 my( $self ) = @_;
86 return $self->{_request_oxd_id};
87 }
88  
89 # @param string $request_oxd_id
90 # @return void
91 sub setRequestOxdId{
92 my ( $self, $request_oxd_id ) = @_;
93 $self->{_request_oxd_id} = $request_oxd_id if defined($request_oxd_id);
94 return $self->{_request_oxd_id};
95 }
96  
97 # @return array
98 sub getRequestResources{
99 my( $self ) = @_;
100 return $self->{_request_resources};
101 }
102  
103 sub addResource{
104 my ( $self, $path ) = @_;
105
106 my @request_resources = {
107 'path'=>$path,
108 'conditions' => $self->{_request_condition}
109 };
110
111 push $self->{_request_resources}, @request_resources;
112 $self->{_request_condition} = "";
113 }
114  
115 sub addConditionForPath{
116 my ( $self, $httpMethods, $scopes, $ticketScopes ) = @_;
117
118 my @request_condition = {
119 "httpMethods" => $httpMethods,
120 "scopes" => $scopes,
121 "ticketScopes" => $ticketScopes
122 };
123
124 push $self->{_request_condition}, @request_condition;
125 return $self->{_request_condition};
126 }
127 sub getCondition{
128 my( $self ) = @_;
129 return $self->{_request_condition};
130 }
131
132 # Protocol command to oxd server
133 # @return void
134 sub setCommand{
135 my ( $self ) = @_;
136 $self->{_command} = 'uma_rs_protect';
137 }
138  
139 # Protocol parameter to oxd server
140 # @return void
141 sub setParams{
142 my ( $self, $params ) = @_;
143 my $paramsArray = {
144 "oxd_id" => $self->getRequestOxdId(),
145 "resources" => $self->getRequestResources()
146  
147 };
148 # print Dumper $paramsArray;
149 $self->{_params} = $paramsArray;
150
151 #exit 1;
152 return $self->{_params};
153 }
154  
155 1; # this 1; is neccessary for our class to work