| 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 RP - Authorize RPT class | ||
| 42 | # | ||
| 43 | # Class is connecting to oxd-server via socket, and getting authorized RPT status from 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 | ||
| 53 | #/ | ||
| 54 | |||
| 55 | package UmaRpAuthorizeRpt; | ||
| 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 | |||
| 68 | # @var string $request_oxd_id This parameter you must get after registration site in gluu-server | ||
| 69 | _request_oxd_id => shift, | ||
| 70 | |||
| 71 | # @var string $request_rpt This parameter you must get after using uma_rp_get_rpt protocol | ||
| 72 | _request_rpt => shift, | ||
| 73 | |||
| 74 | # @var string $request_ticket This parameter you must get after using uma_rs_check_access protocol | ||
| 75 | _request_ticket => shift, | ||
| 76 | }; | ||
| 77 | # Print all the values just for clarification. | ||
| 78 | #print "First Name is $self->{_request_oxd_id}\n"; | ||
| 79 | |||
| 80 | #print "<br>"; | ||
| 81 | bless $self, $class; | ||
| 82 | return $self; | ||
| 83 | } | ||
| 84 | |||
| 85 | # @return string | ||
| 86 | sub getRequestOxdId | ||
| 87 | { | ||
| 88 | my( $self ) = @_; | ||
| 89 | return $self->{_request_oxd_id}; | ||
| 90 | } | ||
| 91 | |||
| 92 | # @param string $request_oxd_id | ||
| 93 | # @return void | ||
| 94 | sub setRequestOxdId | ||
| 95 | { | ||
| 96 | my ( $self, $request_oxd_id ) = @_; | ||
| 97 | $self->{_request_oxd_id} = $request_oxd_id if defined($request_oxd_id); | ||
| 98 | return $self->{_request_oxd_id}; | ||
| 99 | } | ||
| 100 | |||
| 101 | # @return string | ||
| 102 | sub getRequestRpt | ||
| 103 | { | ||
| 104 | my( $self ) = @_; | ||
| 105 | return $self->{_request_rpt}; | ||
| 106 | } | ||
| 107 | |||
| 108 | # @param string $request_rpt | ||
| 109 | # @return void | ||
| 110 | sub setRequestRpt | ||
| 111 | { | ||
| 112 | my ( $self, $request_rpt ) = @_; | ||
| 113 | $self->{_request_rpt} = $request_rpt if defined($request_rpt); | ||
| 114 | return $self->{_request_rpt}; | ||
| 115 | } | ||
| 116 | |||
| 117 | # @return string | ||
| 118 | sub getRequestTicket | ||
| 119 | { | ||
| 120 | my( $self ) = @_; | ||
| 121 | return $self->{_request_ticket}; | ||
| 122 | } | ||
| 123 | |||
| 124 | # @param string $request_ticket | ||
| 125 | # @return void | ||
| 126 | sub setRequestTicket | ||
| 127 | { | ||
| 128 | my ( $self, $request_ticket ) = @_; | ||
| 129 | $self->{_request_ticket} = $request_ticket if defined($request_ticket); | ||
| 130 | return $self->{_request_ticket}; | ||
| 131 | } | ||
| 132 | |||
| 133 | # Protocol command to oxd server | ||
| 134 | # @return void | ||
| 135 | sub setCommand | ||
| 136 | { | ||
| 137 | my ( $self ) = @_; | ||
| 138 | $self->{_command} = 'uma_rp_authorize_rpt'; | ||
| 139 | } | ||
| 140 | |||
| 141 | # Protocol parameter to oxd server | ||
| 142 | # @return void | ||
| 143 | sub setParams | ||
| 144 | { | ||
| 145 | my ( $self, $params ) = @_; | ||
| 146 | my $paramsArray = { | ||
| 147 | "oxd_id" => $self->getRequestOxdId(), | ||
| 148 | "rpt" => $self->getRequestRpt(), | ||
| 149 | "ticket" => $self->getRequestTicket(), | ||
| 150 | |||
| 151 | }; | ||
| 152 | $self->{_params} = $paramsArray; | ||
| 153 | return $self->{_params}; | ||
| 154 | } | ||
| 155 | |||
| 156 | 1; # this 1; is neccessary for our class to work |