1.0.0 Alpha Release #59
5 changed files with 51 additions and 20 deletions
|
@ -47,6 +47,9 @@
|
|||
{
|
||||
unset($e);
|
||||
}
|
||||
|
||||
if($this->Vault == null)
|
||||
$this->Vault = new Vault();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,7 +84,7 @@
|
|||
* @throws RuntimeException
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public function loadVault(): void
|
||||
private function loadVault(): void
|
||||
{
|
||||
if($this->Vault !== null)
|
||||
return;
|
||||
|
@ -127,4 +130,12 @@
|
|||
{
|
||||
return $this->CredentialsPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Vault|null
|
||||
*/
|
||||
public function getVault(): ?Vault
|
||||
{
|
||||
return $this->Vault;
|
||||
}
|
||||
}
|
|
@ -131,7 +131,7 @@
|
|||
|
||||
if($entry->getPassword() === null)
|
||||
{
|
||||
if($entry->isEncrypted() && !$entry->isIsCurrentlyDecrypted())
|
||||
if($entry->isEncrypted() && !$entry->isCurrentlyDecrypted())
|
||||
{
|
||||
return $entry->unlock($password);
|
||||
}
|
||||
|
@ -162,16 +162,7 @@
|
|||
$entries = [];
|
||||
foreach($this->Entries as $entry)
|
||||
{
|
||||
$entry_array = $entry->toArray($bytecode);
|
||||
|
||||
if($entry->getPassword() !== null && $entry->isEncrypted())
|
||||
{
|
||||
$entry_array['password'] = Crypto::encryptWithPassword(
|
||||
ZiProto::encode($entry_array['password']), $entry->getPassword()->__toString(), $bytecode
|
||||
);
|
||||
}
|
||||
|
||||
$entries[] = $entry_array;
|
||||
$entries[] = $entry->toArray($bytecode);;
|
||||
}
|
||||
|
||||
return [
|
||||
|
|
|
@ -87,12 +87,12 @@
|
|||
return false;
|
||||
|
||||
if($username == null)
|
||||
return $password == $this->Password->Password;
|
||||
return $password == $this->Password->getPassword();
|
||||
|
||||
if($password == null)
|
||||
return $username == $this->Password->Username;
|
||||
return $username == $this->Password->getUsername();
|
||||
|
||||
return $username == $this->Password->Username && $password == $this->Password->Password;
|
||||
return $username == $this->Password->getUsername() && $password == $this->Password->getPassword();
|
||||
|
||||
case AuthenticationType::AccessToken:
|
||||
if(!($this->Password instanceof AccessToken))
|
||||
|
@ -124,7 +124,7 @@
|
|||
* @return bool
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function isIsCurrentlyDecrypted(): bool
|
||||
public function isCurrentlyDecrypted(): bool
|
||||
{
|
||||
return $this->IsCurrentlyDecrypted;
|
||||
}
|
||||
|
@ -222,12 +222,16 @@
|
|||
*/
|
||||
public function toArray(bool $bytecode=false): array
|
||||
{
|
||||
if(!$this->Password)
|
||||
if($this->Password !== null)
|
||||
{
|
||||
if($this->Encrypted && $this->IsCurrentlyDecrypted)
|
||||
{
|
||||
$password = $this->encrypt();
|
||||
}
|
||||
elseif($this->Encrypted)
|
||||
{
|
||||
$password = $this->Password;
|
||||
}
|
||||
else
|
||||
{
|
||||
$password = $this->Password->toArray(true);
|
||||
|
@ -268,7 +272,8 @@
|
|||
}
|
||||
elseif(gettype($password) == 'array')
|
||||
{
|
||||
$self->Password = match (Functions::array_bc($data, 'authentication_type')) {
|
||||
$self->Password = match (Functions::array_bc($data, 'authentication_type'))
|
||||
{
|
||||
AuthenticationType::UsernamePassword => UsernamePassword::fromArray($password),
|
||||
AuthenticationType::AccessToken => AccessToken::fromArray($password)
|
||||
};
|
||||
|
|
|
@ -71,4 +71,12 @@
|
|||
{
|
||||
return $this->AccessToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $AccessToken
|
||||
*/
|
||||
public function setAccessToken(string $AccessToken): void
|
||||
{
|
||||
$this->AccessToken = $AccessToken;
|
||||
}
|
||||
}
|
|
@ -15,14 +15,14 @@
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
public $Username;
|
||||
private $Username;
|
||||
|
||||
/**
|
||||
* The entry's password
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $Password;
|
||||
private $Password;
|
||||
|
||||
/**
|
||||
* Returns an array representation of the object
|
||||
|
@ -90,4 +90,20 @@
|
|||
{
|
||||
return $this->Password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Username
|
||||
*/
|
||||
public function setUsername(string $Username): void
|
||||
{
|
||||
$this->Username = $Username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $Password
|
||||
*/
|
||||
public function setPassword(string $Password): void
|
||||
{
|
||||
$this->Password = $Password;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue