forked from ecotoneframework/ecotone-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChannelProtectionConfiguration.php
More file actions
48 lines (39 loc) · 1.23 KB
/
ChannelProtectionConfiguration.php
File metadata and controls
48 lines (39 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Ecotone\DataProtection\Configuration;
/**
* licence Enterprise
*/
class ChannelProtectionConfiguration
{
private function __construct(
private string $channelName,
private ?string $encryptionKey,
private bool $isPayloadSensitive,
private array $sensitiveHeaders,
) {
}
public static function create(string $channelName, ?string $encryptionKey = null, $isPayloadSensitive = true, array $sensitiveHeaders = []): self
{
return new self($channelName, $encryptionKey, $isPayloadSensitive, $sensitiveHeaders);
}
public function channelName(): string
{
return $this->channelName;
}
public function obfuscatorConfig(): ObfuscatorConfig
{
return new ObfuscatorConfig($this->encryptionKey, $this->isPayloadSensitive, $this->sensitiveHeaders);
}
public function withSensitivePayload(bool $isPayloadSensitive): self
{
$config = clone $this;
$config->isPayloadSensitive = $isPayloadSensitive;
return $config;
}
public function withSensitiveHeader(string $sensitiveHeader): self
{
$config = clone $this;
$config->sensitiveHeaders[] = $sensitiveHeader;
return $config;
}
}