BAOBAB
CO_Login_Manager Class Reference
Inheritance diagram for CO_Login_Manager:
Collaboration diagram for CO_Login_Manager:

Public Member Functions

 __construct ( $in_login_id=NULL, $in_hashed_password=NULL, $in_raw_password=NULL, $in_initial_personal_ids=0)
 
 load_from_db ($in_db_result)
 
 is_manager ()
 
 add_new_login_id ( $in_login_id)
 
- Public Member Functions inherited from CO_Cobra_Login
 __construct ( $in_login_id=NULL, $in_hashed_password=NULL, $in_raw_password=NULL)
 
 set_personal_ids ( $in_personal_ids=[])
 
 security_exemption ()
 
- Public Member Functions inherited from CO_Security_Login
 __construct ( $in_db_object=NULL, $in_db_result=NULL, $in_login_id=NULL, $in_ids=NULL, $in_personal_ids=NULL)
 
 set_ids ( $in_ids_array)
 
 add_id ( $in_id)
 
 remove_id ( $in_id)
 
 ids ()
 
 user_can_edit_ids ()
 
 personal_ids ()
 
 get_crypted_password ( $in_password_to_crypt=NULL)
 
 is_login_valid ( $in_login_id, $in_hashed_password=NULL, $in_raw_password=NULL, $in_dont_create_new_api_key=false)
 
 i_am_a_god ()
 
 is_god ()
 
 get_lang ()
 
 set_lang ( $in_lang_id=NULL)
 
 get_user_object ()
 
 set_password_from_cleartext ( $in_cleartext_password)
 
 is_api_key_valid ( $in_api_key)
 
 get_remaining_time ()
 
 get_api_key ()
 
 get_api_key_age_in_seconds ()
 
 clear_api_key ()
 
 add_personal_token_from_current_login ( $in_id)
 
 remove_personal_token_from_this_login ( $in_id)
 
 get_logins_that_have_any_of_my_ids ()
 
 user_can_write ()
 
 delete_from_db ()
 
- Public Member Functions inherited from CO_Security_Node
 __construct ( $in_db_object=NULL, $in_db_result=NULL)
 
- Public Member Functions inherited from A_CO_DB_Table_Base
 set_batch_mode ()
 
 clear_batch_mode ()
 
 id ()
 
 lock ()
 
 locked ()
 
 danger_will_robinson_danger_clear_id ()
 
 user_can_read ()
 
 set_read_security_id ($in_new_id)
 
 set_write_security_id ($in_new_id)
 
 set_name ($in_new_value)
 
 update_db ()
 
 reload_from_db ()
 
 get_access_object ()
 

Protected Attributes

 $_added_new_id
 This is a very temporary, ephemeral semaphore that we use to allow us to add an ID when we create a new object. More...
 
- Protected Attributes inherited from CO_Cobra_Login
 $_special_first_time_security_exemption
 
- Protected Attributes inherited from CO_Security_Login
 $_api_key
 This is an API key for REST. More...
 
 $_personal_ids
 These are personal IDs (special IDs, unique to the login). More...
 
 $_ids
 These are security tokens, available to this ID. More...
 
- Protected Attributes inherited from CO_Security_Node
 $_ids
 
- Protected Attributes inherited from A_CO_DB_Table_Base
 $_db_object
 This is the actual database object that "owns" this instance. It should not be exposed beyond this class or subclasses, thereof. More...
 
 $_id
 This is the within-table unique ID of this record. More...
 
 $_batch_mode
 If this is true, then the write_record call will not be made in update_db. It will be done when clear_batch_mode() is called, instead. More...
 

Additional Inherited Members

- Public Attributes inherited from CO_Security_Login
 $login_id
 
- Public Attributes inherited from A_CO_DB_Table_Base
 $class_description
 This is a description of the class (not the instance). More...
 
 $instance_description
 This is a description that describes the instance. More...
 
 $last_access
 This is a UNIX epoch date that describes the last modification. The default is UNIX Day Two (in case of UTC timezone issues). More...
 
 $name
 This is the "object_name" string field. More...
 
 $read_security_id
 This is a single integer, defining the security ID required to view the record. If it is 0, then it is "open.". More...
 
 $write_security_id
 This is a single integer, defining the required security token to modify the record. If it is 0, then any logged-in user can modify. More...
 
 $context
 This is a mixed associative array, containing fields for the object. More...
 
 $error
 If there is an error, it is contained here, in a LGV_Error instance. More...
 
- Protected Member Functions inherited from CO_Security_Login
 _set_up_api_key ( $key_length)
 
 _default_setup ()
 
 _build_parameter_array ()
 
- Protected Member Functions inherited from A_CO_DB_Table_Base
 _badger_serialize ( $in_data)
 
 _badger_unserialize ( $in_data)
 
 _write_to_db ()
 
 _seppuku ()
 
- Static Protected Member Functions inherited from CO_Security_Login
static _random_str ($length, $keyspace='0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
 

Detailed Description

Definition at line 33 of file co_login_manager.class.php.

Constructor & Destructor Documentation

◆ __construct()

CO_Login_Manager::__construct (   $in_login_id = NULL,
  $in_hashed_password = NULL,
  $in_raw_password = NULL,
  $in_initial_personal_ids = 0 
)

The constructor.

Parameters
$in_login_idThe login ID
$in_hashed_passwordThe password, crypt-hashed
$in_raw_passwordThe password, cleartext.
$in_initial_personal_idsThis is the number of personal IDs to create and assign. It defaults to 0.

Definition at line 41 of file co_login_manager.class.php.

45  {
46  parent::__construct($in_login_id, $in_hashed_password, $in_raw_password, $in_initial_personal_ids);
47  $this->_added_new_id = NULL;
48  $this->class_description = 'This is a security class for login managers.';
49  if (intval($this->id()) == intval(CO_Config::god_mode_id())) {
50  // God Mode is always forced to use the config password.
51  $this->context['hashed_password'] = bin2hex(openssl_random_pseudo_bytes(4)); // Just create a randomish junk password. It will never be used.
52  $this->instance_description = 'GOD MODE: '.(isset($this->name) && $this->name ? "$this->name (".$this->login_id.")" : "Unnamed Login Manager Node (".$this->login_id.")");
53  } else {
54  $this->instance_description = isset($this->name) && $this->name ? "$this->name (".$this->login_id.")" : "Unnamed Login Manager Node (".$this->login_id.")";
55  }
56  }

Member Function Documentation

◆ add_new_login_id()

CO_Login_Manager::add_new_login_id (   $in_login_id)

This allows us to add one single ID to our list. We set our ephemeral ID, then we add the ID, which should pass, just this once.

Returns
true, if the operation succeeded.
Parameters
$in_login_idThe integer ID of the new login item.

Definition at line 96 of file co_login_manager.class.php.

97  {
98  $this->_added_new_id = intval($in_login_id);
99  $ret = $this->add_id($in_login_id);
100  unset($this->_added_new_id);
101  return $ret;
102  }

◆ is_manager()

CO_Login_Manager::is_manager ( )
Returns
true, as we are a manager.

Reimplemented from CO_Security_Login.

Definition at line 85 of file co_login_manager.class.php.

85  {
86  return true;
87  }

◆ load_from_db()

CO_Login_Manager::load_from_db (   $in_db_result)

This function sets up this instance, according to the DB-formatted associative array passed in.

Returns
true, if the instance was able to set itself up to the provided array.

Reimplemented from CO_Cobra_Login.

Definition at line 64 of file co_login_manager.class.php.

64  {
65  $ret = parent::load_from_db($in_db_result);
66 
67  if ($ret) {
68  $this->class_description = 'This is a security class for login managers.';
69  if (intval($this->id()) == intval(CO_Config::god_mode_id())) {
70  // God Mode is always forced to use the config password.
71  $this->context['hashed_password'] = bin2hex(openssl_random_pseudo_bytes(4)); // Just create a randomish junk password. It will never be used.
72  $this->instance_description = 'GOD MODE: '.(isset($this->name) && $this->name ? "$this->name (".$this->login_id.")" : "Unnamed Login Manager Node (".$this->login_id.")");
73  } else {
74  $this->instance_description = isset($this->name) && $this->name ? "$this->name (".$this->login_id.")" : "Unnamed Login Manager Node (".$this->login_id.")";
75  }
76  }
77 
78  return $ret;
79  }

Member Data Documentation

◆ $_added_new_id

CO_Login_Manager::$_added_new_id
protected

This is a very temporary, ephemeral semaphore that we use to allow us to add an ID when we create a new object.

Definition at line 34 of file co_login_manager.class.php.