You are here

class CredentialsStorage in Lightweight Directory Access Protocol (LDAP) 8.4

Same name and namespace in other branches
  1. 8.3 ldap_servers/src/Helper/CredentialsStorage.php \Drupal\ldap_servers\Helper\CredentialsStorage

Temporarily stores credentials from user input.

This temporary storage is required so that LDAP can work with them in the clear independent of the login form process and to avoid passing them around dozens of functions.

Hierarchy

Expanded class hierarchy of CredentialsStorage

6 files declare their use of CredentialsStorage
CredentialsStorageTest.php in ldap_servers/tests/src/Unit/CredentialsStorageTest.php
LdapBridge.php in ldap_servers/src/LdapBridge.php
LdapEntryProvisionSubscriber.php in ldap_user/src/EventSubscriber/LdapEntryProvisionSubscriber.php
LdapProtectedUserFieldConstraintValidator.php in ldap_user/src/Plugin/Validation/Constraint/LdapProtectedUserFieldConstraintValidator.php
ldap_user.module in ldap_user/ldap_user.module

... See full list

File

ldap_servers/src/Helper/CredentialsStorage.php, line 14

Namespace

Drupal\ldap_servers\Helper
View source
class CredentialsStorage {

  /**
   * User DN.
   *
   * @var string
   */
  private static $userDn;

  /**
   * User Password.
   *
   * @var string
   */
  private static $userPassword;

  /**
   * Validate.
   *
   * @var bool
   */
  private static $validate = FALSE;

  /**
   * Stores the user DN as provided by other LDAP modules.
   *
   * @param string|null $userDn
   *   DN to store.
   */
  public static function storeUserDn(?string $userDn) : void {
    self::$userDn = $userDn;
  }

  /**
   * Stores the password from user input.
   *
   * @param string|null $password
   *   Password to store.
   */
  public static function storeUserPassword(?string $password) : void {
    self::$userPassword = $password;
  }

  /**
   * Turn testing of user credentials on or off.
   *
   * @param bool $validate
   *   Defaults to false.
   */
  public static function testCredentials(bool $validate) : void {
    self::$validate = $validate;
  }

  /**
   * Return the temporarily saved user DN.
   *
   * @return null|string
   *   Login name.
   */
  public static function getUserDn() : ?string {
    return self::$userDn;
  }

  /**
   * Return the temporarily saved user password.
   *
   * @return null|string
   *   Login password.
   */
  public static function getPassword() : ?string {
    return self::$userPassword;
  }

  /**
   * Whether the bind function will use these credentials.
   *
   * @return bool
   *   Defaults to false.
   */
  public static function validateCredentials() : bool {
    return self::$validate;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CredentialsStorage::$userDn private static property User DN.
CredentialsStorage::$userPassword private static property User Password.
CredentialsStorage::$validate private static property Validate.
CredentialsStorage::getPassword public static function Return the temporarily saved user password.
CredentialsStorage::getUserDn public static function Return the temporarily saved user DN.
CredentialsStorage::storeUserDn public static function Stores the user DN as provided by other LDAP modules.
CredentialsStorage::storeUserPassword public static function Stores the password from user input.
CredentialsStorage::testCredentials public static function Turn testing of user credentials on or off.
CredentialsStorage::validateCredentials public static function Whether the bind function will use these credentials.