Initial Version
This commit is contained in:
78
shared/lib/Mail/Service/ServiceIdentityBasic.php
Normal file
78
shared/lib/Mail/Service/ServiceIdentityBasic.php
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPDX-FileCopyrightText: Sebastian Krupinski <krupinski01@gmail.com>
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
namespace KTXF\Mail\Service;
|
||||
|
||||
/**
|
||||
* Mail Service Basic Identity Implementation
|
||||
*
|
||||
* Username/password authentication credentials.
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*/
|
||||
class ServiceIdentityBasic implements IServiceIdentityBasic {
|
||||
|
||||
/**
|
||||
* @param string $username Login username
|
||||
* @param string $password Login password
|
||||
*/
|
||||
public function __construct(
|
||||
private string $username,
|
||||
private string $password,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Creates from array data
|
||||
*
|
||||
* @since 2025.05.01
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public static function fromArray(array $data): self {
|
||||
return new self(
|
||||
$data['username'] ?? '',
|
||||
$data['password'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getType(): string {
|
||||
return self::TYPE_BASIC;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getUsername(): string {
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getPassword(): string {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function jsonSerialize(): array {
|
||||
return [
|
||||
'type' => self::TYPE_BASIC,
|
||||
'username' => $this->username,
|
||||
// Password intentionally omitted from serialization for security
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user