| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | ## | ||
| 4 | # Gluu-oxd-library | ||
| 5 | # | ||
| 6 | # An open source application library for Perl | ||
| 7 | # | ||
| 8 | # This content is released under the MIT License (MIT) | ||
| 9 | # | ||
| 10 | # Copyright (c) 2017, Gluu inc, USA, Austin | ||
| 11 | # | ||
| 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| 13 | # of this software and associated documentation files (the "Software"), to deal | ||
| 14 | # in the Software without restriction, including without limitation the rights | ||
| 15 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| 16 | # copies of the Software, and to permit persons to whom the Software is | ||
| 17 | # furnished to do so, subject to the following conditions: | ||
| 18 | # | ||
| 19 | # The above copyright notice and this permission notice shall be included in | ||
| 20 | # all copies or substantial portions of the Software. | ||
| 21 | # | ||
| 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 25 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 26 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| 27 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| 28 | # THE SOFTWARE. | ||
| 29 | # | ||
| 30 | # @package Gluu-oxd-library | ||
| 31 | # @version 3.1.0 | ||
| 32 | # @author Sobhan Panda | ||
| 33 | # @author sobhan@centroxy.com | ||
| 34 | # @copyright Copyright (c) 2017, Gluu inc federation (https://gluu.org/) | ||
| 35 | # @license http://opensource.org/licenses/MIT MIT License | ||
| 36 | # @link https://gluu.org/ | ||
| 37 | # @since Version 3.1.0 | ||
| 38 | # @filesource | ||
| 39 | # | ||
| 40 | #/ | ||
| 41 | |||
| 42 | package UmaRpGetClaimsGatheringUrl; | ||
| 43 | use vars qw($VERSION); | ||
| 44 | $VERSION = '0.01'; | ||
| 45 | use OxdPackages::OxdClient; | ||
| 46 | use base qw(OxdClient Class::Accessor); | ||
| 47 | use strict; | ||
| 48 | our @ISA = qw(OxdClient); # inherits from OxdClient | ||
| 49 | use Data::Dumper; | ||
| 50 | |||
| 51 | sub new { | ||
| 52 | my $class = shift; | ||
| 53 | my $self = { | ||
| 54 | |||
| 55 | # @var string $request_oxd_id This parameter you must get after registration site in gluu-server | ||
| 56 | _request_oxd_id => shift, | ||
| 57 | |||
| 58 | # @var bool $request_force_new Indicates whether return new RPT, in general should be false, so oxd server can cache/reuse same RPT | ||
| 59 | _request_force_new => shift, | ||
| 60 | |||
| 61 | _request_ticket => shift, | ||
| 62 | |||
| 63 | _request_claims_redirect_uri => shift, | ||
| 64 | |||
| 65 | _request_protection_access_token => shift, | ||
| 66 | |||
| 67 | |||
| 68 | # Response parameter from oxd-server | ||
| 69 | # Gluu RP Token | ||
| 70 | # @var string $response_rpt | ||
| 71 | |||
| 72 | _response_rpt => shift | ||
| 73 | }; | ||
| 74 | # Print all the values just for clarification. | ||
| 75 | # print "First Name is $self->{_request_oxd_id}\n"; | ||
| 76 | |||
| 77 | # print "<br>"; | ||
| 78 | bless $self, $class; | ||
| 79 | return $self; | ||
| 80 | } | ||
| 81 | |||
| 82 | # @return string | ||
| 83 | sub getRequestOxdId | ||
| 84 | { | ||
| 85 | my( $self ) = @_; | ||
| 86 | return $self->{_request_oxd_id} | ||
| 87 | } | ||
| 88 | |||
| 89 | ## | ||
| 90 | # @param string $request_oxd_id | ||
| 91 | # @return void | ||
| 92 | # | ||
| 93 | sub setRequestOxdId | ||
| 94 | { | ||
| 95 | my ( $self, $request_oxd_id ) = @_; | ||
| 96 | $self->{_request_oxd_id} = $request_oxd_id if defined($request_oxd_id); | ||
| 97 | return $self->{_request_oxd_id}; | ||
| 98 | } | ||
| 99 | |||
| 100 | ## | ||
| 101 | # @return bool | ||
| 102 | # | ||
| 103 | sub getRequestForceNew | ||
| 104 | { | ||
| 105 | my( $self ) = @_; | ||
| 106 | return $self->{_request_force_new}; | ||
| 107 | } | ||
| 108 | |||
| 109 | ## | ||
| 110 | # @param bool $request_force_new | ||
| 111 | # @return void | ||
| 112 | # | ||
| 113 | sub setRequestForceNew | ||
| 114 | { | ||
| 115 | my ( $self, $request_force_new ) = @_; | ||
| 116 | $self->{_request_force_new} = $request_force_new if defined($request_force_new); | ||
| 117 | return $self->{_request_force_new}; | ||
| 118 | } | ||
| 119 | |||
| 120 | |||
| 121 | # @return string | ||
| 122 | sub getRequestTicket | ||
| 123 | { | ||
| 124 | my( $self ) = @_; | ||
| 125 | return $self->{_request_ticket} | ||
| 126 | } | ||
| 127 | |||
| 128 | ## | ||
| 129 | # @param string $request_ticket | ||
| 130 | # @return void | ||
| 131 | # | ||
| 132 | sub setRequestTicket | ||
| 133 | { | ||
| 134 | my ( $self, $request_ticket ) = @_; | ||
| 135 | $self->{_request_ticket} = $request_ticket if defined($request_ticket); | ||
| 136 | return $self->{_request_ticket}; | ||
| 137 | } | ||
| 138 | |||
| 139 | |||
| 140 | # @return string | ||
| 141 | sub getRequestClaimsRedirectUri | ||
| 142 | { | ||
| 143 | my( $self ) = @_; | ||
| 144 | return $self->{_request_claims_redirect_uri} | ||
| 145 | } | ||
| 146 | |||
| 147 | ## | ||
| 148 | # @param string $request_claim_token | ||
| 149 | # @return void | ||
| 150 | # | ||
| 151 | sub setRequestClaimsRedirectUri | ||
| 152 | { | ||
| 153 | my ( $self, $request_claims_redirect_uri ) = @_; | ||
| 154 | $self->{_request_claims_redirect_uri} = $request_claims_redirect_uri if defined($request_claims_redirect_uri); | ||
| 155 | return $self->{_request_claims_redirect_uri}; | ||
| 156 | } | ||
| 157 | |||
| 158 | |||
| 159 | # @return string | ||
| 160 | sub getRequestProtectionAccessToken | ||
| 161 | { | ||
| 162 | my( $self ) = @_; | ||
| 163 | return $self->{_request_protection_access_token} | ||
| 164 | } | ||
| 165 | |||
| 166 | ## | ||
| 167 | # @param string $request_protection_access_token | ||
| 168 | # @return void | ||
| 169 | # | ||
| 170 | sub setRequestProtectionAccessToken | ||
| 171 | { | ||
| 172 | my ( $self, $request_protection_access_token ) = @_; | ||
| 173 | $self->{_request_protection_access_token} = $request_protection_access_token if defined($request_protection_access_token); | ||
| 174 | return $self->{_request_protection_access_token}; | ||
| 175 | } | ||
| 176 | |||
| 177 | |||
| 178 | ## | ||
| 179 | # @return string | ||
| 180 | # | ||
| 181 | sub getResponseRpt | ||
| 182 | { | ||
| 183 | my( $self ) = @_; | ||
| 184 | $self->{_response_rpt} = $self->getResponseData()->{rpt}; | ||
| 185 | return $self->{_response_rpt}; | ||
| 186 | } | ||
| 187 | |||
| 188 | ## | ||
| 189 | # Protocol command to oxd server | ||
| 190 | # @return void | ||
| 191 | # | ||
| 192 | sub setCommand | ||
| 193 | { | ||
| 194 | my ( $self ) = @_; | ||
| 195 | $self->{_command} = 'uma_rp_get_claims_gathering_url'; | ||
| 196 | } | ||
| 197 | |||
| 198 | ## | ||
| 199 | # Protocol command to oxd to http server | ||
| 200 | # @return void | ||
| 201 | # | ||
| 202 | sub sethttpCommand | ||
| 203 | { | ||
| 204 | my ( $self ) = @_; | ||
| 205 | $self->{_httpcommand} = 'uma-rp-get-claims-gathering-url'; | ||
| 206 | } | ||
| 207 | |||
| 208 | ## | ||
| 209 | # Protocol parameter to oxd server | ||
| 210 | # @return void | ||
| 211 | # | ||
| 212 | sub setParams | ||
| 213 | { | ||
| 214 | my ( $self, $params ) = @_; | ||
| 215 | my $paramsArray = { | ||
| 216 | "oxd_id" => $self->getRequestOxdId(), | ||
| 217 | "ticket" => $self->getRequestTicket(), | ||
| 218 | "claims_redirect_uri" => $self->getRequestClaimsRedirectUri(), | ||
| 219 | "protection_access_token" => $self->getRequestProtectionAccessToken() | ||
| 220 | }; | ||
| 221 | $self->{_params} = $paramsArray; | ||
| 222 | return $self->{_params}; | ||
| 223 | } | ||
| 224 | |||
| 225 | 1; # this 1; is neccessary for our class to work |