Ejemplo n.º 1
0
        }
        throw new Exception($e->getMessage());
    } catch (\Exception $e) {
        if ($bAutologin) {
            $alres = new Login_AutologinResponse('error', $e->getMessage());
            $alres->send();
            exit(0);
        }
        throw $e;
    }
    // SREG
    $sreg = new \OpenID_Extension_SREG11(\OpenID_Extension::REQUEST);
    $sreg->set('required', 'email,fullname');
    $authRequest->addExtension($sreg);
    // AX, http://stackoverflow.com/a/7657061/282601
    $ax = new \OpenID_Extension_AX(\OpenID_Extension::REQUEST);
    $ax->set('type.email', 'http://axschema.org/contact/email');
    $ax->set('type.firstname', 'http://axschema.org/namePerson/first');
    $ax->set('type.lastname', 'http://axschema.org/namePerson/last');
    $ax->set('type.fullname', 'http://axschema.org/namePerson');
    $ax->set('mode', 'fetch_request');
    $ax->set('required', 'email,firstname,lastname,fullname');
    $authRequest->addExtension($ax);
    $url = $authRequest->getAuthorizeURL();
    header("Location: {$url}");
    exit;
}
if (isset($_SESSION['openid_url'])) {
    $usid = $_SESSION['openid_url'];
    unset($_SESSION['openid_url']);
} else {
Ejemplo n.º 2
0
 /**
  * @SuppressWarnings(PHPMD.ExitExpression)
  */
 public function loginUser()
 {
     $returnTo = $this->_controller->absolutePath('login');
     $realm = $this->_controller->absoluetPath('');
     if (!empty($_POST['openid_identifier'])) {
         $identifier = $_POST['openid_identifier'];
         $relayParty = new \OpenID_RelyingParty($returnTo, $realm, $identifier);
         $authRequest = $relayParty->prepare();
         $authExtension = new \OpenID_Extension_AX(\OpenID_Extension::REQUEST);
         $authExtension->set('type.email', 'http://axschema.org/contact/email');
         $authExtension->set('type.firstname', 'http://axschema.org/namePerson/first');
         $authExtension->set('type.lastname', 'http://axschema.org/namePerson/last');
         $authExtension->set('mode', 'fetch_request');
         $authExtension->set('required', 'email,firstname,lastname');
         $authRequest->addExtension($authExtension);
         header('Location: ' . $authRequest->getAuthorizeURL());
         exit(0);
     }
     $relayParty = new \OpenID_RelyingParty($returnTo, $realm);
     $arr = explode('?', $_SERVER['REQUEST_URI']);
     $queryString = isset($arr[1]) ? $arr[1] : '';
     if ($queryString) {
         $message = new \OpenID_Message($queryString, \OpenID_Message::FORMAT_HTTP);
         $result = $relayParty->verify(new \Net_URL2($returnTo), $message);
         if ($result->success()) {
             $this->_controller->getStore()->expire();
             $this->_controller->getStore()->touchAuthentication();
             $authExtension = new \OpenID_Extension_AX(\OpenID_Extension::RESPONSE, $message);
             $uniqueName = $message->get('openid.claimed_id');
             $email = $authExtension->get('value.email');
             $firstName = $authExtension->get('value.firstname');
             $lastName = $authExtension->get('value.lastname');
             $this->_controller->getStore()->set(self::SESSION_VAR_ID, $uniqueName);
             $user = $this->_controller->getEntityManager()->getRepository('\\Jazzee\\Entity\\User')->findOneBy(array('uniqueName' => $uniqueName));
             if (!$user) {
                 $user = new \Jazzee\Entity\User();
                 $user->setUniqueName($uniqueName);
             }
             $user->setFirstName($firstName);
             $user->setLastName($lastName);
             $user->setEmail($email);
             $this->_controller->getEntityManager()->persist($user);
             $this->_user = $user;
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * testAddExtension 
  * 
  * @return void
  */
 public function testAddExtension()
 {
     $extension = new OpenID_Extension_AX(OpenID_Extension::REQUEST);
     $extension->set('foo', 'bar');
     $this->object->addExtension($extension);
     $this->assertSame('bar', $this->object->get('openid.ax.foo'));
 }