Client
in package
Create a new Kastela Client instance for communicating with the server.
Require server information and return client instance.
Example
$kastelaClient = new Client("server.url", "credentials/ca.crt", "credentials/client.crt", "credentials/client.key", );
Table of Contents
Properties
- $kastelaUrl : mixed
Methods
- __construct() : void
- cryptoDecrypt() : mixed
- cryptoEncrypt() : mixed
- cryptoEqual() : mixed
- cryptoHMAC() : mixed
- cryptoSign() : mixed
- cryptoVerify() : mixed
- privacyProxyRequest() : mixed
- Proxying Request.
- protectionCount() : int
- Count protection data
- protectionFetch() : array<string|int, mixed>
- Fetch protection data
- protectionOpen() : array<int, array<int, mixed>>
- Decrypt data protection by protection data ids.
- protectionSeal() : void
- Encrypt data protection by protection data ids, which can be used $after storing data or updating data.
- secureProtectionCommit() : void
- Commit secure protection.
- secureProtectionInit() : array<string|int, mixed>
- Initialize secure protection.
- secureVaultInit() : array<string|int, mixed>
- Initialize secure vault.
- vaultCount() : array<string|int, string>
- Count vault data
- vaultDelete() : void
- Remove vault data by vault $token.
- vaultFetch() : array<int, string>
- Search vault data by indexed column.
- vaultGet() : array<int, array<int, mixed>>
- Get batch vault data by vault $token ids.
- vaultStore() : array<int, array<int, string>>
- Store batch vault data on the server.
- vaultUpdate() : void
- Update vault data by vault $token.
Properties
$kastelaUrl
public
mixed
$kastelaUrl
Methods
__construct()
public
__construct(string $kastelaUrl, string $caCertPath, string $clientCertPath, string $clientKeyPath) : void
Parameters
- $kastelaUrl : string
-
Kastela server url
- $caCertPath : string
-
Kastela ca certificate path
- $clientCertPath : string
-
Kastela client certificate path
- $clientKeyPath : string
-
kastela client key path
cryptoDecrypt()
public
cryptoDecrypt(array<int, string> $input) : mixed
Parameters
- $input : array<int, string>
cryptoEncrypt()
public
cryptoEncrypt(array<string|int, mixed> $input) : mixed
Parameters
- $input : array<string|int, mixed>
cryptoEqual()
public
cryptoEqual(array<int, CryptoEqualInput> $input) : mixed
Parameters
- $input : array<int, CryptoEqualInput>
cryptoHMAC()
public
cryptoHMAC(array<int, CryptoHMACInput> $input) : mixed
Parameters
- $input : array<int, CryptoHMACInput>
cryptoSign()
public
cryptoSign(array<int, CryptoSignInput> $input) : mixed
Parameters
- $input : array<int, CryptoSignInput>
cryptoVerify()
public
cryptoVerify(array<int, CryptoVerifyInput> $input) : mixed
Parameters
- $input : array<int, CryptoVerifyInput>
privacyProxyRequest()
Proxying Request.
public
privacyProxyRequest(PrivacyProxyRequestType $type, string $url, PrivacyProxyRequestMethod $method, array<string|int, mixed> $common, array<string|int, mixed> $options) : mixed
Parameters
- $type : PrivacyProxyRequestType
-
request body type "json"|"xml"
- $url : string
-
request url
- $method : PrivacyProxyRequestMethod
-
request method "get"|"post"
- $common : array<string|int, mixed>
-
needed information for protection and vault. $common = [ 'protections' => ['_column'=>'protectionId'] protections object list. Define column with prefix as key and protectionId as $value. 'vaults' => ['_column'=>['vaultId', 'selectedVaultColumn']]] vaults object list. Define column with prefix as key and array with id as first index and vault column as second index. ]
- $options : array<string|int, mixed>
-
$options = [ 'headers' => (array) {object} request headers, use "" prefix for encrypted column key and data id/token as $value. 'params' => (array) {object} request parameters, use "" prefix for encrypted column key and data id/token as $value. 'body' => (array) {object} request body, use "" prefix for encrypted column key and data id/token as $value. 'query' => (array) {object} request query, use "" prefix for encrypted column key and data id/token as $value. 'rootTag' => (string) root tag, required for xml type$res = $kastelaClient->privacyProxyRequest($data["type"], $data["url"], $data["method"], $data["common"], $data["options"]); ]
Example
$res = $kastelaClient->privacyProxyRequest($data["type"], $data["url"], $data["method"], $data["common"], $data["options"]);
protectionCount()
Count protection data
public
protectionCount(ProtectionCountInput $input) : int
Parameters
- $input : ProtectionCountInput
Return values
int —count of data
Example
Example
$result = $kastelaClient->protectionCount(new ProtectionCountInput("your-protection-id", "foo");
protectionFetch()
Fetch protection data
public
protectionFetch(ProtectionFetchInput $input) : array<string|int, mixed>
Parameters
- $input : ProtectionFetchInput
Return values
array<string|int, mixed> —array of primary keys
Example
$result = $kastelaClient->protectionFetch(new ProtectionFetchInput("your-protection-id", "foo");
protectionOpen()
Decrypt data protection by protection data ids.
public
protectionOpen(array<int, ProtectionOpenInput> $input) : array<int, array<int, mixed>>
Parameters
- $input : array<int, ProtectionOpenInput>
Return values
array<int, array<int, mixed>> —$array of decrypted data refers to ids
Example
// decrypt data with id 1,2,3,4,5
$data = $kastelaClient->protection_open(new ProtectionOpenInput("id", ["token1", "token2"])]);
protectionSeal()
Encrypt data protection by protection data ids, which can be used $after storing data or updating data.
public
protectionSeal(array<int, ProtectionSealInput> $input) : void
Parameters
- $input : array<int, ProtectionSealInput>
Return values
void —Example
// protect data with id 1,2,3,4,5
kastelaClient->protection_seal([new ProtectionSealInput("id", ["pKey1", "pKey2"])]);
secureProtectionCommit()
Commit secure protection.
public
secureProtectionCommit(string $credential) : void
Parameters
- $credential : string
Return values
void —Example
// commit secure protection
client.secureProtectionCommit("yourCredential")
secureProtectionInit()
Initialize secure protection.
public
secureProtectionInit(SecureOperation $operation, array<string|int, mixed> $protectionIds, int $ttl) : array<string|int, mixed>
Parameters
- $operation : SecureOperation
-
operation secure protection operation mode
- $protectionIds : array<string|int, mixed>
-
protectionIds array of protection id
- $ttl : int
-
ttl time to live in minutes
Return values
array<string|int, mixed> —secure protection credential
Example
// begin secure protection
client.secureProtectionInit(["yourProtectionId"], 5)
secureVaultInit()
Initialize secure vault.
public
secureVaultInit(SecureOperation $operation, array<string|int, mixed> $vaultIds, int $ttl) : array<string|int, mixed>
Parameters
- $operation : SecureOperation
-
operation secure vault operation mode
- $vaultIds : array<string|int, mixed>
-
vaultIds array of vault id
- $ttl : int
-
ttl time to live in minutes
Return values
array<string|int, mixed> —secure vault credential
Example
// begin secure vault
client.secureVaultInit(["yourVaultId"], 5)
vaultCount()
Count vault data
public
vaultCount(VaultCountInput $input) : array<string|int, string>
Parameters
- $input : VaultCountInput
Return values
array<string|int, string> —Example
$result = $kastelaClient->vaultCount(new VaultCountInput("your-vault-id", "foo"));
vaultDelete()
Remove vault data by vault $token.
public
vaultDelete(array<int, VaultDeleteInput> $input) : void
Parameters
- $input : array<int, VaultDeleteInput>
Return values
void —Example
$kastelaClient->vault_delete(new VaultDeleteInput("id", ["token1", "token2"]));
vaultFetch()
Search vault data by indexed column.
public
vaultFetch(VaultFetchInput $input) : array<int, string>
Parameters
- $input : VaultFetchInput
Return values
array<int, string> —Example
// fetch vault data with indexed colum $value "jhon doe", return the list of vault $token/id
$tokens = $kastelaClient->vault_fetch(new VaultFetchInput($data["vault_id"], $data["search"], $data["size"] | null, $data["after"] | null));
vaultGet()
Get batch vault data by vault $token ids.
public
vaultGet(array<int, VaultGetInput> $input) : array<int, array<int, mixed>>
Parameters
- $input : array<int, VaultGetInput>
Return values
array<int, array<int, mixed>> —Example
// get vault data
$secrets = $kastelaClient->vault_get(new VaultGetInput("id", ["tokens1", "tokens2"]));
vaultStore()
Store batch vault data on the server.
public
vaultStore(array<int, VaultStoreInput> $input) : array<int, array<int, string>>
Parameters
- $input : array<int, VaultStoreInput>
Return values
array<int, array<int, string>> —of vault $token
Example
$tokens = $kastelaClient->vault_store([new VaultStoreInput("id", ["values1", "values2"])])
vaultUpdate()
Update vault data by vault $token.
public
vaultUpdate(array<int, VaultUpdateInput> $input) : void
Parameters
- $input : array<int, VaultUpdateInput>
Return values
void —Example
$kastelaClient->vault_update([new VaultUpdateInput("id", [new VaultUpdateInputValues("token", ["data"=>"yourUpdateData"])])]);