| 1 | #!/usr/bin/perl | ||
| 2 | # OxdLogout.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) 2017, 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.0 | ||
| 33 | # @author Sobhan Panda | ||
| 34 | # @author_email sobhan@centroxy.com | ||
| 35 | # @copyright Copyright (c) 2017, 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.0 | ||
| 39 | # @filesource | ||
| 40 | #/ | ||
| 41 | |||
| 42 | |||
| 43 | package OxdLogout; # This is the "Class" | ||
| 44 | use vars qw($VERSION); | ||
| 45 | $VERSION = '0.01'; | ||
| 46 | |||
| 47 | use OxdPackages::OxdClient; | ||
| 48 | use base qw(OxdClient Class::Accessor); | ||
| 49 | use strict; | ||
| 50 | our @ISA = qw(OxdClient); # inherits from OxdClient | ||
| 51 | |||
| 52 | sub new { | ||
| 53 | my $class = shift; | ||
| 54 | my $self = { | ||
| 55 | |||
| 56 | # @var string $request_oxd_id Need to get after registration site in gluu-server | ||
| 57 | _request_oxd_id => shift, | ||
| 58 | |||
| 59 | # @var string $request_id_token Need to get after registration site in gluu-server | ||
| 60 | _request_id_token => shift, | ||
| 61 | |||
| 62 | # @var string $request_post_logout_redirect_uri Need to get after registration site in gluu-server | ||
| 63 | _request_post_logout_redirect_uri => shift, | ||
| 64 | |||
| 65 | # @var string $request_session_state Need to get after registration site in gluu-server | ||
| 66 | _request_session_state => shift, | ||
| 67 | |||
| 68 | # @var string $request_state Need to get after registration site in gluu-server | ||
| 69 | _request_state => shift, | ||
| 70 | |||
| 71 | # @var array $request_protection_access_token To protect the command with access token | ||
| 72 | _request_protection_access_token => shift, | ||
| 73 | |||
| 74 | |||
| 75 | # Response parameter from oxd-server | ||
| 76 | # Doing logout user from all sites | ||
| 77 | # @var string $response_claims | ||
| 78 | _response_html => shift, | ||
| 79 | }; | ||
| 80 | # Print all the values just for clarification. | ||
| 81 | bless $self, $class; | ||
| 82 | |||
| 83 | return $self; | ||
| 84 | } | ||
| 85 | |||
| 86 | # @return string | ||
| 87 | sub getRequestState | ||
| 88 | { | ||
| 89 | my( $self ) = @_; | ||
| 90 | return $self->{_request_state}; | ||
| 91 | } | ||
| 92 | |||
| 93 | |||
| 94 | # @param string $request_state | ||
| 95 | # @return void | ||
| 96 | sub setRequestState | ||
| 97 | { | ||
| 98 | my ( $self, $request_state ) = @_; | ||
| 99 | $self->{_request_state} = $request_state if defined($request_state); | ||
| 100 | return $self->{_request_access_token}; | ||
| 101 | } | ||
| 102 | |||
| 103 | |||
| 104 | # @return string | ||
| 105 | sub getRequestSessionState | ||
| 106 | { | ||
| 107 | my( $self ) = @_; | ||
| 108 | return $self->{_request_session_state}; | ||
| 109 | } | ||
| 110 | |||
| 111 | |||
| 112 | # @param string $request_session_state | ||
| 113 | # @return void | ||
| 114 | sub setRequestSessionState | ||
| 115 | { | ||
| 116 | my ( $self, $request_session_state ) = @_; | ||
| 117 | $self->{_request_session_state} = $request_session_state if defined($request_session_state); | ||
| 118 | return $self->{_request_session_state}; | ||
| 119 | } | ||
| 120 | |||
| 121 | # @param string $request_post_logout_redirect_uri | ||
| 122 | # @return void | ||
| 123 | sub setRequestPostLogoutRedirectUri | ||
| 124 | { | ||
| 125 | my ( $self, $request_post_logout_redirect_uri ) = @_; | ||
| 126 | $self->{_request_post_logout_redirect_uri} = $request_post_logout_redirect_uri if defined($request_post_logout_redirect_uri); | ||
| 127 | return $self->{_request_post_logout_redirect_uri}; | ||
| 128 | } | ||
| 129 | |||
| 130 | |||
| 131 | # @return string | ||
| 132 | sub getResponseHtml() | ||
| 133 | { | ||
| 134 | my( $self ) = @_; | ||
| 135 | $self->{_response_html} = $self->getResponseData()->{url}; | ||
| 136 | return $self->{_response_html}; | ||
| 137 | } | ||
| 138 | |||
| 139 | # @return string | ||
| 140 | sub getRequestIdToken | ||
| 141 | { | ||
| 142 | my( $self ) = @_; | ||
| 143 | return $self->{_request_id_token}; | ||
| 144 | } | ||
| 145 | |||
| 146 | |||
| 147 | # @return string | ||
| 148 | sub getRequestPostLogoutRedirectUri | ||
| 149 | { | ||
| 150 | my( $self ) = @_; | ||
| 151 | return $self->{_request_post_logout_redirect_uri}; | ||
| 152 | } | ||
| 153 | |||
| 154 | # @param string $request_id_token | ||
| 155 | # @return void | ||
| 156 | sub setRequestIdToken | ||
| 157 | { | ||
| 158 | my ( $self, $request_id_token ) = @_; | ||
| 159 | $self->{_request_id_token} = $request_id_token if defined($request_id_token); | ||
| 160 | return $self->{_request_id_token}; | ||
| 161 | } | ||
| 162 | |||
| 163 | # @return string | ||
| 164 | sub getRequestOxdId | ||
| 165 | { | ||
| 166 | my( $self ) = @_; | ||
| 167 | return $self->{_request_oxd_id}; | ||
| 168 | } | ||
| 169 | |||
| 170 | # @param string $request_oxd_id | ||
| 171 | # @return void | ||
| 172 | sub setRequestOxdId | ||
| 173 | { | ||
| 174 | my ( $self, $request_oxd_id ) = @_; | ||
| 175 | $self->{_request_oxd_id} = $request_oxd_id if defined($request_oxd_id); | ||
| 176 | return $self->{_request_oxd_id}; | ||
| 177 | } | ||
| 178 | |||
| 179 | # Protocol command to oxd server | ||
| 180 | # @return void | ||
| 181 | |||
| 182 | |||
| 183 | # @return array | ||
| 184 | sub getRequestProtectionAccessToken | ||
| 185 | { | ||
| 186 | my( $self ) = @_; | ||
| 187 | return $self->{_request_protection_access_token}; | ||
| 188 | } | ||
| 189 | |||
| 190 | |||
| 191 | # @param array $request_request_protection_access_token | ||
| 192 | # @return void | ||
| 193 | sub setRequestProtectionAccessToken | ||
| 194 | { | ||
| 195 | my ( $self, $request_protection_access_token ) = @_; | ||
| 196 | $self->{_request_protection_access_token} = $request_protection_access_token if defined($request_protection_access_token); | ||
| 197 | return $self->{_request_protection_access_token}; | ||
| 198 | } | ||
| 199 | |||
| 200 | |||
| 201 | |||
| 202 | sub setCommand | ||
| 203 | { | ||
| 204 | my ( $self, $command ) = @_; | ||
| 205 | $self->{_command} = 'get_logout_uri'; | ||
| 206 | return $self->{_command}; | ||
| 207 | } | ||
| 208 | |||
| 209 | # Protocol command to oXD to http server | ||
| 210 | # @return void | ||
| 211 | |||
| 212 | sub sethttpCommand | ||
| 213 | { | ||
| 214 | my ( $self, $httpCommand ) = @_; | ||
| 215 | $self->{_httpcommand} = 'get-logout-uri'; | ||
| 216 | return $self->{_httpcommand}; | ||
| 217 | } | ||
| 218 | |||
| 219 | # Protocol parameter to oxd server | ||
| 220 | # @return void | ||
| 221 | sub setParams | ||
| 222 | { | ||
| 223 | my ( $self, $params ) = @_; | ||
| 224 | my $paramsArray = { | ||
| 225 | "oxd_id" => $self->getRequestOxdId(), | ||
| 226 | "id_token_hint" => $self->getRequestIdToken(), | ||
| 227 | "post_logout_redirect_uri" => $self->getRequestPostLogoutRedirectUri(), | ||
| 228 | "state" => $self->getRequestState(), | ||
| 229 | "session_state" => $self->getRequestSessionState(), | ||
| 230 | "protection_access_token"=> $self->getRequestProtectionAccessToken() | ||
| 231 | }; | ||
| 232 | $self->{_params} = $paramsArray; | ||
| 233 | return $self->{_params}; | ||
| 234 | } | ||
| 235 | |||
| 236 | |||
| 237 | 1; # this 1; is neccessary for our class to work |