66 lines
1.8 KiB
PHP
66 lines
1.8 KiB
PHP
<?php
|
|
//////////////////////
|
|
// TokenManager.php //
|
|
// DigiErbe Tresor //
|
|
//////////////////////
|
|
|
|
class TokenManager {
|
|
/*
|
|
* VARIABLES
|
|
*/
|
|
private string $storagePath; // Subdirectory under Tresor's /private directory to use to store all the token information
|
|
private int $expireDays; // number of dates for a token to expire
|
|
private int $maxDownloads; // maximum number of downloads before a token becomes invalid
|
|
private int $tokenLength; // number of random bytes to use to create the token name
|
|
private string $allowedUser; // the user allowed to access the token
|
|
|
|
/*
|
|
* PUBLIC FUNCTIONS
|
|
*/
|
|
|
|
// initialize the token instance in PHP
|
|
public __contruct(
|
|
string $storagePath = '/tokens',
|
|
int $exireDays = 1,
|
|
int $maxDownloads = 1,
|
|
int $tokenLength = 32
|
|
) {
|
|
$this->storagePath = $storagePath;
|
|
$this->$expireDays = $expireDays;
|
|
$this->$maxDownloads = $maxDownloads;
|
|
$this->$tokenLength = $tokenLength;
|
|
}
|
|
|
|
// generate a new token and save it to the file system
|
|
public generateToken(
|
|
string $filename,
|
|
string $ownerName,
|
|
string $allowedUser
|
|
) {
|
|
return (['error'=>'no token generated', 'status'=>'500']);
|
|
}
|
|
|
|
// retrieve/download the key file connected with the token
|
|
public retrieveToken(string $tokenName) {
|
|
|
|
}
|
|
|
|
// check a token and remove it when it's expired
|
|
public cleanupToken(string $tokenName) {
|
|
|
|
}
|
|
|
|
/*
|
|
* PRIVATE FUNCTIONS
|
|
*/
|
|
|
|
// check whether a token is still valid and accessible by the user requesting it
|
|
private validateToken($tokenName) {
|
|
return null;
|
|
}
|
|
|
|
private getDownloadFileInfo ($tokenName) {
|
|
$fileInfo = [];
|
|
return null;
|
|
}
|
|
} |