Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
Public Member Functions | Protected Attributes | List of all members
EOpenIDService Class Reference
Inheritance diagram for EOpenIDService:
EAuthServiceBase IAuthService IAuthService GoogleOpenIDService YandexOpenIDService CustomGoogleService GoogleService CustomYandexService

Public Member Functions

 init ($component, $options=array())
 authenticate ()
- 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 Attributes

 $url
 $requiredAttributes = array()
- Protected Attributes inherited from EAuthServiceBase
 $name
 $title
 $type
 $jsArguments = array()
 $attributes = array()
 $authenticated = false

Additional Inherited Members

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

Detailed Description

Definition at line 16 of file EOpenIDService.php.

Member Function Documentation

EOpenIDService::authenticate ( )

Authenticate the user.

Returns
boolean whether user was successfuly authenticated.

Reimplemented from EAuthServiceBase.

Definition at line 49 of file EOpenIDService.php.

References IAuthService\cancel(), and EAuthServiceBase\getServiceName().

{
if (!empty($_REQUEST['openid_mode'])) {
switch ($_REQUEST['openid_mode']) {
case 'id_res':
try {
if ($this->auth->validate()) {
$this->attributes['id'] = $this->auth->identity;
$attributes = $this->auth->getAttributes();
foreach ($this->requiredAttributes as $key => $attr) {
if (isset($attributes[$attr[1]])) {
$this->attributes[$key] = $attributes[$attr[1]];
}
else {
throw new EAuthException(Yii::t('eauth', 'Unable to complete the authentication because the required data was not received.', array('{provider}' => ucfirst($this->getServiceName()))));
return false;
}
}
$this->authenticated = true;
return true;
}
else {
throw new EAuthException(Yii::t('eauth', 'Unable to complete the authentication because the required data was not received.', array('{provider}' => ucfirst($this->getServiceName()))));
return false;
}
}
catch (Exception $e) {
throw new EAuthException($e->getMessage(), $e->getCode());
}
break;
case 'cancel':
$this->cancel();
break;
default:
throw new CHttpException(400, Yii::t('yii', 'Your request is invalid.'));
break;
}
}
else {
$this->auth->identity = $this->url; //Setting identifier
$this->auth->required = array(); //Try to get info from openid provider
foreach ($this->requiredAttributes as $attribute)
$this->auth->required[$attribute[0]] = $attribute[1];
$this->auth->realm = Yii::app()->request->hostInfo;
$this->auth->returnUrl = $this->auth->realm.Yii::app()->request->url; //getting return URL
try {
$url = $this->auth->authUrl();
Yii::app()->request->redirect($url);
}
catch (Exception $e) {
throw new EAuthException($e->getMessage(), $e->getCode());
}
}
return false;
}
EOpenIDService::init (   $component,
  $options = array() 
)

Initialize the component.

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

Reimplemented from EAuthServiceBase.

Definition at line 39 of file EOpenIDService.php.

{
parent::init($component, $options);
$this->auth = Yii::app()->loid->load();
//$this->auth = new EOpenID();
}

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