Imported code from old repository

This commit is contained in:
2022-11-22 15:46:36 +01:00
parent 976fdc0199
commit 77cf9e05f1
91 changed files with 18969 additions and 2 deletions
+36
View File
@@ -0,0 +1,36 @@
<?php
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
namespace CloudObjects\PhpMAE;
use Cilex\Application;
use ML\IRI\IRI;
use CloudObjects\SDK\AccountGateway\AccountContext;
class CredentialManager {
private static $context;
private static function getFilename() {
return getenv('HOME').DIRECTORY_SEPARATOR.'.cloudobjects';
}
public static function isConfigured() {
return file_exists(self::getFilename());
}
public static function getAccountContext() {
if (!self::$context) {
if (file_exists(self::getFilename())) {
$data = json_decode(file_get_contents(self::getFilename()), true);
if (isset($data['aauid']) && isset($data['access_token']))
self::$context = new AccountContext(new IRI('aauid:'.$data['aauid']), $data['access_token']);
}
}
return self::$context;
}
}