2require_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 = accestoken',
26 'request' =>
'requestToken.key+consumerKey = requesttoken',
47 $request_attributes = $this->store->get(
'requesttorequest', $requestTokenKey,
'');
48 if ($request_attributes[
'value']) {
50 $v = $request_attributes[
'value'][
'version'];
54 if ($request_attributes[
'value'][
'callback']) {
55 $url = $request_attributes[
'value'][
'callback'];
61 $oConsumer = $this->
lookup_consumer($request_attributes[
'value'][
'consumerKey']);
63 if ($oConsumer && ($oConsumer->callback_url))
$url = $oConsumer->callback_url;
66 $url = \SimpleSAML\Utils\HTTP::addURLParameters(
$url, array(
"oauth_verifier"=>$verifier));
68 $this->store->set(
'authorized', $requestTokenKey, $verifier,
$data, $this->config->getValue(
'requestTokenDuration', 60*30) );
70 return array(
$url, $verifier);
83 return $this->store->exists(
'authorized',
$requestToken, $verifier);
88 $data = $this->store->get(
'authorized', $token, $verifier);
89 return $data[
'value'];
103 $this->store->set(
'authorized', $accessTokenKey,
'', $authorizedData, $this->config->getValue(
'accessTokenDuration', 60*60*24));
108 if (! $this->store->exists(
'consumers', $consumer_key,
''))
return NULL;
109 $consumer = $this->store->get(
'consumers', $consumer_key,
'');
112 if (
$consumer[
'value'][
'callback_url']) $callback =
$consumer[
'value'][
'callback_url'];
114 if (
$consumer[
'value'][
'RSAcertificate']) {
115 return new OAuthConsumer(
$consumer[
'value'][
'key'],
$consumer[
'value'][
'RSAcertificate'], $callback);
117 return new OAuthConsumer(
$consumer[
'value'][
'key'],
$consumer[
'value'][
'secret'], $callback);
124 if (
$data == NULL)
throw new Exception(
'Could not find token');
125 return $data[
'value'];
130 if ($this->store->exists(
'nonce', $nonce,
$consumer->key))
return TRUE;
131 $this->store->set(
'nonce', $nonce,
$consumer->key, TRUE, $this->config->getValue(
'nonceCache', 60*60*24*14));
138 $lifetime = $this->config->getValue(
'requestTokenDuration', 60*30);
141 $token->callback = $callback;
142 $this->store->set(
'request', $token->key,
$consumer->key, $token, $lifetime);
145 $request_attributes = array(
146 'callback' => $callback,
150 $this->store->set(
'requesttorequest', $token->key,
'', $request_attributes, $lifetime);
153 $this->store->set(
'requesttoconsumer', $token->key,
'',
$consumer->key, $lifetime);
161 $this->store->set(
'access', $accestoken->key,
$consumer->key, $accestoken, $this->config->getValue(
'accessTokenDuration', 60*60*24) );
172 if (! $this->store->exists(
'requesttorequest', $requestTokenKey,
''))
return NULL;
174 $request = $this->store->get(
'requesttorequest', $requestTokenKey,
'');
175 $consumerKey = $request[
'value'][
'consumerKey'];
176 if (! $consumerKey) {
180 $consumer = $this->store->get(
'consumers', $consumerKey[
'value'],
'');
foreach($mandatory_scripts as $file) $timestamp
An exception for terminatinating execution or to throw for unit testing.
OAuth PECL extension includes an OAuth Exception class, so we need to wrap the definition of this cla...
static generateID()
Generate a random identifier, ID_LENGTH bytes long.
static getOptionalConfig($filename='config.php', $configSet='simplesaml')
Load a configuration file from a configuration set.
lookup_token($consumer, $tokenType='default', $token)
isAuthorized($requestToken, $verifier='')
Perform lookup whether a given token exists in the list of authorized tokens; if a verifier is passed...
getAuthorizedData($token, $verifier='')
lookup_consumer_by_requestToken($requestTokenKey)
Return OAuthConsumer-instance that a given requestToken was issued to.
lookup_consumer($consumer_key)
lookup_nonce($consumer, $token, $nonce, $timestamp)
new_request_token($consumer, $callback=null, $version=null)
moveAuthorizedData($requestToken, $verifier, $accessTokenKey)
new_access_token($requestToken, $consumer, $verifier=null)
authorize($requestTokenKey, $data)
Attach the data to the token, and establish the Callback URL and verifier.
Attribute-related utility methods.