Subversion Repositories oidplus

Rev

Rev 591 | Rev 622 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 591 Rev 620
Line 135... Line 135...
135
        }
135
        }
136
 
136
 
137
        // Override abstract functions
137
        // Override abstract functions
138
 
138
 
139
        public function activate() {
139
        public function activate() {
-
 
140
                // Send cookie at the end of the HTTP request, in case there are multiple activate() calls
-
 
141
                register_shutdown_function(array($this,'activateNow'));
-
 
142
        }
-
 
143
 
-
 
144
        public function activateNow() {
140
                $token = $this->getJWTToken();
145
                $token = $this->getJWTToken();
141
                $exp = $this->getValue('exp',0);
146
                $exp = $this->getValue('exp',0);
142
                OIDplus::cookieUtils()->setcookie(self::COOKIE_NAME, $token, $exp, false);
147
                OIDplus::cookieUtils()->setcookie(self::COOKIE_NAME, $token, $exp, false);
143
        }
148
        }
144
 
149
 
Line 166... Line 171...
166
        public function adminLogoutEx(&$loginfo) {
171
        public function adminLogoutEx(&$loginfo) {
167
                $this->adminLogout();
172
                $this->adminLogout();
168
                $loginfo = 'from JWT session';
173
                $loginfo = 'from JWT session';
169
        }
174
        }
170
 
175
 
-
 
176
        private static $contentProvider = null;
171
        public static function getActiveProvider() {
177
        public static function getActiveProvider() {
172
                static $contentProvider = null;
-
 
173
 
-
 
174
                if (!$contentProvider) {
178
                if (!self::$contentProvider) {
175
                        $jwt = '';
179
                        $jwt = '';
176
                        if (isset($_COOKIE[self::COOKIE_NAME])) $jwt = $_COOKIE[self::COOKIE_NAME];
180
                        if (isset($_COOKIE[self::COOKIE_NAME])) $jwt = $_COOKIE[self::COOKIE_NAME];
177
                        if (isset($_POST[self::COOKIE_NAME]))   $jwt = $_POST[self::COOKIE_NAME];
181
                        if (isset($_POST[self::COOKIE_NAME]))   $jwt = $_POST[self::COOKIE_NAME];
178
                        if (isset($_GET[self::COOKIE_NAME]))    $jwt = $_GET[self::COOKIE_NAME];
182
                        if (isset($_GET[self::COOKIE_NAME]))    $jwt = $_GET[self::COOKIE_NAME];
179
 
183
 
Line 195... Line 199...
195
                                                OIDplus::cookieUtils()->unsetcookie(self::COOKIE_NAME);
199
                                                OIDplus::cookieUtils()->unsetcookie(self::COOKIE_NAME);
196
                                                return null;
200
                                                return null;
197
                                        }
201
                                        }
198
                                }
202
                                }
199
 
203
 
200
                                $contentProvider = $tmp;
204
                                self::$contentProvider = $tmp;
201
                        }
205
                        }
202
                }
206
                }
203
 
207
 
204
                return $contentProvider;
208
                return self::$contentProvider;
205
        }
209
        }
206
 
210
 
207
        public function raLoginEx($email, &$loginfo) {
211
        public function raLoginEx($email, &$loginfo) {
208
                if (is_null(self::getActiveProvider())) {
212
                if (is_null(self::getActiveProvider())) {
209
                        $this->raLogin($email);
213
                        $this->raLogin($email);
210
                        $loginfo = 'into new JWT session';
214
                        $loginfo = 'into new JWT session';
-
 
215
                        self::$contentProvider = $this;
211
                } else {
216
                } else {
212
                        $gen = $this->getValue('oidplus_generator',-1);
217
                        $gen = $this->getValue('oidplus_generator',-1);
213
                        switch ($gen) {
218
                        switch ($gen) {
214
                                case OIDplusAuthContentStoreJWT::JWT_GENERATOR_AJAX :
219
                                case OIDplusAuthContentStoreJWT::JWT_GENERATOR_AJAX :
215
                                case OIDplusAuthContentStoreJWT::JWT_GENERATOR_MANUAL :
220
                                case OIDplusAuthContentStoreJWT::JWT_GENERATOR_MANUAL :
Line 230... Line 235...
230
 
235
 
231
        public function adminLoginEx(&$loginfo) {
236
        public function adminLoginEx(&$loginfo) {
232
                if (is_null(self::getActiveProvider())) {
237
                if (is_null(self::getActiveProvider())) {
233
                        $this->adminLogin();
238
                        $this->adminLogin();
234
                        $loginfo = 'into new JWT session';
239
                        $loginfo = 'into new JWT session';
-
 
240
                        self::$contentProvider = $this;
235
                } else {
241
                } else {
236
                        $gen = $this->getValue('oidplus_generator',-1);
242
                        $gen = $this->getValue('oidplus_generator',-1);
237
                        switch ($gen) {
243
                        switch ($gen) {
238
                                case OIDplusAuthContentStoreJWT::JWT_GENERATOR_AJAX :
244
                                case OIDplusAuthContentStoreJWT::JWT_GENERATOR_AJAX :
239
                                case OIDplusAuthContentStoreJWT::JWT_GENERATOR_MANUAL :
245
                                case OIDplusAuthContentStoreJWT::JWT_GENERATOR_MANUAL :