@@ -20,72 +20,72 @@ |
||
| 20 | 20 | use Psr\Log\LoggerInterface; |
| 21 | 21 | |
| 22 | 22 | class Capabilities implements ICapability, IInitialStateExcludedCapability { |
| 23 | - public const API_VERSION = '1.1'; // informative, real version. |
|
| 23 | + public const API_VERSION = '1.1'; // informative, real version. |
|
| 24 | 24 | |
| 25 | - public function __construct( |
|
| 26 | - private IURLGenerator $urlGenerator, |
|
| 27 | - private IAppConfig $appConfig, |
|
| 28 | - private IOCMProvider $provider, |
|
| 29 | - private readonly OCMSignatoryManager $ocmSignatoryManager, |
|
| 30 | - private readonly LoggerInterface $logger, |
|
| 31 | - ) { |
|
| 32 | - } |
|
| 25 | + public function __construct( |
|
| 26 | + private IURLGenerator $urlGenerator, |
|
| 27 | + private IAppConfig $appConfig, |
|
| 28 | + private IOCMProvider $provider, |
|
| 29 | + private readonly OCMSignatoryManager $ocmSignatoryManager, |
|
| 30 | + private readonly LoggerInterface $logger, |
|
| 31 | + ) { |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Function an app uses to return the capabilities |
|
| 36 | - * |
|
| 37 | - * @return array{ |
|
| 38 | - * ocm: array{ |
|
| 39 | - * apiVersion: '1.0-proposal1', |
|
| 40 | - * enabled: bool, |
|
| 41 | - * endPoint: string, |
|
| 42 | - * publicKey?: array{ |
|
| 43 | - * keyId: string, |
|
| 44 | - * publicKeyPem: string, |
|
| 45 | - * }, |
|
| 46 | - * resourceTypes: list<array{ |
|
| 47 | - * name: string, |
|
| 48 | - * shareTypes: list<string>, |
|
| 49 | - * protocols: array<string, string> |
|
| 50 | - * }>, |
|
| 51 | - * version: string |
|
| 52 | - * } |
|
| 53 | - * } |
|
| 54 | - * @throws OCMArgumentException |
|
| 55 | - */ |
|
| 56 | - public function getCapabilities() { |
|
| 57 | - $url = $this->urlGenerator->linkToRouteAbsolute('cloud_federation_api.requesthandlercontroller.addShare'); |
|
| 58 | - $pos = strrpos($url, '/'); |
|
| 59 | - if ($pos === false) { |
|
| 60 | - throw new OCMArgumentException('generated route should contain a slash character'); |
|
| 61 | - } |
|
| 34 | + /** |
|
| 35 | + * Function an app uses to return the capabilities |
|
| 36 | + * |
|
| 37 | + * @return array{ |
|
| 38 | + * ocm: array{ |
|
| 39 | + * apiVersion: '1.0-proposal1', |
|
| 40 | + * enabled: bool, |
|
| 41 | + * endPoint: string, |
|
| 42 | + * publicKey?: array{ |
|
| 43 | + * keyId: string, |
|
| 44 | + * publicKeyPem: string, |
|
| 45 | + * }, |
|
| 46 | + * resourceTypes: list<array{ |
|
| 47 | + * name: string, |
|
| 48 | + * shareTypes: list<string>, |
|
| 49 | + * protocols: array<string, string> |
|
| 50 | + * }>, |
|
| 51 | + * version: string |
|
| 52 | + * } |
|
| 53 | + * } |
|
| 54 | + * @throws OCMArgumentException |
|
| 55 | + */ |
|
| 56 | + public function getCapabilities() { |
|
| 57 | + $url = $this->urlGenerator->linkToRouteAbsolute('cloud_federation_api.requesthandlercontroller.addShare'); |
|
| 58 | + $pos = strrpos($url, '/'); |
|
| 59 | + if ($pos === false) { |
|
| 60 | + throw new OCMArgumentException('generated route should contain a slash character'); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - $this->provider->setEnabled(true); |
|
| 64 | - $this->provider->setApiVersion(self::API_VERSION); |
|
| 65 | - $this->provider->setEndPoint(substr($url, 0, $pos)); |
|
| 63 | + $this->provider->setEnabled(true); |
|
| 64 | + $this->provider->setApiVersion(self::API_VERSION); |
|
| 65 | + $this->provider->setEndPoint(substr($url, 0, $pos)); |
|
| 66 | 66 | |
| 67 | - $resource = $this->provider->createNewResourceType(); |
|
| 68 | - $resource->setName('file') |
|
| 69 | - ->setShareTypes(['user', 'group']) |
|
| 70 | - ->setProtocols(['webdav' => '/public.php/webdav/']); |
|
| 67 | + $resource = $this->provider->createNewResourceType(); |
|
| 68 | + $resource->setName('file') |
|
| 69 | + ->setShareTypes(['user', 'group']) |
|
| 70 | + ->setProtocols(['webdav' => '/public.php/webdav/']); |
|
| 71 | 71 | |
| 72 | - $this->provider->addResourceType($resource); |
|
| 72 | + $this->provider->addResourceType($resource); |
|
| 73 | 73 | |
| 74 | - // Adding a public key to the ocm discovery |
|
| 75 | - try { |
|
| 76 | - if (!$this->appConfig->getValueBool('core', OCMSignatoryManager::APPCONFIG_SIGN_DISABLED, lazy: true)) { |
|
| 77 | - /** |
|
| 78 | - * @experimental 31.0.0 |
|
| 79 | - * @psalm-suppress UndefinedInterfaceMethod |
|
| 80 | - */ |
|
| 81 | - $this->provider->setSignatory($this->ocmSignatoryManager->getLocalSignatory()); |
|
| 82 | - } else { |
|
| 83 | - $this->logger->debug('ocm public key feature disabled'); |
|
| 84 | - } |
|
| 85 | - } catch (SignatoryException|IdentityNotFoundException $e) { |
|
| 86 | - $this->logger->warning('cannot generate local signatory', ['exception' => $e]); |
|
| 87 | - } |
|
| 74 | + // Adding a public key to the ocm discovery |
|
| 75 | + try { |
|
| 76 | + if (!$this->appConfig->getValueBool('core', OCMSignatoryManager::APPCONFIG_SIGN_DISABLED, lazy: true)) { |
|
| 77 | + /** |
|
| 78 | + * @experimental 31.0.0 |
|
| 79 | + * @psalm-suppress UndefinedInterfaceMethod |
|
| 80 | + */ |
|
| 81 | + $this->provider->setSignatory($this->ocmSignatoryManager->getLocalSignatory()); |
|
| 82 | + } else { |
|
| 83 | + $this->logger->debug('ocm public key feature disabled'); |
|
| 84 | + } |
|
| 85 | + } catch (SignatoryException|IdentityNotFoundException $e) { |
|
| 86 | + $this->logger->warning('cannot generate local signatory', ['exception' => $e]); |
|
| 87 | + } |
|
| 88 | 88 | |
| 89 | - return ['ocm' => $this->provider->jsonSerialize()]; |
|
| 90 | - } |
|
| 89 | + return ['ocm' => $this->provider->jsonSerialize()]; |
|
| 90 | + } |
|
| 91 | 91 | } |