| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * @author Viktar Dubiniuk <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @copyright Copyright (c) 2018, ownCloud GmbH | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @license AGPL-3.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * This code is free software: you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * it under the terms of the GNU Affero General Public License, version 3, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * as published by the Free Software Foundation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  * This program is distributed in the hope that it will be useful, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * GNU Affero General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * You should have received a copy of the GNU Affero General Public License, version 3, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * along with this program.  If not, see <http://www.gnu.org/licenses/> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | namespace OCA\FederatedFileSharing\Controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use OCA\FederatedFileSharing\Address; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use OCA\FederatedFileSharing\AddressHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use OCA\FederatedFileSharing\Middleware\OcmMiddleware; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use OCA\FederatedFileSharing\Ocm\Exception\BadRequestException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use OCA\FederatedFileSharing\Ocm\Exception\NotImplementedException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use OCA\FederatedFileSharing\Ocm\Notification\FileNotification; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | use OCP\AppFramework\Http\JSONResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  | use OCA\FederatedFileSharing\FedShareManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  | use OCA\FederatedFileSharing\Ocm\Exception\OcmException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | use OCP\AppFramework\Controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | use OCP\AppFramework\Http; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | use OCP\ILogger; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | use OCP\IRequest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | use OCP\IURLGenerator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | use OCP\IUserManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  * Class OcmController | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  * @package OCA\FederatedFileSharing\Controller | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | class OcmController extends Controller { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 	const API_VERSION = '1.0-proposal1'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 	 * @var OcmMiddleware | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 	private $ocmMiddleware; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 	 * @var IURLGenerator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 	protected $urlGenerator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 	 * @var IUserManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 	protected $userManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 	 * @var AddressHandler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 	protected $addressHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 	 * @var FedShareManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 	protected $fedShareManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 	 * @var ILogger | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 	protected $logger; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 	 * OcmController constructor. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 	 * @param string $appName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 	 * @param IRequest $request | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 	 * @param OcmMiddleware $ocmMiddleware | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 	 * @param IURLGenerator $urlGenerator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 	 * @param IUserManager $userManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 	 * @param AddressHandler $addressHandler | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 	 * @param FedShareManager $fedShareManager | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 	 * @param ILogger $logger | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 90 |  | View Code Duplication | 	public function __construct($appName, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 									IRequest $request, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 									OcmMiddleware $ocmMiddleware, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 									IURLGenerator $urlGenerator, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 									IUserManager $userManager, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 									AddressHandler $addressHandler, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 									FedShareManager $fedShareManager, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 									ILogger $logger | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  | 	) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 		parent::__construct($appName, $request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 		$this->ocmMiddleware = $ocmMiddleware; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 		$this->urlGenerator = $urlGenerator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 		$this->userManager = $userManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 		$this->addressHandler = $addressHandler; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  | 		$this->fedShareManager = $fedShareManager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 		$this->logger = $logger; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 	 * @NoCSRFRequired | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 	 * @PublicPage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 	 * EndPoint discovery | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 	 * Responds to /ocm-provider/ requests | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 	public function discovery() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 		$endPoint = $this->urlGenerator->linkToRouteAbsolute( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 			"{$this->appName}.ocm.index" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 		return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 			'enabled' => true, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 			'apiVersion' => self::API_VERSION, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 			'endPoint' => \rtrim($endPoint, '/'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 			'shareTypes' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 				[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 					'name' => FileNotification::RESOURCE_TYPE_FILE, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 					'protocols' => $this->getProtocols() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 				] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 			] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 		]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 	 * @NoCSRFRequired | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	 * @PublicPage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	 * @param string $shareWith identifier of the user or group | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 	 * 							to share the resource with | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	 * @param string $name name of the shared resource | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 	 * @param string $description share description (optional) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 	 * @param string $providerId Identifier of the resource at the provider side | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 	 * @param string $owner identifier of the user that owns the resource | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 	 * @param string $ownerDisplayName display name of the owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 	 * @param string $sender Provider specific identifier of the user that wants | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 	 *							to share the resource | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 	 * @param string $senderDisplayName Display name of the user that wants | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 	 * 									to share the resource | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 	 * @param string $shareType Share type ('user' is supported atm) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 	 * @param string $resourceType only 'file' is supported atm | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 	 * @param array $protocol | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  | 	 * 		[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 	 * 			'name' => (string) protocol name. Only 'webdav' is supported atm, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | 	 * 			'options' => [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 	 * 				protocol specific options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 	 * 				only `webdav` options are supported atm | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  | 	 * 				e.g. `uri`,	`access_token`, `password`, `permissions` etc. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 	 * 				For backward compatibility the webdav protocol will use | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 	 * 				the 'sharedSecret" as username and password | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 	 * 			] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  | 	 * @return JSONResponse | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 165 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 166 |  |  | 	public function createShare($shareWith, | 
            
                                                                        
                            
            
                                    
            
            
                | 167 |  |  | 								$name, | 
            
                                                                        
                            
            
                                    
            
            
                | 168 |  |  | 								$description, | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 169 |  |  | 								$providerId, | 
            
                                                                        
                            
            
                                    
            
            
                | 170 |  |  | 								$owner, | 
            
                                                                        
                            
            
                                    
            
            
                | 171 |  |  | 								$ownerDisplayName, | 
            
                                                                        
                            
            
                                    
            
            
                | 172 |  |  | 								$sender, | 
            
                                                                        
                            
            
                                    
            
            
                | 173 |  |  | 								$senderDisplayName, | 
            
                                                                        
                            
            
                                    
            
            
                | 174 |  |  | 								$shareType, | 
            
                                                                        
                            
            
                                    
            
            
                | 175 |  |  | 								$resourceType, | 
            
                                                                        
                            
            
                                    
            
            
                | 176 |  |  | 								$protocol | 
            
                                                                        
                            
            
                                    
            
            
                | 177 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 178 |  |  | 	) { | 
            
                                                                        
                            
            
                                    
            
            
                | 179 |  |  | 		try { | 
            
                                                                        
                            
            
                                    
            
            
                | 180 |  |  | 			$this->ocmMiddleware->assertIncomingSharingEnabled(); | 
            
                                                                        
                            
            
                                    
            
            
                | 181 |  |  | 			$this->ocmMiddleware->assertNotNull( | 
            
                                                                        
                            
            
                                    
            
            
                | 182 |  |  | 				[ | 
            
                                                                        
                            
            
                                    
            
            
                | 183 |  |  | 					'shareWith' => $shareWith, | 
            
                                                                        
                            
            
                                    
            
            
                | 184 |  |  | 					'name' => $name, | 
            
                                                                        
                            
            
                                    
            
            
                | 185 |  |  | 					'providerId' => $providerId, | 
            
                                                                        
                            
            
                                    
            
            
                | 186 |  |  | 					'owner' => $owner, | 
            
                                                                        
                            
            
                                    
            
            
                | 187 |  |  | 					'shareType' => $shareType, | 
            
                                                                        
                            
            
                                    
            
            
                | 188 |  |  | 					'resourceType' => $resourceType | 
            
                                                                        
                            
            
                                    
            
            
                | 189 |  |  | 				] | 
            
                                                                        
                            
            
                                    
            
            
                | 190 |  |  | 			); | 
            
                                                                        
                            
            
                                    
            
            
                | 191 |  |  | 			if (!\is_array($protocol) | 
            
                                                                        
                            
            
                                    
            
            
                | 192 |  |  | 				|| !isset($protocol['name']) | 
            
                                                                        
                            
            
                                    
            
            
                | 193 |  |  | 				|| !isset($protocol['options']) | 
            
                                                                        
                            
            
                                    
            
            
                | 194 |  |  | 				|| !\is_array($protocol['options']) | 
            
                                                                        
                            
            
                                    
            
            
                | 195 |  |  | 				|| !isset($protocol['options']['sharedSecret']) | 
            
                                                                        
                            
            
                                    
            
            
                | 196 |  |  | 			) { | 
            
                                                                        
                            
            
                                    
            
            
                | 197 |  |  | 				throw new BadRequestException( | 
            
                                                                        
                            
            
                                    
            
            
                | 198 |  |  | 					'server can not add remote share, missing parameter' | 
            
                                                                        
                            
            
                                    
            
            
                | 199 |  |  | 				); | 
            
                                                                        
                            
            
                                    
            
            
                | 200 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 201 |  |  | 			if (!\OCP\Util::isValidFileName($name)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 202 |  |  | 				throw new BadRequestException( | 
            
                                                                        
                            
            
                                    
            
            
                | 203 |  |  | 					'The mountpoint name contains invalid characters.' | 
            
                                                                        
                            
            
                                    
            
            
                | 204 |  |  | 				); | 
            
                                                                        
                            
            
                                    
            
            
                | 205 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 207 |  |  | 			if ($this->isSupportedProtocol($protocol['name']) === false) { | 
            
                                                                        
                            
            
                                    
            
            
                | 208 |  |  | 				throw new NotImplementedException( | 
            
                                                                        
                            
            
                                    
            
            
                | 209 |  |  | 					"Protocol {$protocol['name']} is not supported" | 
            
                                                                        
                            
            
                                    
            
            
                | 210 |  |  | 				); | 
            
                                                                        
                            
            
                                    
            
            
                | 211 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 213 |  |  | 			if ($this->isSupportedShareType($shareType) === false) { | 
            
                                                                        
                            
            
                                    
            
            
                | 214 |  |  | 				throw new NotImplementedException( | 
            
                                                                        
                            
            
                                    
            
            
                | 215 |  |  | 					"ShareType {$shareType} is not supported" | 
            
                                                                        
                            
            
                                    
            
            
                | 216 |  |  | 				); | 
            
                                                                        
                            
            
                                    
            
            
                | 217 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 218 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 219 |  |  | 			if ($this->isSupportedResourceType($resourceType) === false) { | 
            
                                                                        
                            
            
                                    
            
            
                | 220 |  |  | 				throw new NotImplementedException( | 
            
                                                                        
                            
            
                                    
            
            
                | 221 |  |  | 					"ResourceType {$resourceType} is not supported" | 
            
                                                                        
                            
            
                                    
            
            
                | 222 |  |  | 				); | 
            
                                                                        
                            
            
                                    
            
            
                | 223 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 224 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 225 |  |  | 			$shareWithAddress = new Address($shareWith); | 
            
                                                                        
                            
            
                                    
            
            
                | 226 |  |  | 			$localShareWith = $shareWithAddress->toLocalUid(); | 
            
                                                                        
                            
            
                                    
            
            
                | 227 |  |  | 			if (!$this->userManager->userExists($localShareWith)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 228 |  |  | 				throw new BadRequestException("User $localShareWith does not exist"); | 
            
                                                                        
                            
            
                                    
            
            
                | 229 |  |  | 			} | 
            
                                                                        
                            
            
                                    
            
            
                | 230 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 231 |  |  | 			$ownerAddress = new Address($owner, $ownerDisplayName); | 
            
                                                                        
                            
            
                                    
            
            
                | 232 |  |  | 			$sharedByAddress = new Address($sender, $senderDisplayName); | 
            
                                                                        
                            
            
                                    
            
            
                | 233 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 234 |  |  | 			$this->fedShareManager->createShare( | 
            
                                                                        
                            
            
                                    
            
            
                | 235 |  |  | 				$ownerAddress, | 
            
                                                                        
                            
            
                                    
            
            
                | 236 |  |  | 				$sharedByAddress, | 
            
                                                                        
                            
            
                                    
            
            
                | 237 |  |  | 				$localShareWith, | 
            
                                                                        
                            
            
                                    
            
            
                | 238 |  |  | 				$providerId, | 
            
                                                                        
                            
            
                                    
            
            
                | 239 |  |  | 				$name, | 
            
                                                                        
                            
            
                                    
            
            
                | 240 |  |  | 				$protocol['options']['sharedSecret'] | 
            
                                                                        
                            
            
                                    
            
            
                | 241 |  |  | 			); | 
            
                                                                        
                            
            
                                    
            
            
                | 242 |  |  | 		} catch (OcmException $e) { | 
            
                                                                        
                            
            
                                    
            
            
                | 243 |  |  | 			return new JSONResponse( | 
            
                                                                        
                            
            
                                    
            
            
                | 244 |  |  | 				['message' => $e->getMessage()], | 
            
                                                                        
                            
            
                                    
            
            
                | 245 |  |  | 				$e->getHttpStatusCode() | 
            
                                                                        
                            
            
                                    
            
            
                | 246 |  |  | 			); | 
            
                                                                        
                            
            
                                    
            
            
                | 247 |  |  | 		} catch (\Exception $e) { | 
            
                                                                        
                            
            
                                    
            
            
                | 248 |  |  | 			$this->logger->error( | 
            
                                                                        
                            
            
                                    
            
            
                | 249 |  |  | 				"server can not add remote share, {$e->getMessage()}", | 
            
                                                                        
                            
            
                                    
            
            
                | 250 |  |  | 				['app' => 'federatefilesharing'] | 
            
                                                                        
                            
            
                                    
            
            
                | 251 |  |  | 			); | 
            
                                                                        
                            
            
                                    
            
            
                | 252 |  |  | 			return new JSONResponse( | 
            
                                                                        
                            
            
                                    
            
            
                | 253 |  |  | 				[ | 
            
                                                                        
                            
            
                                    
            
            
                | 254 |  |  | 					'message' => "internal server error, was not able to add share from {$owner}" | 
            
                                                                        
                            
            
                                    
            
            
                | 255 |  |  | 				], | 
            
                                                                        
                            
            
                                    
            
            
                | 256 |  |  | 				Http::STATUS_INTERNAL_SERVER_ERROR | 
            
                                                                        
                            
            
                                    
            
            
                | 257 |  |  | 			); | 
            
                                                                        
                            
            
                                    
            
            
                | 258 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 259 |  |  | 		return new JSONResponse( | 
            
                                                                        
                            
            
                                    
            
            
                | 260 |  |  | 			[], | 
            
                                                                        
                            
            
                                    
            
            
                | 261 |  |  | 			Http::STATUS_CREATED | 
            
                                                                        
                            
            
                                    
            
            
                | 262 |  |  | 		); | 
            
                                                                        
                            
            
                                    
            
            
                | 263 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 	 * @NoCSRFRequired | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 	 * @PublicPage | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 	 * @param string $notificationType notification type (SHARE_REMOVED, etc) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 	 * @param string $resourceType only 'file' is supported atm | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 	 * @param string $providerId Identifier of the resource at the provider side | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 	 * @param array $notification | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 	 * 		[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 	 * 			optional additional parameters, depending on the notification | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 	 * 				and the resource type | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  | 	 * 		] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 	 * @return JSONResponse | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  | 	public function processNotification($notificationType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 										$resourceType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  | 										$providerId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 										$notification | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  | 	) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 		try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 			if (!\is_array($notification)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 				throw new BadRequestException( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 					'server can not add remote share, missing parameter' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | 			$this->ocmMiddleware->assertNotNull( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 				[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 					'notificationType' => $notificationType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | 					'resourceType' => $resourceType, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 					'providerId' => $providerId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 					'sharedSecret' => $notification['sharedSecret'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 				] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 			if ($this->isSupportedResourceType($resourceType) === false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 				throw new NotImplementedException( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  | 					"ResourceType {$resourceType} is not supported" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 				); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 			switch ($notificationType) { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 308 |  | View Code Duplication | 				case FileNotification::NOTIFICATION_TYPE_SHARE_ACCEPTED: | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 					$this->ocmMiddleware->assertOutgoingSharingEnabled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 					$share = $this->ocmMiddleware->getValidShare( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 						$providerId, $notification['sharedSecret'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | 					$this->fedShareManager->acceptShare($share); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 315 |  | View Code Duplication | 				case FileNotification::NOTIFICATION_TYPE_SHARE_DECLINED: | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 					$this->ocmMiddleware->assertOutgoingSharingEnabled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 					$share = $this->ocmMiddleware->getValidShare( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 						$providerId, $notification['sharedSecret'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 					$this->fedShareManager->declineShare($share); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 				case FileNotification::NOTIFICATION_TYPE_REQUEST_RESHARE: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 					$this->ocmMiddleware->assertOutgoingSharingEnabled(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 					$this->ocmMiddleware->assertNotNull( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | 						[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 							'shareWith' => $notification['shareWith'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 							'senderId' => $notification['senderId'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 						] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | 					$share = $this->ocmMiddleware->getValidShare( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 						$providerId, $notification['sharedSecret'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 					// don't allow to share a file back to the owner | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 					$owner = $share->getShareOwner(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 					$ownerAddress = $this->addressHandler->getLocalUserFederatedAddress($owner); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | 					$shareWithAddress = new Address($notification['shareWith']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 					$this->ocmMiddleware->assertNotSameUser($ownerAddress, $shareWithAddress); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  | 					$this->ocmMiddleware->assertSharingPermissionSet($share); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 					$reShare = $this->fedShareManager->reShare( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 						$share, $notification['senderId'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 						$notification['shareWith'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  | 					return new JSONResponse( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 						[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 							'sharedSecret' => $reShare->getToken(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  | 							'providerId' => $reShare->getId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  | 						], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 						Http::STATUS_CREATED | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 					break; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 				case FileNotification::NOTIFICATION_TYPE_RESHARE_CHANGE_PERMISSION: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  | 					$this->ocmMiddleware->assertNotNull( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 						[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 							'permission' => $notification['permission'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  | 							'senderId' => $notification['senderId'], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 						] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  | 					$share = $this->ocmMiddleware->getValidShare( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 						$providerId, $notification['sharedSecret'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 					$this->fedShareManager->updateOcmPermissions( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 						$share, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 						$notification['permission'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 				case FileNotification::NOTIFICATION_TYPE_SHARE_UNSHARED: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  | 					$this->fedShareManager->unshare( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 						$providerId, $notification['sharedSecret'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 				case FileNotification::NOTIFICATION_TYPE_RESHARE_UNDO: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 					// owner or sender unshared a resource | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 					$share = $this->ocmMiddleware->getValidShare( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  | 						$providerId, $notification['sharedSecret'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 					$this->fedShareManager->undoReshare($share); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 					break; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 				default: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 					return new JSONResponse( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 						['message' => "Notification of type {$notificationType} is not supported"], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 						Http::STATUS_NOT_IMPLEMENTED | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 					); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 		} catch (OcmException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 			return new JSONResponse( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 				['message' => $e->getMessage()], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 				$e->getHttpStatusCode() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 		} catch (\Exception $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  | 			$this->logger->error( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 				"server can not process notification, {$e->getMessage()}", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 				['app' => 'federatefilesharing'] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 			return new JSONResponse( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 				[ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 					'message' => "internal server error, was not able to process notification" | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 				], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 				Http::STATUS_INTERNAL_SERVER_ERROR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 		return new JSONResponse( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 			[], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 			Http::STATUS_CREATED | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 	 * Get list of supported protocols | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 	protected function getProtocols() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 		return [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 			'webdav' => '/public.php/webdav/' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 		]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 	 * @param string $resourceType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 	 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 	protected function isSupportedResourceType($resourceType) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 		return $resourceType === FileNotification::RESOURCE_TYPE_FILE; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 	 * @param string $shareType | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 	 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 	protected function isSupportedShareType($shareType) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 		// TODO: make it a constant | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 		return $shareType === 'user'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 	 * @param string $protocolName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 	 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 	protected function isSupportedProtocol($protocolName) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 		$supportedProtocols = $this->getProtocols(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 		$supportedProtocolNames = \array_keys($supportedProtocols); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 		return \in_array($protocolName, $supportedProtocolNames); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 447 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 448 |  |  |  | 
            
                        
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.