Ejemplo n.º 1
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.º 2
0
    Show_page($content);
    exit;
}
/* Grab identifier */
if (isset($_POST['identifier'])) {
    $identifier = $_POST['identifier'];
} else {
    if (isset($_SESSION['identifier'])) {
        $identifier = $_SESSION['identifier'];
    } else {
        $identifier = null;
    }
}
/* Create OpenID object */
try {
    $o = new OpenID_RelyingParty($returnTo, $realm, $identifier);
} catch (OpenID_Exception $e) {
    $contents = "<div class='relyingparty_results'>\n";
    $contents .= "<pre>" . $e->getMessage() . "</pre>\n";
    $contents .= "</div class='relyingparty_results'>";
    Show_page($contents);
    exit;
}
/* Redirect to OpenID provider */
if (isset($_POST['start'])) {
    try {
        $authRequest = $o->prepare();
    } catch (OpenID_Exception $e) {
        $contents = "<div class='relyingparty_results'>\n";
        $contents .= "<pre>" . $e->getMessage() . "</pre>\n";
        $contents .= "</div class='relyingparty_results'>";
Ejemplo n.º 3
0
if (isset($_POST['openid_url'])) {
    $openid_url = $_POST['openid_url'];
} else {
    if (isset($_SESSION['openid_url'])) {
        $openid_url = $_SESSION['openid_url'];
    } else {
        $openid_url = null;
    }
}
$realm = Tools::fullUrl();
$returnTo = Tools::fullUrl('login');
if ($bAutologin) {
    $returnTo = Tools::fullUrl('login?autologin=2');
}
try {
    $o = new \OpenID_RelyingParty($returnTo, $realm, $openid_url);
} catch (\OpenID_Exception $e) {
    throw new Exception($e->getMessage());
}
if (!empty($_POST['disable_associations']) || !empty($_SESSION['disable_associations'])) {
    $o->disableAssociations();
    $_SESSION['disable_associations'] = true;
}
if (isset($_POST['openid_url'])) {
    $_SESSION['openid_url'] = $openid_url;
    try {
        $authRequest = $o->prepare();
        if ($bAutologin) {
            $authRequest->setMode(\OpenID::MODE_CHECKID_IMMEDIATE);
        }
    } catch (\OpenID_Exception $e) {
Ejemplo n.º 4
0
 /**
  * testPrepareFail 
  * 
  * @expectedException OpenID_Exception
  * @return void
  */
 public function testPrepareFail()
 {
     $rp = new OpenID_RelyingParty($this->returnTo, $this->realm);
     $rp->prepare();
 }