fromOpenIDRequest() 정적인 공개 메소드

Instantiate a Request object from the arguments in a checkid_* OpenID message
static public fromOpenIDRequest ( $request )
예제 #1
0
파일: PAPE.php 프로젝트: openid/php-openid
 function test_fromOpenIDRequest_no_pape()
 {
     $message = new Auth_OpenID_Message();
     $openid_req = new Auth_OpenID_Request();
     $openid_req->message = $message;
     $pape_req = Auth_OpenID_PAPE_Request::fromOpenIDRequest($openid_req);
     $this->assertTrue($pape_req === null);
 }
예제 #2
0
 public function proceedAction()
 {
     // needed for unit tests
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNeverRender(true);
     $server = $this->_getOpenIdProvider();
     $request = $server->decodeRequest();
     if ($request->idSelect()) {
         $id = $this->user->openid;
     } else {
         $id = null;
     }
     $response = $request->answer(true, null, $id);
     if ($this->_hasSreg($request) && $this->_getParam('profileId')) {
         $profiles = new Users_Model_Profiles();
         $profile = $profiles->getRowInstance($this->_getParam('profileId'));
         $personalInfoForm = Users_Form_PersonalInfo::getForm($request, $profile);
         $formData = $this->_request->getPost();
         $personalInfoForm->populate($formData);
         // not planning on validating stuff here yet, but I call this
         // for the date element to be filled properly
         $foo = $personalInfoForm->isValid($formData);
         $sregResponse = Auth_OpenID_SRegResponse::extractResponse($personalInfoForm->getSregRequest(), $personalInfoForm->getUnqualifiedValues());
         $sregResponse->toMessage($response->fields);
     }
     $trustRoot = $this->_getTrustRoot($request);
     if ($this->_getParam('allow')) {
         if ($this->_getParam('forever')) {
             $sites = new Model_Sites();
             $sites->deleteForUserSite($this->user, $trustRoot);
             $siteObj = $sites->createRow();
             $siteObj->user_id = $this->user->id;
             $siteObj->site = $trustRoot;
             $siteObj->creation_date = date('Y-m-d');
             if (isset($personalInfoForm)) {
                 $trusted = array();
                 // using this key name for BC pre 1.1 when we used Zend_OpenId
                 $trusted['Zend_OpenId_Extension_Sreg'] = $personalInfoForm->getUnqualifiedValues();
             } else {
                 $trusted = true;
             }
             $siteObj->trusted = serialize($trusted);
             $siteObj->save();
         }
         $this->_saveHistory($trustRoot, Model_History::AUTHORIZED);
         require_once 'libs/Auth/OpenID/PAPE.php';
         if ($papeRequest = Auth_OpenID_PAPE_Request::fromOpenIDRequest($request)) {
             $this->_processPape($papeRequest, $response);
         }
         $webresponse = $server->encodeResponse($response);
         foreach ($webresponse->headers as $k => $v) {
             if ($k == 'location') {
                 $this->_response->setRedirect($v);
             } else {
                 $this->_response->setHeader($k, $v);
             }
         }
         $this->_response->setHeader('Connection', 'close');
         $this->_response->appendBody($webresponse->body);
     } elseif ($this->_getParam('deny')) {
         if ($this->_getParam('forever')) {
             $sites = new Model_Sites();
             $sites->deleteForUserSite($this->user, $trustRoot);
             $siteObj = $sites->createRow();
             $siteObj->user_id = $this->user->id;
             $siteObj->site = $trustRoot;
             $siteObj->creation_date = date('Y-m-d');
             $siteObj->trusted = serialize(false);
             $siteObj->save();
         }
         $this->_saveHistory($trustRoot, Model_History::DENIED);
         return $this->_sendResponse($server, $request->answer(false));
     }
 }