trait UserPass

Trait for storage classes that store a possibly-encrypted username and password

Traits

Trait for storage classes that store a optionally-encrypted credential fields

Trait allowing objects to store fields encrypted with an account's crypto

Properties

private $crypto_cache

Stores fields decrypted in memory

from  FieldCrypt

Methods

static array
getEncryptedFields()

No description

Account|null
GetAccount()

Returns the account that owns this object

static array
LoadByAccount(ObjectDatabase $database, Account $account)

Returns all objects owned by the given account

static array
GetFieldCryptFieldTemplate()

Gets the extra DB fields required for this trait

bool
isFieldEncrypted($field)

Returns true if the given DB field is encrypted

bool
isCryptoAvailable()

Returns true if field crypto is unlockable

string
GetEncryptedScalar(string $field)

Decrypts and returns the value of the given field

RequireCrypto()

Unlocks account crypto for usage and returns it

string|null
TryGetEncryptedScalar(string $field)

Decrypts and returns the value of the given field

SetEncryptedScalar(string $field, string|null $value, bool|null $fieldcrypt = null)

Sets the value of the given field

SetEncrypted(bool $crypt)

Sets the crypto state of all stored fields

static void
DecryptAccount(ObjectDatabase $database, Account $account)

Loads any objects for the given account and decrypts their fields

static string
GetFieldCryptCreateUsage()

Returns the command usage for Create()

FieldCryptCreate(Input $input)

Performs cred-crypt level initialization on a new storage

static string
GetFieldCryptEditUsage()

Returns the command usage for Edit()

FieldCryptEdit(Input $input)

Performs cred-crypt level edit on an existing storage

array
GetFieldCryptClientObject()

Returns the printable client object of this trait

static array
GetFieldTemplate()

Gets the extra DB fields required for this trait

array
GetClientObject(bool $activate = false)

Returns the printable client object of this trait

static string
GetCreateUsage()

Returns the command usage for Create()

static Storage
Create(ObjectDatabase $database, Input $input, FSManager $filesystem)

Performs cred-crypt level initialization on a new storage

static string
GetEditUsage()

Returns the command usage for Edit()

Edit(Input $input)

Performs cred-crypt level edit on an existing storage

string|null
TryGetUsername()

Returns the decrypted username

string|null
TryGetPassword()

Returns the decrypted password

SetUsername(string|null $username)

Sets the stored username

SetPassword(string|null $password)

Sets the stored password

Details

at line 21
static protected array getEncryptedFields()

No description

Return Value

array

in FieldCrypt at line 22
abstract protected Account|null GetAccount()

Returns the account that owns this object

Return Value

Account|null

in FieldCrypt at line 25
abstract static array LoadByAccount(ObjectDatabase $database, Account $account)

Returns all objects owned by the given account

Parameters

ObjectDatabase $database
Account $account

Return Value

array

in FieldCrypt at line 28
static array GetFieldCryptFieldTemplate()

Gets the extra DB fields required for this trait

Return Value

array

in FieldCrypt at line 35
protected bool isFieldEncrypted($field)

Returns true if the given DB field is encrypted

Parameters

$field

Return Value

bool

in FieldCrypt at line 39
protected bool isCryptoAvailable()

Returns true if field crypto is unlockable

Return Value

bool

in FieldCrypt at line 55
protected string GetEncryptedScalar(string $field)

Decrypts and returns the value of the given field

Parameters

string $field

field name

Return Value

string

decrypted value

Exceptions

KeyNotFoundException

if the value is null

See also

FieldCrypt::TryGetEncryptedScalar

in FieldCrypt at line 63
protected Account RequireCrypto()

Unlocks account crypto for usage and returns it

Return Value

Account

in FieldCrypt at line 78
protected string|null TryGetEncryptedScalar(string $field)

Decrypts and returns the value of the given field

Parameters

string $field

field name

Return Value

string|null

decrypted value

in FieldCrypt at line 103
protected FieldCrypt SetEncryptedScalar(string $field, string|null $value, bool|null $fieldcrypt = null)

Sets the value of the given field

Parameters

string $field

field to set

string|null $value

value to set

bool|null $fieldcrypt

if true, encrypt - default current state

Return Value

FieldCrypt

in FieldCrypt at line 129
protected FieldCrypt SetEncrypted(bool $crypt)

Sets the crypto state of all stored fields

Parameters

bool $crypt

true to encrypted, false if not

Return Value

FieldCrypt

in FieldCrypt at line 145
static void DecryptAccount(ObjectDatabase $database, Account $account)

Loads any objects for the given account and decrypts their fields

Parameters

ObjectDatabase $database

database reference

Account $account

account to load by

Return Value

void

in OptFieldCrypt at line 161
static string GetFieldCryptCreateUsage()

Returns the command usage for Create()

Return Value

string

in OptFieldCrypt at line 164
OptFieldCrypt FieldCryptCreate(Input $input)

Performs cred-crypt level initialization on a new storage

Parameters

Input $input

Return Value

OptFieldCrypt

in OptFieldCrypt at line 172
static string GetFieldCryptEditUsage()

Returns the command usage for Edit()

Return Value

string

in OptFieldCrypt at line 175
OptFieldCrypt FieldCryptEdit(Input $input)

Performs cred-crypt level edit on an existing storage

Parameters

Input $input

Return Value

OptFieldCrypt

in OptFieldCrypt at line 185
array GetFieldCryptClientObject()

Returns the printable client object of this trait

Return Value

array

fields mapped to {field_iscrypt:bool}

at line 24
static array GetFieldTemplate()

Gets the extra DB fields required for this trait

Return Value

array

at line 36
array GetClientObject(bool $activate = false)

Returns the printable client object of this trait

Parameters

bool $activate

Return Value

array

{username:?string, password:bool}

See also

Storage::GetClientObject

at line 45
static string GetCreateUsage()

Returns the command usage for Create()

Return Value

string

at line 48
static Storage Create(ObjectDatabase $database, Input $input, FSManager $filesystem)

Performs cred-crypt level initialization on a new storage

Parameters

ObjectDatabase $database
Input $input
FSManager $filesystem

Return Value

Storage

at line 57
static string GetEditUsage()

Returns the command usage for Edit()

Return Value

string

at line 60
Storage Edit(Input $input)

Performs cred-crypt level edit on an existing storage

Parameters

Input $input

Return Value

Storage

at line 71
protected string|null TryGetUsername()

Returns the decrypted username

Return Value

string|null

at line 74
protected string|null TryGetPassword()

Returns the decrypted password

Return Value

string|null

at line 81
protected UserPass SetUsername(string|null $username)

Sets the stored username

Parameters

string|null $username

username

Return Value

UserPass

at line 89
protected UserPass SetPassword(string|null $password)

Sets the stored password

Parameters

string|null $password

password

Return Value

UserPass