You are here

class CasPropertyBag in CAS 8

Same name and namespace in other branches
  1. 2.x src/CasPropertyBag.php \Drupal\cas\CasPropertyBag

Class CasPropertyBag.

Hierarchy

Expanded class hierarchy of CasPropertyBag

14 files declare their use of CasPropertyBag
CasAutoAssignedRolesTest.php in tests/src/Functional/CasAutoAssignedRolesTest.php
CasEventsTest.php in tests/src/Functional/CasEventsTest.php
CasPostLoginEvent.php in src/Event/CasPostLoginEvent.php
CasPostValidateEvent.php in src/Event/CasPostValidateEvent.php
CasPreLoginEvent.php in src/Event/CasPreLoginEvent.php

... See full list

File

src/CasPropertyBag.php, line 8

Namespace

Drupal\cas
View source
class CasPropertyBag {

  /**
   * The username of the CAS user.
   *
   * @var string
   */
  protected $username;

  /**
   * The original username as it has been received from the CAS server.
   *
   * @var string
   */
  protected $originalUsername;

  /**
   * The proxy granting ticket, if supplied.
   *
   * @var string
   */
  protected $pgt;

  /**
   * An array containing attributes returned from the server.
   *
   * @var array
   */
  protected $attributes = [];

  /**
   * Contructor.
   *
   * @param string $user
   *   The username of the CAS user.
   */
  public function __construct($user) {
    $this->username = $user;
    $this->originalUsername = $user;
  }

  /**
   * Username property setter.
   *
   * @param string $user
   *   The new username.
   */
  public function setUsername($user) {
    $this->username = $user;
  }

  /**
   * Proxy granting ticket property setter.
   *
   * @param string $ticket
   *   The ticket to set as pgt.
   */
  public function setPgt($ticket) {
    $this->pgt = $ticket;
  }

  /**
   * Username property getter.
   *
   * @return string
   *   The username property.
   */
  public function getUsername() {
    return $this->username;
  }

  /**
   * Returns the original username property.
   *
   * @return string
   *   The original username.
   */
  public function getOriginalUsername() {
    return $this->originalUsername;
  }

  /**
   * Proxy granting ticket getter.
   *
   * @return string
   *   The pgt property.
   */
  public function getPgt() {
    return $this->pgt;
  }

  /**
   * Attributes property setter.
   *
   * @param array $cas_attributes
   *   An associative array containing attribute names as keys.
   */
  public function setAttributes(array $cas_attributes) {
    $this->attributes = $cas_attributes;
  }

  /**
   * Cas attributes getter.
   *
   * @return array
   *   The attributes property.
   */
  public function getAttributes() {
    return $this->attributes;
  }

  /**
   * Adds a single attribute.
   *
   * @param string $name
   *   The attribute name.
   * @param mixed $value
   *   The attribute value.
   */
  public function setAttribute($name, $value) {
    $this->attributes[$name] = $value;
  }

  /**
   * Returns a single attribute if exists.
   *
   * @param string $name
   *   The name of the attribute.
   *
   * @return mixed|null
   *   The attribute value, or NULL if it does not exist.
   */
  public function getAttribute($name) {
    return $this
      ->hasAttribute($name) ? $this->attributes[$name] : NULL;
  }

  /**
   * Checks whether an attribute exists.
   *
   * @param string $name
   *   The name of the attribute.
   *
   * @return bool
   *   TRUE if the attribute exists, FALSE otherwise.
   */
  public function hasAttribute($name) {
    return isset($this->attributes[$name]);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CasPropertyBag::$attributes protected property An array containing attributes returned from the server.
CasPropertyBag::$originalUsername protected property The original username as it has been received from the CAS server.
CasPropertyBag::$pgt protected property The proxy granting ticket, if supplied.
CasPropertyBag::$username protected property The username of the CAS user.
CasPropertyBag::getAttribute public function Returns a single attribute if exists.
CasPropertyBag::getAttributes public function Cas attributes getter.
CasPropertyBag::getOriginalUsername public function Returns the original username property.
CasPropertyBag::getPgt public function Proxy granting ticket getter.
CasPropertyBag::getUsername public function Username property getter.
CasPropertyBag::hasAttribute public function Checks whether an attribute exists.
CasPropertyBag::setAttribute public function Adds a single attribute.
CasPropertyBag::setAttributes public function Attributes property setter.
CasPropertyBag::setPgt public function Proxy granting ticket property setter.
CasPropertyBag::setUsername public function Username property setter.
CasPropertyBag::__construct public function Contructor.