Skip to content

Commit

Permalink
Merge pull request #6 from nextmcloud/nmc/raise-version-number
Browse files Browse the repository at this point in the history
raised max version number to 27
  • Loading branch information
tsdicloud authored Jan 29, 2024
2 parents 2489acd + 3d7c045 commit aa2831c
Show file tree
Hide file tree
Showing 18 changed files with 585 additions and 652 deletions.
62 changes: 0 additions & 62 deletions .github/workflows/lint-eslint.yml

This file was deleted.

2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<!-- NextMagentaCloud support must check functionality and increase max-version
with each major release change. See architecture documentation for details.
-->
<nextcloud min-version="21" max-version="25"/>
<nextcloud min-version="21" max-version="27"/>
</dependencies>
<background-jobs>
<job>OCA\NextMagentaCloudSlup\Registration\SlupCircuitControlJob</job>
Expand Down
23 changes: 11 additions & 12 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

namespace OCA\NextMagentaCloudSlup\AppInfo;

use OCP\ILogger;
use OCP\App\IAppManager;
use OCP\AppFramework\App;

use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;

use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\ILogger;

class Application extends App implements IBootstrap {
public const APP_ID = 'nmcslup';
Expand All @@ -31,12 +30,12 @@ public function register(IRegistrationContext $context): void {
* so we cannot use it for SLUP registration on boot
*/
public function boot(IBootContext $context): void {
$appMgr = $this->getContainer()->get(IAppManager::class);
$logger = $this->getContainer()->get(ILogger::class);
if ( !$appMgr->isInstalled('nmcprovisioning') ) {
$logger->error("NmcProvisioning app not installed or enabled, but NmcSlup depends on it!");
}

// TODO: may check also for minimal version of dependent app
}
$appMgr = $this->getContainer()->get(IAppManager::class);
$logger = $this->getContainer()->get(ILogger::class);
if (!$appMgr->isInstalled('nmcprovisioning')) {
$logger->error("NmcProvisioning app not installed or enabled, but NmcSlup depends on it!");
}

// TODO: may check also for minimal version of dependent app
}
}
76 changes: 38 additions & 38 deletions lib/Controller/SlupApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
namespace OCA\NextMagentaCloudSlup\Controller;

use OCA\NextMagentaCloudProvisioning\Rules\DisplaynameRules;
use OCP\ILogger;
use OCP\IRequest;
use OCA\NextMagentaCloudProvisioning\Rules\TariffRules;
use OCA\NextMagentaCloudProvisioning\Rules\UserAccountRules;

use OCA\NextMagentaCloudSlup\Registration\SlupRegistrationManager;
use OCA\NextMagentaCloudSlup\User\UserExistException;
use OCA\NextMagentaCloudSlup\Service\ForbiddenException;
use OCA\NextMagentaCloudSlup\Service\NotFoundException;
use OCA\NextMagentaCloudSlup\User\UserExistException;

use OCA\NextMagentaCloudProvisioning\Rules\TariffRules;
use OCA\NextMagentaCloudProvisioning\Rules\UserAccountRules;
use OCP\ILogger;
use OCP\IRequest;

class SlupApiController extends SoapApiController {
public const PROVIDER_PREFIX = 'Telekom';
Expand All @@ -49,8 +49,8 @@ class SlupApiController extends SoapApiController {
/** @var UserAccountService */
private $accountRules;

/** @var DisplaynameRules */
private $displaynameRules;
/** @var DisplaynameRules */
private $displaynameRules;

/**
* constructor of the controller
Expand All @@ -67,24 +67,24 @@ class SlupApiController extends SoapApiController {
* request should be cached, defaults to 1728000 seconds
*/
public function __construct($appName,
IRequest $request,
ILogger $logger,
SlupRegistrationManager $slupRegistrationMgr,
TariffRules $tariffRules,
DisplaynameRules $displaynameRules,
UserAccountRules $accountRules,
$corsMethods = 'POST',
$corsAllowedHeaders = 'Authorization, Content-Type, Accept',
$corsMaxAge = 1728000) {
IRequest $request,
ILogger $logger,
SlupRegistrationManager $slupRegistrationMgr,
TariffRules $tariffRules,
DisplaynameRules $displaynameRules,
UserAccountRules $accountRules,
$corsMethods = 'POST',
$corsAllowedHeaders = 'Authorization, Content-Type, Accept',
$corsMaxAge = 1728000) {
parent::__construct($appName, $request,
$wsdlPath = dirname(__FILE__) . "/slupClient.wsdl",
$logger,
$corsMethods,
$corsAllowedHeaders,
$corsMaxAge);
$wsdlPath = dirname(__FILE__) . "/slupClient.wsdl",
$logger,
$corsMethods,
$corsAllowedHeaders,
$corsMaxAge);
$this->slupRegistrationMgr = $slupRegistrationMgr;
$this->tariffRules = $tariffRules;
$this->displaynameRules = $displaynameRules;
$this->displaynameRules = $displaynameRules;
$this->accountRules = $accountRules;
}

Expand All @@ -110,7 +110,7 @@ public function getUserDetails($request, string $field, string $prefix = 'urn:te
}

$claims = new \stdClass();
$claims->changeTime = $request->changeTime;
$claims->changeTime = $request->changeTime;

foreach ($request->$field as $element) {
$claims->{$prefix . $element->name} = $element->val;
Expand Down Expand Up @@ -143,12 +143,12 @@ private function getDisplayName($newFieldsClaims, $oldFieldsClaims, string $pref
}

private function getEmail($newFieldsClaims, $oldFieldsClaims, string $prefix = 'urn:telekom.com:') {
$mainEmail = $this->getProperty($newFieldsClaims, $oldFieldsClaims, $prefix, 'mainEmail');
if ( $mainEmail != null ) {
return $mainEmail;
} else {
return $this->getProperty($newFieldsClaims, $oldFieldsClaims, $prefix, 'extMail');
}
$mainEmail = $this->getProperty($newFieldsClaims, $oldFieldsClaims, $prefix, 'mainEmail');
if ($mainEmail != null) {
return $mainEmail;
} else {
return $this->getProperty($newFieldsClaims, $oldFieldsClaims, $prefix, 'extMail');
}

}

Expand All @@ -162,15 +162,15 @@ private function getQuota($newFieldsClaims, string $prefix = 'urn:telekom.com:')

// ---------------- Supported SOAP functions ------------------------
public function SLUP($request) {
$this->logger->info("Counting message.");
$this->slupRegistrationMgr->incrementRecvCount();
$this->logger->info("Counting message.");
$this->slupRegistrationMgr->incrementRecvCount();

$this->logger->info("Checking token.");
$this->logger->info("Checking token.");
$token = strval($request->token);
if (!$this->slupRegistrationMgr->isValidToken($token)) {
$this->logger->error("SLUP invalid token on message.");
// save the currently send token to validate the follow-up disconnect
// message that must follow
$this->logger->error("SLUP invalid token on message.");
// save the currently send token to validate the follow-up disconnect
// message that must follow
$this->slupRegistrationMgr->setToken($token);
// signal invalid token
return array('returncode' => 'F003', 'detail' => 'invalid token');
Expand All @@ -196,7 +196,7 @@ public function SLUP($request) {
try {
$this->logger->info("User account modification start");
$evalResult = $this->accountRules->deriveAccountState($userName, $displayName, $email, $quota,
$newFieldsClaims, false, self::PROVIDER_PREFIX);
$newFieldsClaims, false, self::PROVIDER_PREFIX);
$this->logger->info(json_encode($evalResult));
if ($evalResult['changed']) {
return array('returncode' => '0010', 'detail' => $evalResult['reason']);
Expand All @@ -217,7 +217,7 @@ public function SLUP($request) {
public function SLUPConnect($request) {
$token = strval($request->token);
if (!$this->slupRegistrationMgr->isValidToken($token)) {
$this->logger->error("SLUP invalid token on connect.");
$this->logger->error("SLUP invalid token on connect.");
// with this, we get a disconnect next
return array('returncode' => 'F003', 'detail' => 'invalid token');
}
Expand All @@ -239,7 +239,7 @@ public function SLUPDisconnect($request) {
// we should not assume any circuit breaker state here as a parallel
// disconnect could happen while processing
if (!$this->slupRegistrationMgr->isValidToken($token)) {
$this->logger->error("SLUP invalid token on disconnect.");
$this->logger->error("SLUP invalid token on disconnect.");
// with this, we get a disconnect next
return array('returncode' => 'F003', 'detail' => 'invalid token');
} else {
Expand Down
36 changes: 18 additions & 18 deletions lib/Controller/SlupStatusController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@

namespace OCA\NextMagentaCloudSlup\Controller;

use OCP\ILogger;
use OCP\IRequest;

use OCA\NextMagentaCloudSlup\Registration\SlupRegistrationManager;
use OCP\AppFramework\ApiController;

use OCP\AppFramework\Http\DataResponse;
use OCP\ILogger;

use OCA\NextMagentaCloudSlup\Registration\SlupRegistrationManager;
use OCP\IRequest;

class SlupStatusController extends ApiController {

Expand All @@ -54,16 +54,16 @@ class SlupStatusController extends ApiController {
* request should be cached, defaults to 1728000 seconds
*/
public function __construct($appName,
IRequest $request,
ILogger $logger,
SlupRegistrationManager $slupRegistrationMgr,
$corsMethods = 'POST',
$corsAllowedHeaders = 'Authorization, Content-Type, Accept',
$corsMaxAge = 1728000) {
parent::__construct($appName, $request, $corsMethods,
$corsAllowedHeaders, $corsMaxAge);
$this->logger = $logger;
$this->slupRegistrationMgr = $slupRegistrationMgr;
IRequest $request,
ILogger $logger,
SlupRegistrationManager $slupRegistrationMgr,
$corsMethods = 'POST',
$corsAllowedHeaders = 'Authorization, Content-Type, Accept',
$corsMaxAge = 1728000) {
parent::__construct($appName, $request, $corsMethods,
$corsAllowedHeaders, $corsMaxAge);
$this->logger = $logger;
$this->slupRegistrationMgr = $slupRegistrationMgr;
}

/**
Expand All @@ -75,9 +75,9 @@ public function __construct($appName,
* @PublicPage
*/
public function status() {
return new DataResponse(array( 'circuit_state' => $this->slupRegistrationMgr->circuitState(),
'has_token' => $this->slupRegistrationMgr->hasToken() ? 'true' : 'false',
'num_msg_since_keepalive' => $this->slupRegistrationMgr->getRecvCount() ?? 0));
return new DataResponse(array( 'circuit_state' => $this->slupRegistrationMgr->circuitState(),
'has_token' => $this->slupRegistrationMgr->hasToken() ? 'true' : 'false',
'num_msg_since_keepalive' => $this->slupRegistrationMgr->getRecvCount() ?? 0));

}
}
}
22 changes: 11 additions & 11 deletions lib/Controller/SoapApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
use OCP\AppFramework\ApiController;
use OCP\AppFramework\Http\Response;

use OCP\IRequest;
use OCP\ILogger;
use OCP\IRequest;

/**
* Base class to inherit a Soap API handling controller from
Expand Down Expand Up @@ -62,14 +62,14 @@ abstract class SoapApiController extends ApiController {
* @since 8.1.0
*/
public function __construct($appName,
IRequest $request,
string $wsdlPath,
ILogger $logger,
$corsMethods = 'POST',
$corsAllowedHeaders = 'Authorization, Content-Type, Accept',
$corsMaxAge = 1728000) {
IRequest $request,
string $wsdlPath,
ILogger $logger,
$corsMethods = 'POST',
$corsAllowedHeaders = 'Authorization, Content-Type, Accept',
$corsMaxAge = 1728000) {
parent::__construct($appName, $request, $corsMethods,
$corsAllowedHeaders, $corsMaxAge);
$corsAllowedHeaders, $corsMaxAge);
// some SOAP message use application/soap+xml as content type
$this->registerResponder('soap+xml', function ($message) {
return $this->buildSoapResponse($message);
Expand Down Expand Up @@ -109,9 +109,9 @@ public function getWsdlPath() {
}

protected function soapCall() {
libxml_set_external_entity_loader(static function ($public, $system, $context) {
return $system;
});
libxml_set_external_entity_loader(static function ($public, $system, $context) {
return $system;
});
$soapServer = new \SoapServer($this->wsdlPath);
ini_set("soap.wsdl_cache_enabled", "0");
$soapServer->setObject($this);
Expand Down
Loading

0 comments on commit aa2831c

Please sign in to comment.