JSON -Token für .ini -Datei
private $config;
private static $instance;
private static function getInstance() {
if(is_null(self::$instance)){
self::$instance = new DSConfig();
}
return self::$instance;
}
public function __construct() {
date_default_timezone_set('UTC');
$clientId = getenv("DS_CLIENT_ID");
if (!is_null($clientId) and !empty($clientId)) {
$this->config["DS_CLIENT_ID"] = $clientId;
$this->config["DS_AUTH_SERVER"] = getenv("DS_AUTH_SERVER");
$this->config["DS_IMPERSONATED_USER_GUID"] = getenv("DS_IMPERSONATED_USER_GUID");
$this->config["DS_TARGET_ACCOUNT_ID"] = getenv("DS_TARGET_ACCOUNT_ID");
$this->config["SIGNER_EMAIL"] = getenv("SIGNER_EMAIL");
$this->config["SIGNER_NAME"] = getenv("SIGNER_NAME");
$this->config["CC_EMAIL"] = getenv("CC_EMAIL");
$this->config["CC_NAME"] = getenv("CC_NAME");
$this->config["DS_PRIVATE_KEY"] = getenv("DS_PRIVATE_KEY");
} else {
$this->config = parse_ini_file('ds_config.ini', true);
}
}
private function _auth_server() {
return $this->config["DS_AUTH_SERVER"];
}
public static function auth_server() {
return self::getInstance()->_auth_server();
}
private function _client_id() {
return $this->config["DS_CLIENT_ID"];
}
public static function client_id() {
return self::getInstance()->_client_id();
}
private function _impersonated_user_guid() {
return $this->config["DS_IMPERSONATED_USER_GUID"];
}
public static function impersonated_user_guid() {
return self::getInstance()->_impersonated_user_guid();
}
private function _target_account_id() {
return $this->config["DS_TARGET_ACCOUNT_ID"];
}
public static function target_account_id(){
return self::getInstance()->_target_account_id();
}
private function _signer_email() {
return $this->config["SIGNER_EMAIL"];
}
public static function signer_email(){
return self::getInstance()->_signer_email();
}
private function _signer_name(){
return $this->config["SIGNER_NAME"];
}
public static function signer_name(){
return self::getInstance()->_signer_name();
}
private function _cc_email() {
return $this->config["CC_EMAIL"];
}
public static function cc_email(){
return self::getInstance()->_cc_email();
}
private function _cc_name(){
return $this->config["CC_NAME"];
}
public static function cc_name(){
return self::getInstance()->_cc_name();
}
private function _private_key() {
return $this->config["DS_PRIVATE_KEY"];
}
public static function private_key(){
return self::getInstance()->_private_key();
}
public static function aud() {
$auth_server = self::getInstance()->_auth_server();
if (strpos($auth_server, 'https://') !== false) {
$aud = substr($auth_server, 8);
} else { # assuming http://blah
$aud = substr($auth_server, 7);
}
return $aud;
}
public static function api() {
return "restapi/v2";
}
public static function jwt_scope() {
return "signature";
}
Disturbed Dugong