Completed
Push — master ( 478345...66c260 )
by
unknown
27:35 queued 14s
created
apps/files_external/lib/Lib/Auth/OAuth1/OAuth1.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -14,26 +14,26 @@
 block discarded – undo
14 14
  * OAuth1 authentication
15 15
  */
16 16
 class OAuth1 extends AuthMechanism {
17
-	public function __construct(IL10N $l) {
18
-		$this
19
-			->setIdentifier('oauth1::oauth1')
20
-			->setScheme(self::SCHEME_OAUTH1)
21
-			->setText($l->t('OAuth1'))
22
-			->addParameters([
23
-				(new DefinitionParameter('configured', 'configured'))
24
-					->setType(DefinitionParameter::VALUE_TEXT)
25
-					->setFlag(DefinitionParameter::FLAG_HIDDEN),
26
-				new DefinitionParameter('app_key', $l->t('App key')),
27
-				(new DefinitionParameter('app_secret', $l->t('App secret')))
28
-					->setType(DefinitionParameter::VALUE_PASSWORD),
29
-				(new DefinitionParameter('token', 'token'))
30
-					->setType(DefinitionParameter::VALUE_PASSWORD)
31
-					->setFlag(DefinitionParameter::FLAG_HIDDEN),
32
-				(new DefinitionParameter('token_secret', 'token_secret'))
33
-					->setType(DefinitionParameter::VALUE_PASSWORD)
34
-					->setFlag(DefinitionParameter::FLAG_HIDDEN),
35
-			])
36
-			->addCustomJs('oauth1')
37
-		;
38
-	}
17
+    public function __construct(IL10N $l) {
18
+        $this
19
+            ->setIdentifier('oauth1::oauth1')
20
+            ->setScheme(self::SCHEME_OAUTH1)
21
+            ->setText($l->t('OAuth1'))
22
+            ->addParameters([
23
+                (new DefinitionParameter('configured', 'configured'))
24
+                    ->setType(DefinitionParameter::VALUE_TEXT)
25
+                    ->setFlag(DefinitionParameter::FLAG_HIDDEN),
26
+                new DefinitionParameter('app_key', $l->t('App key')),
27
+                (new DefinitionParameter('app_secret', $l->t('App secret')))
28
+                    ->setType(DefinitionParameter::VALUE_PASSWORD),
29
+                (new DefinitionParameter('token', 'token'))
30
+                    ->setType(DefinitionParameter::VALUE_PASSWORD)
31
+                    ->setFlag(DefinitionParameter::FLAG_HIDDEN),
32
+                (new DefinitionParameter('token_secret', 'token_secret'))
33
+                    ->setType(DefinitionParameter::VALUE_PASSWORD)
34
+                    ->setFlag(DefinitionParameter::FLAG_HIDDEN),
35
+            ])
36
+            ->addCustomJs('oauth1')
37
+        ;
38
+    }
39 39
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/Password/LoginCredentials.php 1 patch
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -27,86 +27,86 @@
 block discarded – undo
27 27
  * Username and password from login credentials, saved in DB
28 28
  */
29 29
 class LoginCredentials extends AuthMechanism {
30
-	public const CREDENTIALS_IDENTIFIER = 'password::logincredentials/credentials';
30
+    public const CREDENTIALS_IDENTIFIER = 'password::logincredentials/credentials';
31 31
 
32
-	public function __construct(
33
-		IL10N $l,
34
-		protected ISession $session,
35
-		protected ICredentialsManager $credentialsManager,
36
-		private CredentialsStore $credentialsStore,
37
-		IEventDispatcher $eventDispatcher,
38
-		private ILDAPProviderFactory $ldapFactory,
39
-	) {
40
-		$this
41
-			->setIdentifier('password::logincredentials')
42
-			->setScheme(self::SCHEME_PASSWORD)
43
-			->setText($l->t('Log-in credentials, save in database'))
44
-			->addParameters([
45
-				(new DefinitionParameter('password', $l->t('Password')))
46
-					->setType(DefinitionParameter::VALUE_PASSWORD)
47
-					->setFlag(DefinitionParameter::FLAG_HIDDEN)
48
-					->setFlag(DefinitionParameter::FLAG_OPTIONAL),
49
-			]);
32
+    public function __construct(
33
+        IL10N $l,
34
+        protected ISession $session,
35
+        protected ICredentialsManager $credentialsManager,
36
+        private CredentialsStore $credentialsStore,
37
+        IEventDispatcher $eventDispatcher,
38
+        private ILDAPProviderFactory $ldapFactory,
39
+    ) {
40
+        $this
41
+            ->setIdentifier('password::logincredentials')
42
+            ->setScheme(self::SCHEME_PASSWORD)
43
+            ->setText($l->t('Log-in credentials, save in database'))
44
+            ->addParameters([
45
+                (new DefinitionParameter('password', $l->t('Password')))
46
+                    ->setType(DefinitionParameter::VALUE_PASSWORD)
47
+                    ->setFlag(DefinitionParameter::FLAG_HIDDEN)
48
+                    ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
49
+            ]);
50 50
 
51
-		$eventDispatcher->addServiceListener(UserLoggedInEvent::class, StorePasswordListener::class);
52
-		$eventDispatcher->addServiceListener(PasswordUpdatedEvent::class, StorePasswordListener::class);
53
-	}
51
+        $eventDispatcher->addServiceListener(UserLoggedInEvent::class, StorePasswordListener::class);
52
+        $eventDispatcher->addServiceListener(PasswordUpdatedEvent::class, StorePasswordListener::class);
53
+    }
54 54
 
55
-	private function getCredentials(IUser $user): array {
56
-		$credentials = $this->credentialsManager->retrieve($user->getUID(), self::CREDENTIALS_IDENTIFIER);
55
+    private function getCredentials(IUser $user): array {
56
+        $credentials = $this->credentialsManager->retrieve($user->getUID(), self::CREDENTIALS_IDENTIFIER);
57 57
 
58
-		if (is_null($credentials)) {
59
-			// nothing saved in db, try to get it from the session and save it
60
-			try {
61
-				$sessionCredentials = $this->credentialsStore->getLoginCredentials();
58
+        if (is_null($credentials)) {
59
+            // nothing saved in db, try to get it from the session and save it
60
+            try {
61
+                $sessionCredentials = $this->credentialsStore->getLoginCredentials();
62 62
 
63
-				if ($sessionCredentials->getUID() !== $user->getUID()) {
64
-					// Can't take the credentials from the session as they are not the same user
65
-					throw new CredentialsUnavailableException();
66
-				}
63
+                if ($sessionCredentials->getUID() !== $user->getUID()) {
64
+                    // Can't take the credentials from the session as they are not the same user
65
+                    throw new CredentialsUnavailableException();
66
+                }
67 67
 
68
-				$credentials = [
69
-					'user' => $sessionCredentials->getLoginName(),
70
-					'password' => $sessionCredentials->getPassword(),
71
-				];
68
+                $credentials = [
69
+                    'user' => $sessionCredentials->getLoginName(),
70
+                    'password' => $sessionCredentials->getPassword(),
71
+                ];
72 72
 
73
-				$this->credentialsManager->store($user->getUID(), self::CREDENTIALS_IDENTIFIER, $credentials);
74
-			} catch (CredentialsUnavailableException $e) {
75
-				throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
76
-			}
77
-		}
73
+                $this->credentialsManager->store($user->getUID(), self::CREDENTIALS_IDENTIFIER, $credentials);
74
+            } catch (CredentialsUnavailableException $e) {
75
+                throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
76
+            }
77
+        }
78 78
 
79
-		return $credentials;
80
-	}
79
+        return $credentials;
80
+    }
81 81
 
82
-	/**
83
-	 * @return void
84
-	 */
85
-	public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
86
-		if (!isset($user)) {
87
-			throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
88
-		}
89
-		$credentials = $this->getCredentials($user);
82
+    /**
83
+     * @return void
84
+     */
85
+    public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
86
+        if (!isset($user)) {
87
+            throw new InsufficientDataForMeaningfulAnswerException('No login credentials saved');
88
+        }
89
+        $credentials = $this->getCredentials($user);
90 90
 
91
-		$loginKey = $storage->getBackendOption('login_ldap_attr');
92
-		if ($loginKey) {
93
-			$backend = $user->getBackend();
94
-			if ($backend instanceof IUserBackend && $backend->getBackendName() === 'LDAP') {
95
-				$value = $this->getLdapPropertyForUser($user, $loginKey);
96
-				if ($value === null) {
97
-					throw new InsufficientDataForMeaningfulAnswerException('Custom ldap attribute not set for user ' . $user->getUID());
98
-				}
99
-				$storage->setBackendOption('user', $value);
100
-			} else {
101
-				throw new InsufficientDataForMeaningfulAnswerException('Custom ldap attribute configured but user ' . $user->getUID() . ' is not an ldap user');
102
-			}
103
-		} else {
104
-			$storage->setBackendOption('user', $credentials['user']);
105
-		}
106
-		$storage->setBackendOption('password', $credentials['password']);
107
-	}
91
+        $loginKey = $storage->getBackendOption('login_ldap_attr');
92
+        if ($loginKey) {
93
+            $backend = $user->getBackend();
94
+            if ($backend instanceof IUserBackend && $backend->getBackendName() === 'LDAP') {
95
+                $value = $this->getLdapPropertyForUser($user, $loginKey);
96
+                if ($value === null) {
97
+                    throw new InsufficientDataForMeaningfulAnswerException('Custom ldap attribute not set for user ' . $user->getUID());
98
+                }
99
+                $storage->setBackendOption('user', $value);
100
+            } else {
101
+                throw new InsufficientDataForMeaningfulAnswerException('Custom ldap attribute configured but user ' . $user->getUID() . ' is not an ldap user');
102
+            }
103
+        } else {
104
+            $storage->setBackendOption('user', $credentials['user']);
105
+        }
106
+        $storage->setBackendOption('password', $credentials['password']);
107
+    }
108 108
 
109
-	private function getLdapPropertyForUser(IUser $user, string $property): ?string {
110
-		return $this->ldapFactory->getLDAPProvider()->getUserAttribute($user->getUID(), $property);
111
-	}
109
+    private function getLdapPropertyForUser(IUser $user, string $property): ?string {
110
+        return $this->ldapFactory->getLDAPProvider()->getUserAttribute($user->getUID(), $property);
111
+    }
112 112
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/Password/SessionCredentials.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -23,44 +23,44 @@
 block discarded – undo
23 23
  */
24 24
 class SessionCredentials extends AuthMechanism {
25 25
 
26
-	public function __construct(
27
-		IL10N $l,
28
-		private CredentialsStore $credentialsStore,
29
-	) {
30
-		$this->setIdentifier('password::sessioncredentials')
31
-			->setScheme(self::SCHEME_PASSWORD)
32
-			->setText($l->t('Log-in credentials, save in session'))
33
-			->addParameters([
34
-				(new DefinitionParameter('password', $l->t('Password')))
35
-					->setType(DefinitionParameter::VALUE_PASSWORD)
36
-					->setFlag(DefinitionParameter::FLAG_HIDDEN)
37
-					->setFlag(DefinitionParameter::FLAG_OPTIONAL),
38
-			]);
39
-	}
26
+    public function __construct(
27
+        IL10N $l,
28
+        private CredentialsStore $credentialsStore,
29
+    ) {
30
+        $this->setIdentifier('password::sessioncredentials')
31
+            ->setScheme(self::SCHEME_PASSWORD)
32
+            ->setText($l->t('Log-in credentials, save in session'))
33
+            ->addParameters([
34
+                (new DefinitionParameter('password', $l->t('Password')))
35
+                    ->setType(DefinitionParameter::VALUE_PASSWORD)
36
+                    ->setFlag(DefinitionParameter::FLAG_HIDDEN)
37
+                    ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
38
+            ]);
39
+    }
40 40
 
41
-	/**
42
-	 * @return void
43
-	 */
44
-	public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
45
-		try {
46
-			$credentials = $this->credentialsStore->getLoginCredentials();
47
-		} catch (CredentialsUnavailableException $e) {
48
-			throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved');
49
-		}
41
+    /**
42
+     * @return void
43
+     */
44
+    public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
45
+        try {
46
+            $credentials = $this->credentialsStore->getLoginCredentials();
47
+        } catch (CredentialsUnavailableException $e) {
48
+            throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved');
49
+        }
50 50
 
51
-		if ($user === null) {
52
-			throw new StorageAuthException('Session unavailable');
53
-		}
51
+        if ($user === null) {
52
+            throw new StorageAuthException('Session unavailable');
53
+        }
54 54
 
55
-		if ($credentials->getUID() !== $user->getUID()) {
56
-			throw new StorageAuthException('Session credentials for storage owner not available');
57
-		}
55
+        if ($credentials->getUID() !== $user->getUID()) {
56
+            throw new StorageAuthException('Session credentials for storage owner not available');
57
+        }
58 58
 
59
-		$storage->setBackendOption('user', $credentials->getLoginName());
60
-		$storage->setBackendOption('password', $credentials->getPassword());
61
-	}
59
+        $storage->setBackendOption('user', $credentials->getLoginName());
60
+        $storage->setBackendOption('password', $credentials->getPassword());
61
+    }
62 62
 
63
-	public function wrapStorage(IStorage $storage): IStorage {
64
-		return new SessionStorageWrapper(['storage' => $storage]);
65
-	}
63
+    public function wrapStorage(IStorage $storage): IStorage {
64
+        return new SessionStorageWrapper(['storage' => $storage]);
65
+    }
66 66
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/PublicKey/RSA.php 1 patch
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -19,56 +19,56 @@
 block discarded – undo
19 19
  */
20 20
 class RSA extends AuthMechanism {
21 21
 
22
-	public function __construct(
23
-		IL10N $l,
24
-		private IConfig $config,
25
-	) {
26
-		$this
27
-			->setIdentifier('publickey::rsa')
28
-			->setScheme(self::SCHEME_PUBLICKEY)
29
-			->setText($l->t('RSA public key'))
30
-			->addParameters([
31
-				new DefinitionParameter('user', $l->t('Login')),
32
-				new DefinitionParameter('public_key', $l->t('Public key')),
33
-				(new DefinitionParameter('private_key', 'private_key'))
34
-					->setType(DefinitionParameter::VALUE_PASSWORD)
35
-					->setFlag(DefinitionParameter::FLAG_HIDDEN),
36
-			])
37
-			->addCustomJs('public_key')
38
-		;
39
-	}
22
+    public function __construct(
23
+        IL10N $l,
24
+        private IConfig $config,
25
+    ) {
26
+        $this
27
+            ->setIdentifier('publickey::rsa')
28
+            ->setScheme(self::SCHEME_PUBLICKEY)
29
+            ->setText($l->t('RSA public key'))
30
+            ->addParameters([
31
+                new DefinitionParameter('user', $l->t('Login')),
32
+                new DefinitionParameter('public_key', $l->t('Public key')),
33
+                (new DefinitionParameter('private_key', 'private_key'))
34
+                    ->setType(DefinitionParameter::VALUE_PASSWORD)
35
+                    ->setFlag(DefinitionParameter::FLAG_HIDDEN),
36
+            ])
37
+            ->addCustomJs('public_key')
38
+        ;
39
+    }
40 40
 
41
-	/**
42
-	 * @return void
43
-	 */
44
-	public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
45
-		$auth = new RSACrypt();
46
-		$auth->setPassword($this->config->getSystemValue('secret', ''));
47
-		if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
48
-			// Add fallback routine for a time where secret was not enforced to be exists
49
-			$auth->setPassword('');
50
-			if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
51
-				throw new \RuntimeException('unable to load private key');
52
-			}
53
-		}
54
-		$storage->setBackendOption('public_key_auth', $auth);
55
-	}
41
+    /**
42
+     * @return void
43
+     */
44
+    public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
45
+        $auth = new RSACrypt();
46
+        $auth->setPassword($this->config->getSystemValue('secret', ''));
47
+        if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
48
+            // Add fallback routine for a time where secret was not enforced to be exists
49
+            $auth->setPassword('');
50
+            if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
51
+                throw new \RuntimeException('unable to load private key');
52
+            }
53
+        }
54
+        $storage->setBackendOption('public_key_auth', $auth);
55
+    }
56 56
 
57
-	/**
58
-	 * Generate a keypair
59
-	 *
60
-	 * @param int $keyLenth
61
-	 * @return array ['privatekey' => $privateKey, 'publickey' => $publicKey]
62
-	 */
63
-	public function createKey($keyLength) {
64
-		$rsa = new RSACrypt();
65
-		$rsa->setPublicKeyFormat(RSACrypt::PUBLIC_FORMAT_OPENSSH);
66
-		$rsa->setPassword($this->config->getSystemValue('secret', ''));
57
+    /**
58
+     * Generate a keypair
59
+     *
60
+     * @param int $keyLenth
61
+     * @return array ['privatekey' => $privateKey, 'publickey' => $publicKey]
62
+     */
63
+    public function createKey($keyLength) {
64
+        $rsa = new RSACrypt();
65
+        $rsa->setPublicKeyFormat(RSACrypt::PUBLIC_FORMAT_OPENSSH);
66
+        $rsa->setPassword($this->config->getSystemValue('secret', ''));
67 67
 
68
-		if ($keyLength !== 1024 && $keyLength !== 2048 && $keyLength !== 4096) {
69
-			$keyLength = 1024;
70
-		}
68
+        if ($keyLength !== 1024 && $keyLength !== 2048 && $keyLength !== 4096) {
69
+            $keyLength = 1024;
70
+        }
71 71
 
72
-		return $rsa->createKey($keyLength);
73
-	}
72
+        return $rsa->createKey($keyLength);
73
+    }
74 74
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Auth/OAuth2/OAuth2.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -14,23 +14,23 @@
 block discarded – undo
14 14
  * OAuth2 authentication
15 15
  */
16 16
 class OAuth2 extends AuthMechanism {
17
-	public function __construct(IL10N $l) {
18
-		$this
19
-			->setIdentifier('oauth2::oauth2')
20
-			->setScheme(self::SCHEME_OAUTH2)
21
-			->setText($l->t('OAuth2'))
22
-			->addParameters([
23
-				(new DefinitionParameter('configured', 'configured'))
24
-					->setType(DefinitionParameter::VALUE_TEXT)
25
-					->setFlag(DefinitionParameter::FLAG_HIDDEN),
26
-				new DefinitionParameter('client_id', $l->t('Client ID')),
27
-				(new DefinitionParameter('client_secret', $l->t('Client secret')))
28
-					->setType(DefinitionParameter::VALUE_PASSWORD),
29
-				(new DefinitionParameter('token', 'token'))
30
-					->setType(DefinitionParameter::VALUE_PASSWORD)
31
-					->setFlag(DefinitionParameter::FLAG_HIDDEN),
32
-			])
33
-			->addCustomJs('oauth2')
34
-		;
35
-	}
17
+    public function __construct(IL10N $l) {
18
+        $this
19
+            ->setIdentifier('oauth2::oauth2')
20
+            ->setScheme(self::SCHEME_OAUTH2)
21
+            ->setText($l->t('OAuth2'))
22
+            ->addParameters([
23
+                (new DefinitionParameter('configured', 'configured'))
24
+                    ->setType(DefinitionParameter::VALUE_TEXT)
25
+                    ->setFlag(DefinitionParameter::FLAG_HIDDEN),
26
+                new DefinitionParameter('client_id', $l->t('Client ID')),
27
+                (new DefinitionParameter('client_secret', $l->t('Client secret')))
28
+                    ->setType(DefinitionParameter::VALUE_PASSWORD),
29
+                (new DefinitionParameter('token', 'token'))
30
+                    ->setType(DefinitionParameter::VALUE_PASSWORD)
31
+                    ->setFlag(DefinitionParameter::FLAG_HIDDEN),
32
+            ])
33
+            ->addCustomJs('oauth2')
34
+        ;
35
+    }
36 36
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/DefinitionParameter.php 1 patch
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -10,207 +10,207 @@
 block discarded – undo
10 10
  * Parameter for an external storage definition
11 11
  */
12 12
 class DefinitionParameter implements \JsonSerializable {
13
-	// placeholder value for password fields, when the client updates a storage configuration
14
-	// placeholder values are ignored and the field is left unmodified
15
-	public const UNMODIFIED_PLACEHOLDER = '__unmodified__';
16
-
17
-	/** Value constants */
18
-	public const VALUE_TEXT = 0;
19
-	public const VALUE_BOOLEAN = 1;
20
-	public const VALUE_PASSWORD = 2;
21
-
22
-	/** Flag constants */
23
-	public const FLAG_NONE = 0;
24
-	public const FLAG_OPTIONAL = 1;
25
-	public const FLAG_USER_PROVIDED = 2;
26
-	public const FLAG_HIDDEN = 4;
27
-
28
-	/** @var string human-readable parameter tooltip */
29
-	private string $tooltip = '';
30
-
31
-	/** @var int value type, see self::VALUE_* constants */
32
-	private int $type = self::VALUE_TEXT;
33
-
34
-	/** @var int flags, see self::FLAG_* constants */
35
-	private int $flags = self::FLAG_NONE;
36
-
37
-	/**
38
-	 * @param string $name parameter name
39
-	 * @param string $text parameter description
40
-	 * @param mixed $defaultValue default value
41
-	 */
42
-	public function __construct(
43
-		private string $name,
44
-		private string $text,
45
-		private $defaultValue = null,
46
-	) {
47
-	}
48
-
49
-	/**
50
-	 * @return string
51
-	 */
52
-	public function getName(): string {
53
-		return $this->name;
54
-	}
55
-
56
-	/**
57
-	 * @return string
58
-	 */
59
-	public function getText(): string {
60
-		return $this->text;
61
-	}
62
-
63
-	/**
64
-	 * Get value type
65
-	 *
66
-	 * @return int
67
-	 */
68
-	public function getType(): int {
69
-		return $this->type;
70
-	}
71
-
72
-	/**
73
-	 * Set value type
74
-	 *
75
-	 * @param int $type
76
-	 * @return self
77
-	 */
78
-	public function setType(int $type) {
79
-		$this->type = $type;
80
-		return $this;
81
-	}
82
-
83
-	/**
84
-	 * @return mixed default value
85
-	 */
86
-	public function getDefaultValue() {
87
-		return $this->defaultValue;
88
-	}
89
-
90
-	/**
91
-	 * @param mixed $defaultValue default value
92
-	 * @return self
93
-	 */
94
-	public function setDefaultValue($defaultValue) {
95
-		$this->defaultValue = $defaultValue;
96
-		return $this;
97
-	}
98
-
99
-	/**
100
-	 * @return string
101
-	 */
102
-	public function getTypeName(): string {
103
-		switch ($this->type) {
104
-			case self::VALUE_BOOLEAN:
105
-				return 'boolean';
106
-			case self::VALUE_TEXT:
107
-				return 'text';
108
-			case self::VALUE_PASSWORD:
109
-				return 'password';
110
-			default:
111
-				return 'unknown';
112
-		}
113
-	}
114
-
115
-	/**
116
-	 * @return int
117
-	 */
118
-	public function getFlags(): int {
119
-		return $this->flags;
120
-	}
121
-
122
-	/**
123
-	 * @param int $flags
124
-	 * @return self
125
-	 */
126
-	public function setFlags(int $flags) {
127
-		$this->flags = $flags;
128
-		return $this;
129
-	}
130
-
131
-	/**
132
-	 * @param int $flag
133
-	 * @return self
134
-	 */
135
-	public function setFlag(int $flag) {
136
-		$this->flags |= $flag;
137
-		return $this;
138
-	}
139
-
140
-	/**
141
-	 * @param int $flag
142
-	 * @return bool
143
-	 */
144
-	public function isFlagSet(int $flag): bool {
145
-		return (bool)($this->flags & $flag);
146
-	}
147
-
148
-	/**
149
-	 * @return string
150
-	 */
151
-	public function getTooltip(): string {
152
-		return $this->tooltip;
153
-	}
154
-
155
-	/**
156
-	 * @param string $tooltip
157
-	 * @return self
158
-	 */
159
-	public function setTooltip(string $tooltip) {
160
-		$this->tooltip = $tooltip;
161
-		return $this;
162
-	}
163
-
164
-	/**
165
-	 * Serialize into JSON for client-side JS
166
-	 */
167
-	public function jsonSerialize(): array {
168
-		$result = [
169
-			'value' => $this->getText(),
170
-			'flags' => $this->getFlags(),
171
-			'type' => $this->getType(),
172
-			'tooltip' => $this->getTooltip(),
173
-		];
174
-		$defaultValue = $this->getDefaultValue();
175
-		if ($defaultValue) {
176
-			$result['defaultValue'] = $defaultValue;
177
-		}
178
-		return $result;
179
-	}
180
-
181
-	public function isOptional(): bool {
182
-		return $this->isFlagSet(self::FLAG_OPTIONAL) || $this->isFlagSet(self::FLAG_USER_PROVIDED);
183
-	}
184
-
185
-	/**
186
-	 * Validate a parameter value against this
187
-	 * Convert type as necessary
188
-	 *
189
-	 * @param mixed $value Value to check
190
-	 * @return bool success
191
-	 */
192
-	public function validateValue(&$value): bool {
193
-		switch ($this->getType()) {
194
-			case self::VALUE_BOOLEAN:
195
-				if (!is_bool($value)) {
196
-					switch ($value) {
197
-						case 'true':
198
-							$value = true;
199
-							break;
200
-						case 'false':
201
-							$value = false;
202
-							break;
203
-						default:
204
-							return false;
205
-					}
206
-				}
207
-				break;
208
-			default:
209
-				if (!$value && !$this->isOptional()) {
210
-					return false;
211
-				}
212
-				break;
213
-		}
214
-		return true;
215
-	}
13
+    // placeholder value for password fields, when the client updates a storage configuration
14
+    // placeholder values are ignored and the field is left unmodified
15
+    public const UNMODIFIED_PLACEHOLDER = '__unmodified__';
16
+
17
+    /** Value constants */
18
+    public const VALUE_TEXT = 0;
19
+    public const VALUE_BOOLEAN = 1;
20
+    public const VALUE_PASSWORD = 2;
21
+
22
+    /** Flag constants */
23
+    public const FLAG_NONE = 0;
24
+    public const FLAG_OPTIONAL = 1;
25
+    public const FLAG_USER_PROVIDED = 2;
26
+    public const FLAG_HIDDEN = 4;
27
+
28
+    /** @var string human-readable parameter tooltip */
29
+    private string $tooltip = '';
30
+
31
+    /** @var int value type, see self::VALUE_* constants */
32
+    private int $type = self::VALUE_TEXT;
33
+
34
+    /** @var int flags, see self::FLAG_* constants */
35
+    private int $flags = self::FLAG_NONE;
36
+
37
+    /**
38
+     * @param string $name parameter name
39
+     * @param string $text parameter description
40
+     * @param mixed $defaultValue default value
41
+     */
42
+    public function __construct(
43
+        private string $name,
44
+        private string $text,
45
+        private $defaultValue = null,
46
+    ) {
47
+    }
48
+
49
+    /**
50
+     * @return string
51
+     */
52
+    public function getName(): string {
53
+        return $this->name;
54
+    }
55
+
56
+    /**
57
+     * @return string
58
+     */
59
+    public function getText(): string {
60
+        return $this->text;
61
+    }
62
+
63
+    /**
64
+     * Get value type
65
+     *
66
+     * @return int
67
+     */
68
+    public function getType(): int {
69
+        return $this->type;
70
+    }
71
+
72
+    /**
73
+     * Set value type
74
+     *
75
+     * @param int $type
76
+     * @return self
77
+     */
78
+    public function setType(int $type) {
79
+        $this->type = $type;
80
+        return $this;
81
+    }
82
+
83
+    /**
84
+     * @return mixed default value
85
+     */
86
+    public function getDefaultValue() {
87
+        return $this->defaultValue;
88
+    }
89
+
90
+    /**
91
+     * @param mixed $defaultValue default value
92
+     * @return self
93
+     */
94
+    public function setDefaultValue($defaultValue) {
95
+        $this->defaultValue = $defaultValue;
96
+        return $this;
97
+    }
98
+
99
+    /**
100
+     * @return string
101
+     */
102
+    public function getTypeName(): string {
103
+        switch ($this->type) {
104
+            case self::VALUE_BOOLEAN:
105
+                return 'boolean';
106
+            case self::VALUE_TEXT:
107
+                return 'text';
108
+            case self::VALUE_PASSWORD:
109
+                return 'password';
110
+            default:
111
+                return 'unknown';
112
+        }
113
+    }
114
+
115
+    /**
116
+     * @return int
117
+     */
118
+    public function getFlags(): int {
119
+        return $this->flags;
120
+    }
121
+
122
+    /**
123
+     * @param int $flags
124
+     * @return self
125
+     */
126
+    public function setFlags(int $flags) {
127
+        $this->flags = $flags;
128
+        return $this;
129
+    }
130
+
131
+    /**
132
+     * @param int $flag
133
+     * @return self
134
+     */
135
+    public function setFlag(int $flag) {
136
+        $this->flags |= $flag;
137
+        return $this;
138
+    }
139
+
140
+    /**
141
+     * @param int $flag
142
+     * @return bool
143
+     */
144
+    public function isFlagSet(int $flag): bool {
145
+        return (bool)($this->flags & $flag);
146
+    }
147
+
148
+    /**
149
+     * @return string
150
+     */
151
+    public function getTooltip(): string {
152
+        return $this->tooltip;
153
+    }
154
+
155
+    /**
156
+     * @param string $tooltip
157
+     * @return self
158
+     */
159
+    public function setTooltip(string $tooltip) {
160
+        $this->tooltip = $tooltip;
161
+        return $this;
162
+    }
163
+
164
+    /**
165
+     * Serialize into JSON for client-side JS
166
+     */
167
+    public function jsonSerialize(): array {
168
+        $result = [
169
+            'value' => $this->getText(),
170
+            'flags' => $this->getFlags(),
171
+            'type' => $this->getType(),
172
+            'tooltip' => $this->getTooltip(),
173
+        ];
174
+        $defaultValue = $this->getDefaultValue();
175
+        if ($defaultValue) {
176
+            $result['defaultValue'] = $defaultValue;
177
+        }
178
+        return $result;
179
+    }
180
+
181
+    public function isOptional(): bool {
182
+        return $this->isFlagSet(self::FLAG_OPTIONAL) || $this->isFlagSet(self::FLAG_USER_PROVIDED);
183
+    }
184
+
185
+    /**
186
+     * Validate a parameter value against this
187
+     * Convert type as necessary
188
+     *
189
+     * @param mixed $value Value to check
190
+     * @return bool success
191
+     */
192
+    public function validateValue(&$value): bool {
193
+        switch ($this->getType()) {
194
+            case self::VALUE_BOOLEAN:
195
+                if (!is_bool($value)) {
196
+                    switch ($value) {
197
+                        case 'true':
198
+                            $value = true;
199
+                            break;
200
+                        case 'false':
201
+                            $value = false;
202
+                            break;
203
+                        default:
204
+                            return false;
205
+                    }
206
+                }
207
+                break;
208
+            default:
209
+                if (!$value && !$this->isOptional()) {
210
+                    return false;
211
+                }
212
+                break;
213
+        }
214
+        return true;
215
+    }
216 216
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Backend/LegacyBackend.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -15,68 +15,68 @@
 block discarded – undo
15 15
  * Legacy compatibility for OCA\Files_External\MountConfig::registerBackend()
16 16
  */
17 17
 class LegacyBackend extends Backend {
18
-	use LegacyDependencyCheckPolyfill {
19
-		LegacyDependencyCheckPolyfill::checkDependencies as doCheckDependencies;
20
-	}
18
+    use LegacyDependencyCheckPolyfill {
19
+        LegacyDependencyCheckPolyfill::checkDependencies as doCheckDependencies;
20
+    }
21 21
 
22
-	/** @var bool */
23
-	protected $hasDependencies = false;
22
+    /** @var bool */
23
+    protected $hasDependencies = false;
24 24
 
25
-	/**
26
-	 * @param string $class
27
-	 * @param array $definition
28
-	 * @param Builtin $authMechanism
29
-	 */
30
-	public function __construct($class, array $definition, Builtin $authMechanism) {
31
-		$this
32
-			->setIdentifier($class)
33
-			->setStorageClass($class)
34
-			->setText($definition['backend'])
35
-			->addAuthScheme(Builtin::SCHEME_BUILTIN)
36
-			->setLegacyAuthMechanism($authMechanism)
37
-		;
25
+    /**
26
+     * @param string $class
27
+     * @param array $definition
28
+     * @param Builtin $authMechanism
29
+     */
30
+    public function __construct($class, array $definition, Builtin $authMechanism) {
31
+        $this
32
+            ->setIdentifier($class)
33
+            ->setStorageClass($class)
34
+            ->setText($definition['backend'])
35
+            ->addAuthScheme(Builtin::SCHEME_BUILTIN)
36
+            ->setLegacyAuthMechanism($authMechanism)
37
+        ;
38 38
 
39
-		foreach ($definition['configuration'] as $name => $placeholder) {
40
-			$flags = DefinitionParameter::FLAG_NONE;
41
-			$type = DefinitionParameter::VALUE_TEXT;
42
-			if ($placeholder[0] === '&') {
43
-				$flags = DefinitionParameter::FLAG_OPTIONAL;
44
-				$placeholder = substr($placeholder, 1);
45
-			}
46
-			switch ($placeholder[0]) {
47
-				case '!':
48
-					$type = DefinitionParameter::VALUE_BOOLEAN;
49
-					$placeholder = substr($placeholder, 1);
50
-					break;
51
-				case '*':
52
-					$type = DefinitionParameter::VALUE_PASSWORD;
53
-					$placeholder = substr($placeholder, 1);
54
-					break;
55
-			}
56
-			$this->addParameter((new DefinitionParameter($name, $placeholder))
57
-				->setType($type)
58
-				->setFlags($flags)
59
-			);
60
-		}
39
+        foreach ($definition['configuration'] as $name => $placeholder) {
40
+            $flags = DefinitionParameter::FLAG_NONE;
41
+            $type = DefinitionParameter::VALUE_TEXT;
42
+            if ($placeholder[0] === '&') {
43
+                $flags = DefinitionParameter::FLAG_OPTIONAL;
44
+                $placeholder = substr($placeholder, 1);
45
+            }
46
+            switch ($placeholder[0]) {
47
+                case '!':
48
+                    $type = DefinitionParameter::VALUE_BOOLEAN;
49
+                    $placeholder = substr($placeholder, 1);
50
+                    break;
51
+                case '*':
52
+                    $type = DefinitionParameter::VALUE_PASSWORD;
53
+                    $placeholder = substr($placeholder, 1);
54
+                    break;
55
+            }
56
+            $this->addParameter((new DefinitionParameter($name, $placeholder))
57
+                ->setType($type)
58
+                ->setFlags($flags)
59
+            );
60
+        }
61 61
 
62
-		if (isset($definition['priority'])) {
63
-			$this->setPriority($definition['priority']);
64
-		}
65
-		if (isset($definition['custom'])) {
66
-			$this->addCustomJs($definition['custom']);
67
-		}
68
-		if (isset($definition['has_dependencies']) && $definition['has_dependencies']) {
69
-			$this->hasDependencies = true;
70
-		}
71
-	}
62
+        if (isset($definition['priority'])) {
63
+            $this->setPriority($definition['priority']);
64
+        }
65
+        if (isset($definition['custom'])) {
66
+            $this->addCustomJs($definition['custom']);
67
+        }
68
+        if (isset($definition['has_dependencies']) && $definition['has_dependencies']) {
69
+            $this->hasDependencies = true;
70
+        }
71
+    }
72 72
 
73
-	/**
74
-	 * @return MissingDependency[]
75
-	 */
76
-	public function checkDependencies() {
77
-		if ($this->hasDependencies) {
78
-			return $this->doCheckDependencies();
79
-		}
80
-		return [];
81
-	}
73
+    /**
74
+     * @return MissingDependency[]
75
+     */
76
+    public function checkDependencies() {
77
+        if ($this->hasDependencies) {
78
+            return $this->doCheckDependencies();
79
+        }
80
+        return [];
81
+    }
82 82
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Lib/Backend/SMB.php 1 patch
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -21,105 +21,105 @@
 block discarded – undo
21 21
 use OCP\IUser;
22 22
 
23 23
 class SMB extends Backend {
24
-	use LegacyDependencyCheckPolyfill;
24
+    use LegacyDependencyCheckPolyfill;
25 25
 
26
-	public function __construct(IL10N $l, Password $legacyAuth) {
27
-		$this
28
-			->setIdentifier('smb')
29
-			->addIdentifierAlias('\OC\Files\Storage\SMB')// legacy compat
30
-			->setStorageClass('\OCA\Files_External\Lib\Storage\SMB')
31
-			->setText($l->t('SMB/CIFS'))
32
-			->addParameters([
33
-				new DefinitionParameter('host', $l->t('Host')),
34
-				new DefinitionParameter('share', $l->t('Share')),
35
-				(new DefinitionParameter('root', $l->t('Remote subfolder')))
36
-					->setFlag(DefinitionParameter::FLAG_OPTIONAL),
37
-				(new DefinitionParameter('domain', $l->t('Domain')))
38
-					->setFlag(DefinitionParameter::FLAG_OPTIONAL),
39
-				(new DefinitionParameter('show_hidden', $l->t('Show hidden files')))
40
-					->setType(DefinitionParameter::VALUE_BOOLEAN)
41
-					->setFlag(DefinitionParameter::FLAG_OPTIONAL),
42
-				(new DefinitionParameter('case_sensitive', $l->t('Case sensitive file system')))
43
-					->setType(DefinitionParameter::VALUE_BOOLEAN)
44
-					->setFlag(DefinitionParameter::FLAG_OPTIONAL)
45
-					->setDefaultValue(true)
46
-					->setTooltip($l->t('Disabling it will allow to use a case insensitive file system, but comes with a performance penalty')),
47
-				(new DefinitionParameter('check_acl', $l->t('Verify ACL access when listing files')))
48
-					->setType(DefinitionParameter::VALUE_BOOLEAN)
49
-					->setFlag(DefinitionParameter::FLAG_OPTIONAL)
50
-					->setTooltip($l->t("Check the ACL's of each file or folder inside a directory to filter out items where the account has no read permissions, comes with a performance penalty")),
51
-				(new DefinitionParameter('timeout', $l->t('Timeout')))
52
-					->setType(DefinitionParameter::VALUE_TEXT)
53
-					->setFlag(DefinitionParameter::FLAG_OPTIONAL)
54
-					->setFlag(DefinitionParameter::FLAG_HIDDEN),
55
-			])
56
-			->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
57
-			->addAuthScheme(AuthMechanism::SCHEME_SMB)
58
-			->setLegacyAuthMechanism($legacyAuth);
59
-	}
26
+    public function __construct(IL10N $l, Password $legacyAuth) {
27
+        $this
28
+            ->setIdentifier('smb')
29
+            ->addIdentifierAlias('\OC\Files\Storage\SMB')// legacy compat
30
+            ->setStorageClass('\OCA\Files_External\Lib\Storage\SMB')
31
+            ->setText($l->t('SMB/CIFS'))
32
+            ->addParameters([
33
+                new DefinitionParameter('host', $l->t('Host')),
34
+                new DefinitionParameter('share', $l->t('Share')),
35
+                (new DefinitionParameter('root', $l->t('Remote subfolder')))
36
+                    ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
37
+                (new DefinitionParameter('domain', $l->t('Domain')))
38
+                    ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
39
+                (new DefinitionParameter('show_hidden', $l->t('Show hidden files')))
40
+                    ->setType(DefinitionParameter::VALUE_BOOLEAN)
41
+                    ->setFlag(DefinitionParameter::FLAG_OPTIONAL),
42
+                (new DefinitionParameter('case_sensitive', $l->t('Case sensitive file system')))
43
+                    ->setType(DefinitionParameter::VALUE_BOOLEAN)
44
+                    ->setFlag(DefinitionParameter::FLAG_OPTIONAL)
45
+                    ->setDefaultValue(true)
46
+                    ->setTooltip($l->t('Disabling it will allow to use a case insensitive file system, but comes with a performance penalty')),
47
+                (new DefinitionParameter('check_acl', $l->t('Verify ACL access when listing files')))
48
+                    ->setType(DefinitionParameter::VALUE_BOOLEAN)
49
+                    ->setFlag(DefinitionParameter::FLAG_OPTIONAL)
50
+                    ->setTooltip($l->t("Check the ACL's of each file or folder inside a directory to filter out items where the account has no read permissions, comes with a performance penalty")),
51
+                (new DefinitionParameter('timeout', $l->t('Timeout')))
52
+                    ->setType(DefinitionParameter::VALUE_TEXT)
53
+                    ->setFlag(DefinitionParameter::FLAG_OPTIONAL)
54
+                    ->setFlag(DefinitionParameter::FLAG_HIDDEN),
55
+            ])
56
+            ->addAuthScheme(AuthMechanism::SCHEME_PASSWORD)
57
+            ->addAuthScheme(AuthMechanism::SCHEME_SMB)
58
+            ->setLegacyAuthMechanism($legacyAuth);
59
+    }
60 60
 
61
-	/**
62
-	 * @return void
63
-	 */
64
-	public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
65
-		$auth = $storage->getAuthMechanism();
66
-		if ($auth->getScheme() === AuthMechanism::SCHEME_PASSWORD) {
67
-			if (!is_string($storage->getBackendOption('user')) || !is_string($storage->getBackendOption('password'))) {
68
-				throw new \InvalidArgumentException('user or password is not set');
69
-			}
61
+    /**
62
+     * @return void
63
+     */
64
+    public function manipulateStorageConfig(StorageConfig &$storage, ?IUser $user = null) {
65
+        $auth = $storage->getAuthMechanism();
66
+        if ($auth->getScheme() === AuthMechanism::SCHEME_PASSWORD) {
67
+            if (!is_string($storage->getBackendOption('user')) || !is_string($storage->getBackendOption('password'))) {
68
+                throw new \InvalidArgumentException('user or password is not set');
69
+            }
70 70
 
71
-			$smbAuth = new BasicAuth(
72
-				$storage->getBackendOption('user'),
73
-				$storage->getBackendOption('domain'),
74
-				$storage->getBackendOption('password')
75
-			);
76
-		} else {
77
-			switch ($auth->getIdentifier()) {
78
-				case 'smb::kerberos':
79
-					$smbAuth = new KerberosAuth();
80
-					break;
81
-				case 'smb::kerberosapache':
82
-					if (!$auth instanceof KerberosApacheAuthMechanism) {
83
-						throw new \InvalidArgumentException('invalid authentication backend');
84
-					}
85
-					$credentialsStore = $auth->getCredentialsStore();
86
-					$kerbAuth = new KerberosApacheAuth();
87
-					// check if a kerberos ticket is available, else fallback to session credentials
88
-					if ($kerbAuth->checkTicket()) {
89
-						$smbAuth = $kerbAuth;
90
-					} else {
91
-						try {
92
-							$credentials = $credentialsStore->getLoginCredentials();
93
-							$user = $credentials->getLoginName();
94
-							$pass = $credentials->getPassword();
95
-							preg_match('/(.*)@(.*)/', $user, $matches);
96
-							$realm = $storage->getBackendOption('default_realm');
97
-							if (empty($realm)) {
98
-								$realm = 'WORKGROUP';
99
-							}
100
-							if (count($matches) === 0) {
101
-								$username = $user;
102
-								$workgroup = $realm;
103
-							} else {
104
-								$username = $matches[1];
105
-								$workgroup = $matches[2];
106
-							}
107
-							$smbAuth = new BasicAuth(
108
-								$username,
109
-								$workgroup,
110
-								$pass
111
-							);
112
-						} catch (\Exception $e) {
113
-							throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved');
114
-						}
115
-					}
71
+            $smbAuth = new BasicAuth(
72
+                $storage->getBackendOption('user'),
73
+                $storage->getBackendOption('domain'),
74
+                $storage->getBackendOption('password')
75
+            );
76
+        } else {
77
+            switch ($auth->getIdentifier()) {
78
+                case 'smb::kerberos':
79
+                    $smbAuth = new KerberosAuth();
80
+                    break;
81
+                case 'smb::kerberosapache':
82
+                    if (!$auth instanceof KerberosApacheAuthMechanism) {
83
+                        throw new \InvalidArgumentException('invalid authentication backend');
84
+                    }
85
+                    $credentialsStore = $auth->getCredentialsStore();
86
+                    $kerbAuth = new KerberosApacheAuth();
87
+                    // check if a kerberos ticket is available, else fallback to session credentials
88
+                    if ($kerbAuth->checkTicket()) {
89
+                        $smbAuth = $kerbAuth;
90
+                    } else {
91
+                        try {
92
+                            $credentials = $credentialsStore->getLoginCredentials();
93
+                            $user = $credentials->getLoginName();
94
+                            $pass = $credentials->getPassword();
95
+                            preg_match('/(.*)@(.*)/', $user, $matches);
96
+                            $realm = $storage->getBackendOption('default_realm');
97
+                            if (empty($realm)) {
98
+                                $realm = 'WORKGROUP';
99
+                            }
100
+                            if (count($matches) === 0) {
101
+                                $username = $user;
102
+                                $workgroup = $realm;
103
+                            } else {
104
+                                $username = $matches[1];
105
+                                $workgroup = $matches[2];
106
+                            }
107
+                            $smbAuth = new BasicAuth(
108
+                                $username,
109
+                                $workgroup,
110
+                                $pass
111
+                            );
112
+                        } catch (\Exception $e) {
113
+                            throw new InsufficientDataForMeaningfulAnswerException('No session credentials saved');
114
+                        }
115
+                    }
116 116
 
117
-					break;
118
-				default:
119
-					throw new \InvalidArgumentException('unknown authentication backend');
120
-			}
121
-		}
117
+                    break;
118
+                default:
119
+                    throw new \InvalidArgumentException('unknown authentication backend');
120
+            }
121
+        }
122 122
 
123
-		$storage->setBackendOption('auth', $smbAuth);
124
-	}
123
+        $storage->setBackendOption('auth', $smbAuth);
124
+    }
125 125
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Command/Backends.php 2 patches
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -16,88 +16,88 @@
 block discarded – undo
16 16
 use Symfony\Component\Console\Output\OutputInterface;
17 17
 
18 18
 class Backends extends Base {
19
-	public function __construct(
20
-		private BackendService $backendService,
21
-	) {
22
-		parent::__construct();
23
-	}
19
+    public function __construct(
20
+        private BackendService $backendService,
21
+    ) {
22
+        parent::__construct();
23
+    }
24 24
 
25
-	protected function configure(): void {
26
-		$this
27
-			->setName('files_external:backends')
28
-			->setDescription('Show available authentication and storage backends')
29
-			->addArgument(
30
-				'type',
31
-				InputArgument::OPTIONAL,
32
-				'only show backends of a certain type. Possible values are "authentication" or "storage"'
33
-			)->addArgument(
34
-				'backend',
35
-				InputArgument::OPTIONAL,
36
-				'only show information of a specific backend'
37
-			);
38
-		parent::configure();
39
-	}
25
+    protected function configure(): void {
26
+        $this
27
+            ->setName('files_external:backends')
28
+            ->setDescription('Show available authentication and storage backends')
29
+            ->addArgument(
30
+                'type',
31
+                InputArgument::OPTIONAL,
32
+                'only show backends of a certain type. Possible values are "authentication" or "storage"'
33
+            )->addArgument(
34
+                'backend',
35
+                InputArgument::OPTIONAL,
36
+                'only show information of a specific backend'
37
+            );
38
+        parent::configure();
39
+    }
40 40
 
41
-	protected function execute(InputInterface $input, OutputInterface $output): int {
42
-		$authBackends = $this->backendService->getAuthMechanisms();
43
-		$storageBackends = $this->backendService->getBackends();
41
+    protected function execute(InputInterface $input, OutputInterface $output): int {
42
+        $authBackends = $this->backendService->getAuthMechanisms();
43
+        $storageBackends = $this->backendService->getBackends();
44 44
 
45
-		$data = [
46
-			'authentication' => array_map([$this, 'serializeAuthBackend'], $authBackends),
47
-			'storage' => array_map([$this, 'serializeAuthBackend'], $storageBackends)
48
-		];
45
+        $data = [
46
+            'authentication' => array_map([$this, 'serializeAuthBackend'], $authBackends),
47
+            'storage' => array_map([$this, 'serializeAuthBackend'], $storageBackends)
48
+        ];
49 49
 
50
-		$type = $input->getArgument('type');
51
-		$backend = $input->getArgument('backend');
52
-		if ($type) {
53
-			if (!isset($data[$type])) {
54
-				$output->writeln('<error>Invalid type "' . $type . '". Possible values are "authentication" or "storage"</error>');
55
-				return self::FAILURE;
56
-			}
57
-			$data = $data[$type];
50
+        $type = $input->getArgument('type');
51
+        $backend = $input->getArgument('backend');
52
+        if ($type) {
53
+            if (!isset($data[$type])) {
54
+                $output->writeln('<error>Invalid type "' . $type . '". Possible values are "authentication" or "storage"</error>');
55
+                return self::FAILURE;
56
+            }
57
+            $data = $data[$type];
58 58
 
59
-			if ($backend) {
60
-				if (!isset($data[$backend])) {
61
-					$output->writeln('<error>Unknown backend "' . $backend . '" of type  "' . $type . '"</error>');
62
-					return self::FAILURE;
63
-				}
64
-				$data = $data[$backend];
65
-			}
66
-		}
59
+            if ($backend) {
60
+                if (!isset($data[$backend])) {
61
+                    $output->writeln('<error>Unknown backend "' . $backend . '" of type  "' . $type . '"</error>');
62
+                    return self::FAILURE;
63
+                }
64
+                $data = $data[$backend];
65
+            }
66
+        }
67 67
 
68
-		$this->writeArrayInOutputFormat($input, $output, $data);
69
-		return self::SUCCESS;
70
-	}
68
+        $this->writeArrayInOutputFormat($input, $output, $data);
69
+        return self::SUCCESS;
70
+    }
71 71
 
72
-	private function serializeAuthBackend(\JsonSerializable $backend): array {
73
-		$data = $backend->jsonSerialize();
74
-		$result = [
75
-			'name' => $data['name'],
76
-			'identifier' => $data['identifier'],
77
-			'configuration' => $this->formatConfiguration($data['configuration'])
78
-		];
79
-		if ($backend instanceof Backend) {
80
-			$result['storage_class'] = $backend->getStorageClass();
81
-			$authBackends = $this->backendService->getAuthMechanismsByScheme(array_keys($backend->getAuthSchemes()));
82
-			$result['supported_authentication_backends'] = array_keys($authBackends);
83
-			$authConfig = array_map(function (AuthMechanism $auth) {
84
-				return $this->serializeAuthBackend($auth)['configuration'];
85
-			}, $authBackends);
86
-			$result['authentication_configuration'] = array_combine(array_keys($authBackends), $authConfig);
87
-		}
88
-		return $result;
89
-	}
72
+    private function serializeAuthBackend(\JsonSerializable $backend): array {
73
+        $data = $backend->jsonSerialize();
74
+        $result = [
75
+            'name' => $data['name'],
76
+            'identifier' => $data['identifier'],
77
+            'configuration' => $this->formatConfiguration($data['configuration'])
78
+        ];
79
+        if ($backend instanceof Backend) {
80
+            $result['storage_class'] = $backend->getStorageClass();
81
+            $authBackends = $this->backendService->getAuthMechanismsByScheme(array_keys($backend->getAuthSchemes()));
82
+            $result['supported_authentication_backends'] = array_keys($authBackends);
83
+            $authConfig = array_map(function (AuthMechanism $auth) {
84
+                return $this->serializeAuthBackend($auth)['configuration'];
85
+            }, $authBackends);
86
+            $result['authentication_configuration'] = array_combine(array_keys($authBackends), $authConfig);
87
+        }
88
+        return $result;
89
+    }
90 90
 
91
-	/**
92
-	 * @param DefinitionParameter[] $parameters
93
-	 * @return string[]
94
-	 */
95
-	private function formatConfiguration(array $parameters): array {
96
-		$configuration = array_filter($parameters, function (DefinitionParameter $parameter) {
97
-			return $parameter->isFlagSet(DefinitionParameter::FLAG_HIDDEN);
98
-		});
99
-		return array_map(function (DefinitionParameter $parameter) {
100
-			return $parameter->getTypeName();
101
-		}, $configuration);
102
-	}
91
+    /**
92
+     * @param DefinitionParameter[] $parameters
93
+     * @return string[]
94
+     */
95
+    private function formatConfiguration(array $parameters): array {
96
+        $configuration = array_filter($parameters, function (DefinitionParameter $parameter) {
97
+            return $parameter->isFlagSet(DefinitionParameter::FLAG_HIDDEN);
98
+        });
99
+        return array_map(function (DefinitionParameter $parameter) {
100
+            return $parameter->getTypeName();
101
+        }, $configuration);
102
+    }
103 103
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
51 51
 		$backend = $input->getArgument('backend');
52 52
 		if ($type) {
53 53
 			if (!isset($data[$type])) {
54
-				$output->writeln('<error>Invalid type "' . $type . '". Possible values are "authentication" or "storage"</error>');
54
+				$output->writeln('<error>Invalid type "'.$type.'". Possible values are "authentication" or "storage"</error>');
55 55
 				return self::FAILURE;
56 56
 			}
57 57
 			$data = $data[$type];
58 58
 
59 59
 			if ($backend) {
60 60
 				if (!isset($data[$backend])) {
61
-					$output->writeln('<error>Unknown backend "' . $backend . '" of type  "' . $type . '"</error>');
61
+					$output->writeln('<error>Unknown backend "'.$backend.'" of type  "'.$type.'"</error>');
62 62
 					return self::FAILURE;
63 63
 				}
64 64
 				$data = $data[$backend];
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 			$result['storage_class'] = $backend->getStorageClass();
81 81
 			$authBackends = $this->backendService->getAuthMechanismsByScheme(array_keys($backend->getAuthSchemes()));
82 82
 			$result['supported_authentication_backends'] = array_keys($authBackends);
83
-			$authConfig = array_map(function (AuthMechanism $auth) {
83
+			$authConfig = array_map(function(AuthMechanism $auth) {
84 84
 				return $this->serializeAuthBackend($auth)['configuration'];
85 85
 			}, $authBackends);
86 86
 			$result['authentication_configuration'] = array_combine(array_keys($authBackends), $authConfig);
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 	 * @return string[]
94 94
 	 */
95 95
 	private function formatConfiguration(array $parameters): array {
96
-		$configuration = array_filter($parameters, function (DefinitionParameter $parameter) {
96
+		$configuration = array_filter($parameters, function(DefinitionParameter $parameter) {
97 97
 			return $parameter->isFlagSet(DefinitionParameter::FLAG_HIDDEN);
98 98
 		});
99
-		return array_map(function (DefinitionParameter $parameter) {
99
+		return array_map(function(DefinitionParameter $parameter) {
100 100
 			return $parameter->getTypeName();
101 101
 		}, $configuration);
102 102
 	}
Please login to merge, or discard this patch.