Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
EOAuthService Class Reference
Inheritance diagram for EOAuthService:
EAuthServiceBase IAuthService IAuthService TwitterOAuthService CustomTwitterService

Public Member Functions

 init ($component, $options=array())
 authenticate ()
 makeSignedRequest ($url, $options=array(), $parseJson=true)
- Public Member Functions inherited from EAuthServiceBase
 __get ($name)
 __isset ($name)
 getServiceName ()
 getServiceTitle ()
 getServiceType ()
 getJsArguments ()
 setComponent ($component)
 getComponent ()
 setRedirectUrl ($url)
 getRedirectUrl ()
 setCancelUrl ($url)
 getCancelUrl ()
 getIsAuthenticated ()
 redirect ($url=null)
 cancel ($url=null)
 getId ()
 getAttributes ()
 getAttribute ($key, $default=null)
 hasAttribute ($key)
 getItem ()
 getItemAttributes ()
- Public Member Functions inherited from IAuthService
 cancel ()

Protected Member Functions

 getConsumer ()
 getAccessToken ()
 initRequest ($url, $options=array())
- Protected Member Functions inherited from EAuthServiceBase
 makeRequest ($url, $options=array(), $parseJson=true)
 parseJson ($response)
 fetchJsonError ($json)
 getStateKeyPrefix ()
 setState ($key, $value, $defaultValue=null)
 hasState ($key)
 getState ($key, $defaultValue=null)
 fetchAttributes ()
 _fetchAttributes ()

Protected Attributes

 $key
 $secret
 $scope = ''
 $providerOptions
- Protected Attributes inherited from EAuthServiceBase
 $name
 $title
 $type
 $jsArguments = array()
 $attributes = array()
 $authenticated = false

Detailed Description

Definition at line 16 of file EOAuthService.php.

Member Function Documentation

EOAuthService::authenticate ( )

Authenticate the user.

Returns
boolean whether user was successfuly authenticated.

Reimplemented from EAuthServiceBase.

Reimplemented in TwitterOAuthService.

Definition at line 69 of file EOAuthService.php.

References EAuthServiceBase\getIsAuthenticated().

{
$this->authenticated = $this->auth->authenticate();
return $this->getIsAuthenticated();
}
EOAuthService::getAccessToken ( )
protected

Returns the OAuth access token.

Returns
string the token.

Definition at line 86 of file EOAuthService.php.

Referenced by makeSignedRequest().

{
return $this->auth->getProvider()->token;
}
EOAuthService::getConsumer ( )
protected

Returns the OAuth consumer.

Returns
object the consumer.

Definition at line 78 of file EOAuthService.php.

Referenced by makeSignedRequest().

{
return $this->auth->getProvider()->consumer;
}
EOAuthService::init (   $component,
  $options = array() 
)

Initialize the component.

Parameters
EAuth$componentthe component instance.
array$optionsproperties initialization.

Reimplemented from EAuthServiceBase.

Definition at line 54 of file EOAuthService.php.

{
parent::init($component, $options);
$this->auth = new EOAuthUserIdentity(array(
'scope' => $this->scope,
'key' => $this->key,
'secret' => $this->secret,
'provider' => $this->providerOptions,
));
}
EOAuthService::initRequest (   $url,
  $options = array() 
)
protected

Initializes a new session and return a cURL handle.

Parameters
string$urlurl to request.
array$optionsHTTP request options. Keys: query, data, referer.
boolean$parseJsonWhether to parse response in json format.
Returns
cURL handle.

Reimplemented from EAuthServiceBase.

Definition at line 97 of file EOAuthService.php.

{
$ch = parent::initRequest($url, $options);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
if (isset($options['data'])) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml","SOAPAction: \"/soap/action/query\"", "Content-length: ".strlen($options['data'])));
}
return $ch;
}
EOAuthService::makeSignedRequest (   $url,
  $options = array(),
  $parseJson = true 
)

Returns the protected resource.

Parameters
string$urlurl to request.
array$optionsHTTP request options. Keys: query, data, referer.
boolean$parseJsonWhether to parse response in json format.
Returns
string the response.
See Also
makeRequest

Definition at line 114 of file EOAuthService.php.

References getAccessToken(), getConsumer(), EAuthServiceBase\getIsAuthenticated(), and EAuthServiceBase\makeRequest().

Referenced by CustomTwitterService\fetchAttributes(), and TwitterOAuthService\fetchAttributes().

{
if (!$this->getIsAuthenticated())
throw new CHttpException(401, Yii::t('eauth', 'Unable to complete the request because the user was not authenticated.'));
$consumer = $this->getConsumer();
$signatureMethod = new OAuthSignatureMethod_HMAC_SHA1();
$token = $this->getAccessToken();
$request = OAuthRequest::from_consumer_and_token($consumer, $token, isset($options['data']) ? 'POST' : 'GET', $url);
$request->sign_request($signatureMethod, $consumer, $token);
$url = $request->to_url();
return $this->makeRequest($url, $options, $parseJson);
}

Member Data Documentation

EOAuthService::$providerOptions
protected
Initial value:
array(
'request' => '',
'authorize' => '',
'access' => '',
)

Definition at line 42 of file EOAuthService.php.


The documentation for this class was generated from the following file: