CommonSense PHP API Library
OAuthDataStore Class Reference

List of all members.

Public Member Functions

 __construct ($oauthParams=null, $tokenType=null)
 checkConsumer ($consumerKey, $tokenKey)
 getCallbackUrl ($tokenKey)
 getVerifier ($tokenKey, $consumerKey)
 lookupConsumer ($consumerKey)
 lookupToken ($consumer, $tokenType, $token)
 lookupNonce ($consumer, $token, $nonce, $timestamp)
 insertNonce ($nonce, $tokenKey, $consumerKey)
 newRequestToken ($consumer, $callback=null)
 newAccessToken ($token, $consumer, $verifier=null)
 insertVerifier ($verifier, $tokenKey)
 setConsumer ($consumer, $callback=null)
 setToken ($token, $tokenType="request")
 getSecret ($consumerKey, $tokenKey, $secretType="consumer")
 setAllowed ($tokenKey, $value, $userId, $expirTime, $expirTimeUnit)
 getAllowed ($tokenKey, $consumerKey)
 getValidUserID ($tokenKey, $consumerKey)
 getConsumerName ($tokenKey)
 insertUserSessionId ($userId, $sessionId, $timestamp, $ip="")
 getUserId ($sessionId)
 checkLogin ($user, $passwd)

Public Attributes

 $consumer
 $requestToken
 $accessToken
 $nonce
const ERR_NO_TOKEN = 1
const ERR_NO_VERIFIER = 2
const ERR_NO_CALLBACK = 3
const ERR_NEW_ACCESS_TOKEN = 4
const ERR_NO_ALLOWED_RETRIEVED = 5
const ERR_NO_USER_ID = 6
const ERR_INVALID_LOGIN = 7
const ERR_NO_CONSUMER = 10
const ERR_NO_AUTHORIZED_CONSUMER = 11
const ERR_NO_CONSUMER_NAME = 12
const EXPIR_TIME_NEVER = 0
const EXPIR_TIME_IN_DAYS = 1
const EXPIR_TIME_IN_WEEKS = 2
const EXPIR_TIME_IN_MONTHS = 3
const EXPIR_TIME_IN_YEARS = 4

Constructor & Destructor Documentation

OAuthDataStore::__construct ( oauthParams = null,
tokenType = null 
)

Constructor.

Parameters:
array$oauthParams
string$tokenType

Member Function Documentation

OAuthDataStore::checkConsumer ( consumerKey,
tokenKey 
)

Check if the consumer exists in oauth_credentials. If so, return the credential.

Parameters:
string$consumerKey
string$tokenKey
Returns:
OAuthConsumer
Exceptions:
DbException
OAuthDataStore::checkLogin ( user,
passwd 
)

Check the user and password and return the user id.

Parameters:
string$user
string$passwd
Exceptions:
DbException
Returns:
integer
OAuthDataStore::getAllowed ( tokenKey,
consumerKey 
)
Parameters:
string$tokenKey
string$consumerKey
Exceptions:
DbException

Retrieve the callback url from the db.

Parameters:
string$tokenKey
Exceptions:
DbException
Returns:
string

Return the consumer name.

Parameters:
string$tokenKey
Exceptions:
DbException
Returns:
string
OAuthDataStore::getSecret ( consumerKey,
tokenKey,
secretType = "consumer" 
)
Parameters:
string$consumerKey
string$tokenKey
string$secretTypeconsumer|token
Returns:
string
OAuthDataStore::getUserId ( sessionId)

Return the user id giving the session id.

Parameters:
string$sessionId
Returns:
integer
OAuthDataStore::getValidUserID ( tokenKey,
consumerKey 
)
Parameters:
string$tokenKey
string$consumerKey
Exceptions:
DbException
OAuthDataStore::getVerifier ( tokenKey,
consumerKey 
)

Retrieve the verifier code.

Parameters:
string$tokenKey
string$consumerKey
Exceptions:
DbException
Returns:
string
OAuthDataStore::insertNonce ( nonce,
tokenKey,
consumerKey 
)

This method is executed from the provider, in the request token step.

Parameters:
string$nonce
string$tokenKey
string$consumerKey
OAuthDataStore::insertUserSessionId ( userId,
sessionId,
timestamp,
ip = "" 
)

Insert the user id and session id in user_session table.

Parameters:
integer$userId
string$sessionId
integer$timestamp
string$ip
OAuthDataStore::insertVerifier ( verifier,
tokenKey 
)

Insert the verification code in the db.

Parameters:
string$verifier
string$tokenKey
OAuthDataStore::lookupConsumer ( consumerKey)
OAuthDataStore::lookupNonce ( consumer,
token,
nonce,
timestamp 
)

Check if a nonce has been used before, if it has not been used is stored in the db.

Parameters:
OAuthConsumer$consumer
OAuthToken$token
string$nonce
string$timestamp
OAuthDataStore::lookupToken ( consumer,
tokenType,
token 
)
OAuthDataStore::newAccessToken ( token,
consumer,
verifier = null 
)

Create a new access token and insert it into the db.

Parameters:
OAuthToken$token
OAuthConsumer$consumer
string$verifier
Exceptions:
DbException
Returns:
OAuthToken
OAuthDataStore::newRequestToken ( consumer,
callback = null 
)

Create a new temporary token and insert it into the db.

Parameters:
OAuthConsumer$consumer
string$callback
Returns:
OAuthToken
OAuthDataStore::setAllowed ( tokenKey,
value,
userId,
expirTime,
expirTimeUnit 
)

In the authorization step, the user allows or disallows the consumer app to access their data. If the user allows the consumer app, it's also set the expiration time in which the credential will be valid.

Parameters:
string$tokenKey
boolean$value
integer$userId
integer$expirTime
integer$expirTimeUnit
OAuthDataStore::setConsumer ( consumer,
callback = null 
)
Parameters:
OAuthConsumer$consumer
OAuthDataStore::setToken ( token,
tokenType = "request" 
)

Set any kind of token, request or access token.

Parameters:
OAuthToken$token
string$tokenTyperequest|access

Member Data Documentation

OAuthDataStore::$accessToken
OAuthDataStore::$consumer
OAuthDataStore::$nonce
OAuthDataStore::$requestToken

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables