You are here

class ServicesClientConnectionBasicAuth in Services Client 7

Same name and namespace in other branches
  1. 7.2 services_client_connection/plugins/ServicesClientConnectionBasicAuth.inc \ServicesClientConnectionBasicAuth

@file Session authentication for 3.x version

Hierarchy

Expanded class hierarchy of ServicesClientConnectionBasicAuth

1 string reference to 'ServicesClientConnectionBasicAuth'
_services_client_connection_auth in services_client_connection/include/plugin_definition.inc
List of auth plugins provided by module

File

services_client_connection/plugins/ServicesClientConnectionBasicAuth.inc, line 8
Session authentication for 3.x version

View source
class ServicesClientConnectionBasicAuth extends ServicesClientConnectionAuth {

  /**
   * Implements configForm().
   */
  public function configForm(&$form, &$form_state) {
    $form['username'] = array(
      '#type' => 'textfield',
      '#title' => t('Username'),
      '#default_value' => isset($this->config['username']) ? $this->config['username'] : '',
    );
    $form['password'] = array(
      '#type' => 'textfield',
      '#title' => t('Password'),
      '#default_value' => isset($this->config['password']) ? $this->config['password'] : '',
    );
  }

  /**
   * Implements configFormSubmit().
   */
  public function configFormSubmit(&$form, &$form_state) {
    parent::configFormSubmit($form, $form_state);
    $form_state['config']['username'] = $form_state['values']['username'];
    $form_state['config']['password'] = $form_state['values']['password'];
  }

  /**
   * Implements prepareRequest().
   *
   * @param ServicesClientConnectionHttpRequest $request
   */
  public function prepareRequest(ServicesClientConnectionHttpRequest &$request) {
    parent::prepareRequest($request);
    $credentials = $this->config['username'] . ':' . $this->config['password'];
    $credentials = base64_encode($credentials);
    $request->http_headers['Authorization'] = 'Basic ' . $credentials;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ServicesClientConnectionAuth::connect public function Make initial conneciton to client
ServicesClientConnectionAuth::login public function Login and hold login state on beginning of session 1
ServicesClientConnectionAuth::logout public function Logout client from remote site 1
ServicesClientConnectionBasicAuth::configForm public function Implements configForm(). Overrides ServicesClientConnectionPlugin::configForm
ServicesClientConnectionBasicAuth::configFormSubmit public function Implements configFormSubmit(). Overrides ServicesClientConnectionPlugin::configFormSubmit
ServicesClientConnectionBasicAuth::prepareRequest public function Implements prepareRequest(). Overrides ServicesClientConnectionPlugin::prepareRequest
ServicesClientConnectionPlugin::$client protected property Reference to client
ServicesClientConnectionPlugin::$config protected property Plugin specific configuration
ServicesClientConnectionPlugin::$connection protected property Connection definition
ServicesClientConnectionPlugin::configFormValidate public function 1
ServicesClientConnectionPlugin::processResponse public function 2
ServicesClientConnectionPlugin::__construct public function 1