当前位置: 首页>>代码示例>>PHP>>正文


PHP getConsumer函数代码示例

本文整理汇总了PHP中getConsumer函数的典型用法代码示例。如果您正苦于以下问题:PHP getConsumer函数的具体用法?PHP getConsumer怎么用?PHP getConsumer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getConsumer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID.");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    // Create attribute request object
    // See http://code.google.com/apis/accounts/docs/OpenID.html#Parameters for parameters
    // Usage: make($type_uri, $count=1, $required=false, $alias=null)
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email', 2, 1, 'email');
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/first', 1, 1, 'firstname');
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/last', 1, 1, 'lastname');
    // Create AX fetch request
    $ax = new Auth_OpenID_AX_FetchRequest();
    // Add attributes to AX fetch request
    foreach ($attribute as $attr) {
        $ax->add($attr);
    }
    $auth_request->addExtension($ax);
    $policy_uris = $_GET['policies'];
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            print $form_html;
        }
    }
}
开发者ID:umbecr,项目名称:camilaframework,代码行数:60,代码来源:openid_try_auth.php

示例2: run

function run()
{
    $consumer = getConsumer();
    // Complete the authentication process using the server's
    // response.
    $return_to = getReturnTo('finish_auth_openid_setting');
    $response = $consumer->complete($return_to);
    // Check the response status.
    if ($response->status == Auth_OpenID_CANCEL) {
        // This means the authentication was cancelled.
        $msg = 'Verification cancelled.';
    } else {
        if ($response->status == Auth_OpenID_FAILURE) {
            // Authentication failed; display the error message.
            $msg = "OpenID authentication failed: " . $response->message;
        } else {
            if ($response->status == Auth_OpenID_SUCCESS) {
                // This means the authentication succeeded; extract the
                // identity URL and Simple Registration data (if it was
                // returned).
                $openid = $response->getDisplayIdentifier();
                openid_setting($openid);
            }
        }
    }
    include 'message.php';
}
开发者ID:AlexChien,项目名称:EY_BBS,代码行数:27,代码来源:finish_openid_setting.php

示例3: run

function run()
{
    $consumer = getConsumer();
    // Complete the authentication process using the server's
    // response.
    $return_to = getReturnTo();
    $response = $consumer->complete($return_to);
    // Check the response status.
    if ($response->status == Auth_OpenID_CANCEL) {
        // This means the authentication was cancelled.
        $msg = 'Verification cancelled.';
        if (isset($_COOKIE[session_name()])) {
            setcookie(session_name(), '', time() - 42000, '/');
        }
        session_destroy();
    } else {
        if ($response->status == Auth_OpenID_FAILURE) {
            // Authentication failed; display the error message.
            $msg = "OpenID authentication failed: " . $response->message;
            if (isset($_COOKIE[session_name()])) {
                setcookie(session_name(), '', time() - 42000, '/');
            }
            session_destroy();
        } else {
            if ($response->status == Auth_OpenID_SUCCESS) {
                // This means the authentication succeeded; extract the
                // identity URL and Simple Registration data (if it was
                // returned).
                $openid = $response->getDisplayIdentifier();
                $esc_identity = escape($openid);
                $_SESSION = array();
                $_SESSION['openid'] = $esc_identity;
                if ($response->endpoint->canonicalID) {
                    $escaped_canonicalID = escape($response->endpoint->canonicalID);
                    $success .= '  (XRI CanonicalID: ' . $escaped_canonicalID . ') ';
                    $_SESSION['openid'] = $escaped_canonicalID;
                }
                // AX Process
                $ax_resp = Auth_OpenID_AX_FetchResponse::fromSuccessResponse($response);
                if ($ax_resp) {
                    global $ax_data;
                    foreach ($ax_data as $ax_key => $ax_data_ns) {
                        if ($ax_resp->data[$ax_data_ns][0]) {
                            $_SESSION['ax_' . $ax_key] = $ax_resp->data[$ax_data_ns][0];
                        }
                    }
                }
            }
        }
    }
    if ($_GET["popup"] == "true") {
        include 'close.php';
    } else {
        if ($_GET["callback"] == "ax") {
            header("Location: ./ax_example.php");
        } else {
            header("Location: ./index.php");
        }
    }
}
开发者ID:ritou,项目名称:php-openid-popup-example,代码行数:60,代码来源:finish_auth.php

示例4: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    $return_to = getReturnTo();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID.");
    }
    // add AX request
    if ($_GET['ax'] == 'true') {
        $ax_request = new Auth_OpenID_AX_FetchRequest();
        global $ax_data;
        foreach ($ax_data as $ax_key => $ax_data_ns) {
            // set AX params
            if ($_GET['ax_' . $ax_key] == 'true') {
                $ax_request->add(new Auth_OpenID_AX_AttrInfo($ax_data_ns, 1, true, $ax_key));
            }
        }
        // add extension
        if ($ax_request) {
            $auth_request->addExtension($ax_request);
        }
    }
    // add UI extension request
    if ($_GET['ui'] == 'true') {
        $UI_request = new OpenID_UI_Request();
        // set icon
        if ($_GET['icon'] == 'true') {
            $UI_request->setIcon();
        }
        // set lang
        if ($_GET['lang'] == 'true' && $_GET['pref_lang']) {
            $UI_request->setLang($_GET['pref_lang']);
        }
        // set popup
        if ($_GET['popup'] == 'true') {
            $UI_request->setPopup();
            $return_to .= "popup=true";
        }
        $auth_request->addExtension($UI_request);
    } else {
        if ($_GET['callback'] == "ax") {
            $return_to .= "callback=ax";
        }
    }
    $redirect_url = $auth_request->redirectURL(getTrustRoot(), $return_to);
    if (Auth_OpenID::isFailure($redirect_url)) {
        displayError("Could not redirect to server: " . $redirect_url->message);
    } else {
        // Send redirect.
        header("Location: " . $redirect_url);
    }
}
开发者ID:ritou,项目名称:php-openid-popup-example,代码行数:56,代码来源:try_auth.php

示例5: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("认证错误,不是有效的OpenID。");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname', 'email'), array('gender'));
    //'nickname','fullname', 'email', 'dob','gender','postcode','country','language','timezone'
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    /*NOTE:目前还很少有网站要用到PAPE这个功能
       $policy_uris = $_GET['policies'];
    
        $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
        if ($pape_request) {
            $auth_request->addExtension($pape_request);
        }
    	*/
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("不能跳转到: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("不能跳转到: " . $form_html->message);
        } else {
            print $form_html;
        }
    }
}
开发者ID:AlexChien,项目名称:ey_uhome,代码行数:51,代码来源:try_auth.php

示例6: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError(_CORE_OID_URL_INVALID);
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname', 'email'), array('fullname', 'dob', 'gender', 'postcode', 'country', 'language', 'timezone'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    $policy_uris = isset($_GET['policies']) ? filter_var($_GET['policies'], FILTER_SANITIZE_URL) : NULL;
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            //displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header('Location: ' . $redirect_url);
            exit;
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->formMarkup(getTrustRoot(), getReturnTo(), FALSE, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError(sprintf(_CORE_OID_REDIRECT_FAILED, $form_html->message));
        } else {
            $page_contents = array("<html><head><title>", _CORE_OID_INPROGRESS, "</title></head>", "<body onload='document.getElementById(\"" . $form_id . "\").submit()'>", $form_html, "</body></html>");
            print implode("\n", $page_contents);
        }
    }
}
开发者ID:LeeGlendenning,项目名称:formulize,代码行数:49,代码来源:try_auth.php

示例7: run

function run()
{
    $consumer = getConsumer();
    // Complete the authentication process using the server's
    // response.
    $return_to = getReturnTo();
    $response = $consumer->complete($return_to);
    // Check the response status.
    if ($response->status == Auth_OpenID_CANCEL) {
        // This means the authentication was cancelled.
        $msg = 'Verification cancelled.';
    } else {
        if ($response->status == Auth_OpenID_FAILURE) {
            // Authentication failed; display the error message.d
            $msg = "OpenID authentication failed: " . $response->message;
        } else {
            if ($response->status == Auth_OpenID_SUCCESS) {
                // This means the authentication succeeded; extract the
                // identity URL and Simple Registration data (if it was
                // returned).
                $openid = $response->getDisplayIdentifier();
                $esc_identity = escape($openid);
                $success = sprintf('You have successfully verified ' . '<a href="%s">%s</a> as your identity.<br><br>Here\'s your MySpace profile data fetched using the MySpace REST APIs', $esc_identity, $esc_identity);
                if ($response->endpoint->canonicalID) {
                    $escaped_canonicalID = escape($response->endpoint->canonicalID);
                    $success .= '  (XRI CanonicalID: ' . $escaped_canonicalID . ') ';
                }
                $oauth_resp = Auth_OpenID_OAuthResponse::fromSuccessResponse($response);
                $authorized_request_token = $oauth_resp->authorized_request_token;
                //1.0A OAuth Spec, we will need this to get an access token
                $authorized_verifier = $oauth_resp->authorized_verifier;
                if ($authorized_request_token) {
                    $ms = new MySpace(CONSUMER_KEY, CONSUMER_SECRET, $authorized_request_token->key, $authorized_request_token->secret, $authorized_verifier);
                    $access_token = $ms->getAccessToken();
                    $ms = new MySpace(CONSUMER_KEY, CONSUMER_SECRET, $access_token->key, $access_token->secret);
                    $userid = $ms->getCurrentUserId();
                    // Use the userID (fetched in the previous step) to get user's profile, friends and other info
                    $profile_data = $ms->getProfile($userid);
                    $friends_data = $ms->getFriends($userid);
                    $ms->updateStatus($userid, 'testing sdk');
                    // Access $profile_data and $friend_data inside of index.php (via the include below)
                    // to display the profile/friends data
                }
            }
        }
    }
    include 'index.php';
}
开发者ID:jozecuervo,项目名称:myspace-php-sdk,代码行数:48,代码来源:finish_auth.php

示例8: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID.");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    $policy_uris = $_GET['policies'];
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->formMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            $page_contents = array("<html><head><title>", "OpenID transaction in progress", "</title></head>", "<body onload='document.getElementById(\"" . $form_id . "\").submit()'>", $form_html, "</body></html>");
            print implode("\n", $page_contents);
        }
    }
}
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:48,代码来源:try_auth.php

示例9: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        // check for new install, if no, go to index, else goto new-install page
        require_once 'CRM/Core/BAO/UFMatch.php';
        $contactIds = CRM_Core_BAO_UFMatch::getContactIDs();
        if (count($contactIds) > 0) {
            displayError("Authentication error; not a valid OpenID.");
        } else {
            $session =& CRM_Core_Session::singleton();
            $session->set('new_install', true);
            include 'new_install.html';
            exit(1);
        }
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    $policy_uris = null;
    if (isset($_REQUEST['policies'])) {
        $policy_uris = $_REQUEST['policies'];
    }
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
    // If the redirect URL can't be built, display an error
    // message.
    if (Auth_OpenID::isFailure($redirect_url)) {
        displayError("Could not redirect to server: " . $redirect_url->message);
    } else {
        // Send redirect.
        header("Location: " . $redirect_url);
        exit(2);
    }
}
开发者ID:ksecor,项目名称:civicrm,代码行数:43,代码来源:try_auth.php

示例10: run

function run()
{
    $consumer = getConsumer();
    // Complete the authentication process using the server's
    // response.
    $return_to = getReturnTo();
    $response = $consumer->complete($return_to);
    // Check the response status.
    if ($response->status == Auth_OpenID_CANCEL) {
        // This means the authentication was cancelled.
        $msg = '验证被取消。';
        //showmessage('cancel_openid_auth');
    } else {
        if ($response->status == Auth_OpenID_FAILURE) {
            // Authentication failed; display the error message.
            $msg = "OpenID 认证失败: " . $response->message;
        } else {
            if ($response->status == Auth_OpenID_SUCCESS) {
                // This means the authentication succeeded; extract the
                // identity URL and Simple Registration data (if it was
                // returned).
                // 将openid记录到session里,在session超时时间内,由以后的逻辑绑定到已注册的uid上。
                $_SESSION['openid_identifier'] = $response->getDisplayIdentifier();
                $_SESSION['openid_binding'] = time();
                //标记可以绑定了,但在发现是可直接登录用户时在要unset
                if ($response->endpoint->canonicalID) {
                    $_SESSION['xri_canonicalid'] = $response->endpoint->canonicalID;
                }
                $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
                $_SESSION['openid_sreg'] = $sreg_resp->contents();
                //NOTE:记录SREG到会话
                // echo var_dump($_SESSION['openid_identifier'])."--_SESSION['openid_identifier']<br>";
                // echo var_dump($_SESSION['openid_binding'])."--_SESSION['openid_binding']<br>";
                _OpenID_Action();
                //添加动作
            }
        }
    }
    displayError($msg);
}
开发者ID:AlexChien,项目名称:ey_uhome,代码行数:40,代码来源:finish_auth.php

示例11: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID." . "\n OpenID::" . $openid);
    }
    $oauth_req = new Auth_OpenID_OAuthRequest(CONSUMER_KEY);
    $auth_request->addExtension($oauth_req);
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            print $form_html;
        }
    }
}
开发者ID:jozecuervo,项目名称:myspace-php-sdk,代码行数:40,代码来源:try_auth.php

示例12: run

function run()
{
    $consumer = getConsumer();
    // Complete the authentication process using the server's
    // response.
    $return_to = getReturnTo();
    $response = $consumer->complete($return_to);
    // Check the response status.
    if ($response->status == Auth_OpenID_CANCEL) {
        // This means the authentication was cancelled.
        $msg = 'Verification cancelled.';
    } else {
        if ($response->status == Auth_OpenID_FAILURE) {
            // Authentication failed; display the error message.
            $msg = "OpenID authentication failed: " . $response->message;
        } else {
            if ($response->status == Auth_OpenID_SUCCESS) {
                // This means the authentication succeeded; extract the
                // identity URL and Simple Registration data (if it was
                // returned).
                $openid = $response->getDisplayIdentifier();
                $esc_identity = escape($openid);
                $google = strpos($openid, "google.com");
                $success = sprintf('You have successfully verified ' . '<a href="%s">%s</a> as your identity.', $esc_identity, $esc_identity);
                if ($response->endpoint->canonicalID) {
                    $escaped_canonicalID = escape($response->endpoint->canonicalID);
                    $success .= '  (XRI CanonicalID: ' . $escaped_canonicalID . ') ';
                }
                $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
                $sreg = $sreg_resp->contents();
                if (@$sreg['email']) {
                    $success .= "  You also returned '" . escape($sreg['email']) . "' as your email.";
                }
                if (@$sreg['nickname']) {
                    $success .= "  Your nickname is '" . escape($sreg['nickname']) . "'.";
                }
                if (@$sreg['fullname']) {
                    $success .= "  Your fullname is '" . escape($sreg['fullname']) . "'.";
                }
                $pape_resp = Auth_OpenID_PAPE_Response::fromSuccessResponse($response);
                if ($pape_resp) {
                    if ($pape_resp->auth_policies) {
                        $success .= "<p>The following PAPE policies affected the authentication:</p><ul>";
                        foreach ($pape_resp->auth_policies as $uri) {
                            $escaped_uri = escape($uri);
                            $success .= "<li><tt>{$escaped_uri}</tt></li>";
                        }
                        $success .= "</ul>";
                    } else {
                        $success .= "<p>No PAPE policies affected the authentication.</p>";
                    }
                    if ($pape_resp->auth_age) {
                        $age = escape($pape_resp->auth_age);
                        $success .= "<p>The authentication age returned by the " . "server is: <tt>" . $age . "</tt></p>";
                    }
                    if ($pape_resp->nist_auth_level) {
                        $auth_level = escape($pape_resp->nist_auth_level);
                        $success .= "<p>The NIST auth level returned by the " . "server is: <tt>" . $auth_level . "</tt></p>";
                    }
                } else {
                    $success .= "<p>No PAPE response was sent by the provider.</p>";
                }
            }
        }
    }
    include 'index.php';
}
开发者ID:hammerdr,项目名称:Omni-Software-Localization,代码行数:67,代码来源:finish_auth.php

示例13: run

function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID.");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://geni.net/projects', 'unlimited', 1, 'projects');
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://geni.net/slices', 'unlimited', 1, 'slices');
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://geni.net/user/urn', 1, 1, 'urn');
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://geni.net/user/prettyname', 1, 1, 'prettyname');
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://geni.net/wimax/username', 1, 1, 'wimax');
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://geni.net/irods/username', 1, 1, 'irodsuser');
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://geni.net/irods/zone', 1, 1, 'irodszone');
    // Create AX fetch request
    $ax = new Auth_OpenID_AX_FetchRequest();
    // Add attributes to AX fetch request
    foreach ($attribute as $attr) {
        $ax->add($attr);
    }
    // Add AX fetch request to authentication request
    $auth_request->addExtension($ax);
    $policy_uris = null;
    if (isset($_GET['policies'])) {
        $policy_uris = $_GET['policies'];
    }
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            print $form_html;
        }
    }
}
开发者ID:ahelsing,项目名称:geni-portal,代码行数:65,代码来源:try_auth.php

示例14: run

function run()
{
    $session =& CRM_Core_Session::singleton();
    $config =& CRM_Core_Config::singleton();
    $consumer = getConsumer();
    // Complete the authentication process using the server's
    // response.
    $return_to = getReturnTo();
    $response = $consumer->complete($return_to);
    // Check the response status.
    if ($response->status == Auth_OpenID_CANCEL) {
        // This means the authentication was cancelled.
        $msg = 'Verification cancelled.';
        $session->set('msg', $msg);
        $session->set('goahead', "no");
    } else {
        if ($response->status == Auth_OpenID_FAILURE) {
            // Authentication failed; display the error message.
            $msg = "OpenID authentication failed: " . $response->message;
            $session->set('msg', $msg);
            $session->set('goahead', "no");
        } else {
            if ($response->status == Auth_OpenID_SUCCESS) {
                // This means the authentication succeeded; extract the
                // identity URL and Simple Registration data (if it was
                // returned).
                $openid = array();
                $openid['display_id'] = $response->getDisplayIdentifier();
                $openid['claimed_id'] = $response->identity_url;
                $openid['endpoint_url'] = $response->endpoint->server_url;
                #$openid = $response->getDisplayIdentifier();
                //$esc_identity = escape($openid);
                $session->set('openid', $openid);
                $session->set('goahead', "yes");
                $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
                $sreg = $sreg_resp->contents();
                $sreg['email'] = empty($sreg['email']) ? '' : $sreg['email'];
                if ($session->get('new_install') == true) {
                    // update group clause
                    require_once 'CRM/Core/Transaction.php';
                    require_once 'CRM/Contact/BAO/Group.php';
                    $groupDAO =& new CRM_Contact_DAO_Group();
                    $groupDAO->find();
                    while ($groupDAO->fetch()) {
                        if (!isset($transaction)) {
                            $transaction = new CRM_Core_Transaction();
                        }
                        $group =& new CRM_Contact_BAO_Group();
                        $group->id = $groupDAO->id;
                        $group->find(true);
                        $group->buildClause();
                        $group->save();
                    }
                    if (isset($transaction)) {
                        $transaction->commit();
                    }
                    // Redirect to new user registration form
                    $urlVar = $config->userFrameworkURLVar;
                    $config->reset();
                    header("Location: index.php?{$urlVar}=civicrm/standalone/register&reset=1&configReset=1");
                    exit;
                } else {
                    require_once 'CRM/Standalone/User.php';
                    $user = new CRM_Standalone_User($openid, $sreg['email']);
                    require_once 'CRM/Utils/System/Standalone.php';
                    $allow_login = CRM_Utils_System_Standalone::getAllowedToLogin($user);
                    if (!$allow_login && (!defined('CIVICRM_ALLOW_ALL') || !CIVICRM_ALLOW_ALL)) {
                        $session->set('msg', 'You are not allowed to login. Login failed. Contact your Administrator.');
                        $session->set('goahead', "no");
                    } else {
                        CRM_Utils_System_Standalone::getUserID($user);
                        if (!$session->get('userID')) {
                            $session->set('msg', 'You are not authorized to login.');
                            $session->set('goahead', "no");
                        }
                    }
                    header("Location: index.php");
                    exit(0);
                }
            }
        }
    }
    displayError("Unknown status returned.");
}
开发者ID:ksecor,项目名称:civicrm,代码行数:84,代码来源:finish_auth.php

示例15: run

function run()
{
    $consumer = getConsumer();
    // Complete the authentication process using the server's
    // response.
    $return_to = getReturnTo();
    $response = $consumer->complete($return_to);
    // Check the response status.
    if ($response->status == Auth_OpenID_CANCEL) {
        // This means the authentication was cancelled.
        $msg = gettext('Verification cancelled.');
    } else {
        if ($response->status == Auth_OpenID_FAILURE) {
            // Authentication failed; display the error message.
            $msg = sprintf(gettext("OpenID authentication failed: %s"), $response->message);
        } else {
            if ($response->status == Auth_OpenID_SUCCESS) {
                // This means the authentication succeeded; extract the
                // identity URL and Simple Registration data (if it was
                // returned).
                $openid = $response->getDisplayIdentifier();
                $esc_identity = escape($openid);
                $success = sprintf(gettext('You have successfully verified <a href="%s">%s</a> as your identity.'), $esc_identity, $esc_identity);
                if ($response->endpoint->canonicalID) {
                    $escaped_canonicalID = escape($response->endpoint->canonicalID);
                    $success .= '  (XRI CanonicalID: ' . $escaped_canonicalID . ') ';
                }
                $email = $name = NULL;
                $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
                $sreg = $sreg_resp->contents();
                if ($sreg) {
                    if (@$sreg['email']) {
                        $email = trim($sreg['email']);
                    }
                    if (@$sreg['nickname']) {
                        $name = $sreg['nickname'];
                    }
                    if (@$sreg['fullname']) {
                        $name = $sreg['fullname'];
                    }
                }
                $ax_resp = Auth_OpenID_AX_FetchResponse::fromSuccessResponse($response);
                if ($ax_resp) {
                    $arr_ax_resp = get_object_vars($ax_resp);
                    $arr_ax_data = $arr_ax_resp['data'];
                    if (empty($email) && isset($arr_ax_data["http://axschema.org/contact/email"]) && count($arr_ax_data["http://axschema.org/contact/email"]) > 0) {
                        $email = $arr_ax_data["http://axschema.org/contact/email"][0];
                    }
                    if (empty($name) && isset($arr_ax_data["http://axschema.org/namePerson"]) && count($arr_ax_data["http://axschema.org/namePerson"]) > 0) {
                        $name = $arr_ax_data["http://axschema.org/namePerson"][0];
                    }
                    if (empty($name)) {
                        $name_first = '';
                        $name_middle = '';
                        $name_last = '';
                        if (isset($arr_ax_data["http://axschema.org/namePerson/first"]) && count($arr_ax_data["http://axschema.org/namePerson/first"]) > 0) {
                            $name_first = $arr_ax_data["http://axschema.org/namePerson/first"][0];
                        }
                        if (isset($arr_ax_data["http://axschema.org/namePerson/middle"]) && count($arr_ax_data["http://axschema.org/namePerson/middle"]) > 0) {
                            $name_middle = $arr_ax_data["http://axschema.org/namePerson/middle"][0];
                        }
                        if (isset($arr_ax_data["http://axschema.org/namePerson/last"]) && count($arr_ax_data["http://axschema.org/namePerson/last"]) > 0) {
                            $name_last = $arr_ax_data["http://axschema.org/namePerson/last"][0];
                        }
                        $fullname = trim(trim(trim($name_first) . ' ' . $name_middle) . ' ' . $name_last);
                        if (!empty($fullname)) {
                            $name = $fullname;
                        }
                    }
                    if (empty($name) && isset($arr_ax_data["http://axschema.org/namePerson/friendly"]) && count($arr_ax_data["http://axschema.org/namePerson/friendly"]) > 0) {
                        $name = $arr_ax_data["http://axschema.org/namePerson/friendly"][0];
                    }
                }
                $userid = trim(str_replace(array('http://', 'https://'), '', $openid), '/');
                //	always remove the protocol
                $pattern = @$_SESSION['OpenID_cleaner_pattern'];
                if ($pattern) {
                    if (preg_match($pattern, $userid, $matches)) {
                        $userid = $matches[1];
                    }
                }
                $provider = @$_SESSION['provider'];
                if (strlen($userid) + strlen($provider) > 63) {
                    $userid = sha1($userid);
                }
                if ($provider) {
                    $userid = $provider . ':' . $userid;
                }
                $redirect = @$_SESSION['OpenID_redirect'];
                $success .= logonFederatedCredentials($userid, $email, $name, $redirect);
            }
        }
    }
    return $success;
}
开发者ID:hatone,项目名称:zenphoto-1.4.1.4,代码行数:95,代码来源:OpenID_finish_auth.php


注:本文中的getConsumer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。