2 require_once(dirname(dirname(__FILE__)) .
'/libextinc/OAuth.php');
21 'consumers' =>
'consumer = array with consumer attributes',
22 'nonce' =>
'nonce+consumer_key = -boolean-',
23 'requesttorequest' =>
'requestToken.key = array(version,callback,consumerKey,)',
24 'authorized' =>
'requestToken.key, verifier = array(authenticated-user-attributes)',
25 'access' =>
'accessToken.key+consumerKey = accesstoken',
26 'request' =>
'requestToken.key+consumerKey = requesttoken',
48 $request_attributes = $this->store->get(
'requesttorequest', $requestTokenKey,
'');
50 if ($request_attributes[
'value']) {
52 if ($request_attributes[
'value'][
'callback']) {
53 $url = $request_attributes[
'value'][
'callback'];
58 $oConsumer = $this->
lookup_consumer($request_attributes[
'value'][
'consumerKey']);
60 if ($oConsumer && ($oConsumer->callback_url)) {
61 $url = $oConsumer->callback_url;
65 $url = \SimpleSAML\Utils\HTTP::addURLParameters(
$url, array(
"oauth_verifier"=>$verifier));
67 $this->store->set(
'authorized', $requestTokenKey, $verifier,
$data, $this->config->getValue(
'requestTokenDuration', 60*30));
69 return array(
$url, $verifier);
83 return $this->store->exists(
'authorized', $requestToken, $verifier);
89 $data = $this->store->get(
'authorized',
$token, $verifier);
90 return $data[
'value'];
101 $this->store->remove(
'authorized', $requestToken, $verifier);
105 $this->store->set(
'authorized', $accessTokenKey,
'', $authorizedData, $this->config->getValue(
'accessTokenDuration', 60*60*24));
111 if (!$this->store->exists(
'consumers', $consumer_key,
'')) {
114 $consumer = $this->store->get(
'consumers', $consumer_key,
'');
117 if ($consumer[
'value'][
'callback_url']) {
118 $callback = $consumer[
'value'][
'callback_url'];
121 if ($consumer[
'value'][
'RSAcertificate']) {
122 return new OAuthConsumer($consumer[
'value'][
'key'], $consumer[
'value'][
'RSAcertificate'], $callback);
124 return new OAuthConsumer($consumer[
'value'][
'key'], $consumer[
'value'][
'secret'], $callback);
131 $data = $this->store->get($tokenType,
$token, $consumer->key);
133 throw new Exception(
'Could not find token');
135 return $data[
'value'];
141 if ($this->store->exists(
'nonce', $nonce, $consumer->key)) {
144 $this->store->set(
'nonce', $nonce, $consumer->key,
true, $this->config->getValue(
'nonceCache', 60*60*24*14));
152 $lifetime = $this->config->getValue(
'requestTokenDuration', 60*30);
155 $token->callback = $callback;
156 $this->store->set(
'request',
$token->key, $consumer->key,
$token, $lifetime);
159 $request_attributes = array(
160 'callback' => $callback,
162 'consumerKey' => $consumer->key,
164 $this->store->set(
'requesttorequest',
$token->key,
'', $request_attributes, $lifetime);
167 $this->store->set(
'requesttoconsumer',
$token->key,
'', $consumer->key, $lifetime);
176 $this->store->set(
'access', $accesstoken->key, $consumer->key, $accesstoken, $this->config->getValue(
'accessTokenDuration', 60*60*24) );
188 if (!$this->store->exists(
'requesttorequest', $requestTokenKey,
'')) {
192 $request = $this->store->get(
'requesttorequest', $requestTokenKey,
'');
193 $consumerKey =
$request[
'value'][
'consumerKey'];
198 $consumer = $this->store->get(
'consumers', $consumerKey[
'value'],
'');
199 return $consumer[
'value'];
static generateID()
Generate a random identifier, ID_LENGTH bytes long.
foreach($paths as $path) $request
OAuth PECL extension includes an OAuth Exception class, so we need to wrap the definition of this cla...
lookup_token($consumer, $tokenType='default', $token)
new_access_token($requestToken, $consumer, $verifier=null)
isAuthorized($requestToken, $verifier='')
Perform lookup whether a given token exists in the list of authorized tokens; if a verifier is passed...
lookup_consumer_by_requestToken($requestTokenKey)
Return OAuthConsumer-instance that a given requestToken was issued to.
getAuthorizedData($token, $verifier='')
Attribute-related utility methods.
new_request_token($consumer, $callback=null, $version=null)
lookup_nonce($consumer, $token, $nonce, $timestamp)
lookup_consumer($consumer_key)
moveAuthorizedData($requestToken, $verifier, $accessTokenKey)
authorize($requestTokenKey, $data)
Attach the data to the token, and establish the Callback URL and verifier.
foreach($mandatory_scripts as $file) $timestamp
static getOptionalConfig($filename='config.php', $configSet='simplesaml')
Load a configuration file from a configuration set.