Completed
Push — master ( f3c25e...711d86 )
by Morris
43:14 queued 27:18
created
apps/files_external/lib/Lib/Auth/PublicKey/RSA.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@
 block discarded – undo
69 69
 	/**
70 70
 	 * Generate a keypair
71 71
 	 *
72
-	 * @param int $keyLenth
72
+	 * @param integer $keyLength
73 73
 	 * @return array ['privatekey' => $privateKey, 'publickey' => $publicKey]
74 74
 	 */
75 75
 	public function createKey($keyLength) {
Please login to merge, or discard this patch.
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -35,51 +35,51 @@
 block discarded – undo
35 35
  */
36 36
 class RSA extends AuthMechanism {
37 37
 
38
-	/** @var IConfig */
39
-	private $config;
38
+    /** @var IConfig */
39
+    private $config;
40 40
 
41
-	public function __construct(IL10N $l, IConfig $config) {
42
-		$this->config = $config;
41
+    public function __construct(IL10N $l, IConfig $config) {
42
+        $this->config = $config;
43 43
 
44
-		$this
45
-			->setIdentifier('publickey::rsa')
46
-			->setScheme(self::SCHEME_PUBLICKEY)
47
-			->setText($l->t('RSA public key'))
48
-			->addParameters([
49
-				(new DefinitionParameter('user', $l->t('Username'))),
50
-				(new DefinitionParameter('public_key', $l->t('Public key'))),
51
-				(new DefinitionParameter('private_key', 'private_key'))
52
-					->setType(DefinitionParameter::VALUE_HIDDEN),
53
-			])
54
-			->addCustomJs('public_key')
55
-		;
56
-	}
44
+        $this
45
+            ->setIdentifier('publickey::rsa')
46
+            ->setScheme(self::SCHEME_PUBLICKEY)
47
+            ->setText($l->t('RSA public key'))
48
+            ->addParameters([
49
+                (new DefinitionParameter('user', $l->t('Username'))),
50
+                (new DefinitionParameter('public_key', $l->t('Public key'))),
51
+                (new DefinitionParameter('private_key', 'private_key'))
52
+                    ->setType(DefinitionParameter::VALUE_HIDDEN),
53
+            ])
54
+            ->addCustomJs('public_key')
55
+        ;
56
+    }
57 57
 
58
-	public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
59
-		$auth = new RSACrypt();
60
-		$auth->setPassword($this->config->getSystemValue('secret', ''));
61
-		if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
62
-			throw new \RuntimeException('unable to load private key');
63
-		}
64
-		$storage->setBackendOption('public_key_auth', $auth);
65
-	}
58
+    public function manipulateStorageConfig(StorageConfig &$storage, IUser $user = null) {
59
+        $auth = new RSACrypt();
60
+        $auth->setPassword($this->config->getSystemValue('secret', ''));
61
+        if (!$auth->loadKey($storage->getBackendOption('private_key'))) {
62
+            throw new \RuntimeException('unable to load private key');
63
+        }
64
+        $storage->setBackendOption('public_key_auth', $auth);
65
+    }
66 66
 
67
-	/**
68
-	 * Generate a keypair
69
-	 *
70
-	 * @param int $keyLenth
71
-	 * @return array ['privatekey' => $privateKey, 'publickey' => $publicKey]
72
-	 */
73
-	public function createKey($keyLength) {
74
-		$rsa = new RSACrypt();
75
-		$rsa->setPublicKeyFormat(RSACrypt::PUBLIC_FORMAT_OPENSSH);
76
-		$rsa->setPassword($this->config->getSystemValue('secret', ''));
67
+    /**
68
+     * Generate a keypair
69
+     *
70
+     * @param int $keyLenth
71
+     * @return array ['privatekey' => $privateKey, 'publickey' => $publicKey]
72
+     */
73
+    public function createKey($keyLength) {
74
+        $rsa = new RSACrypt();
75
+        $rsa->setPublicKeyFormat(RSACrypt::PUBLIC_FORMAT_OPENSSH);
76
+        $rsa->setPassword($this->config->getSystemValue('secret', ''));
77 77
 
78
-		if ($keyLength !== 1024 && $keyLength !== 2048 && $keyLength !== 4096) {
79
-			$keyLength = 1024;
80
-		}
78
+        if ($keyLength !== 1024 && $keyLength !== 2048 && $keyLength !== 4096) {
79
+            $keyLength = 1024;
80
+        }
81 81
 
82
-		return $rsa->createKey($keyLength);
83
-	}
82
+        return $rsa->createKey($keyLength);
83
+    }
84 84
 
85 85
 }
Please login to merge, or discard this patch.
apps/files_external/lib/Controller/AjaxController.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -37,86 +37,86 @@
 block discarded – undo
37 37
 use OCP\IUserSession;
38 38
 
39 39
 class AjaxController extends Controller {
40
-	/** @var RSA */
41
-	private $rsaMechanism;
42
-	/** @var GlobalAuth  */
43
-	private $globalAuth;
44
-	/** @var IUserSession */
45
-	private $userSession;
46
-	/** @var IGroupManager */
47
-	private $groupManager;
40
+    /** @var RSA */
41
+    private $rsaMechanism;
42
+    /** @var GlobalAuth  */
43
+    private $globalAuth;
44
+    /** @var IUserSession */
45
+    private $userSession;
46
+    /** @var IGroupManager */
47
+    private $groupManager;
48 48
 
49
-	/**
50
-	 * @param string $appName
51
-	 * @param IRequest $request
52
-	 * @param RSA $rsaMechanism
53
-	 * @param GlobalAuth $globalAuth
54
-	 * @param IUserSession $userSession
55
-	 * @param IGroupManager $groupManager
56
-	 */
57
-	public function __construct($appName,
58
-								IRequest $request,
59
-								RSA $rsaMechanism,
60
-								GlobalAuth $globalAuth,
61
-								IUserSession $userSession,
62
-								IGroupManager $groupManager) {
63
-		parent::__construct($appName, $request);
64
-		$this->rsaMechanism = $rsaMechanism;
65
-		$this->globalAuth = $globalAuth;
66
-		$this->userSession = $userSession;
67
-		$this->groupManager = $groupManager;
68
-	}
49
+    /**
50
+     * @param string $appName
51
+     * @param IRequest $request
52
+     * @param RSA $rsaMechanism
53
+     * @param GlobalAuth $globalAuth
54
+     * @param IUserSession $userSession
55
+     * @param IGroupManager $groupManager
56
+     */
57
+    public function __construct($appName,
58
+                                IRequest $request,
59
+                                RSA $rsaMechanism,
60
+                                GlobalAuth $globalAuth,
61
+                                IUserSession $userSession,
62
+                                IGroupManager $groupManager) {
63
+        parent::__construct($appName, $request);
64
+        $this->rsaMechanism = $rsaMechanism;
65
+        $this->globalAuth = $globalAuth;
66
+        $this->userSession = $userSession;
67
+        $this->groupManager = $groupManager;
68
+    }
69 69
 
70
-	/**
71
-	 * @param int $keyLength
72
-	 * @return array
73
-	 */
74
-	private function generateSshKeys($keyLength) {
75
-		$key = $this->rsaMechanism->createKey($keyLength);
76
-		// Replace the placeholder label with a more meaningful one
77
-		$key['publickey'] = str_replace('phpseclib-generated-key', gethostname(), $key['publickey']);
70
+    /**
71
+     * @param int $keyLength
72
+     * @return array
73
+     */
74
+    private function generateSshKeys($keyLength) {
75
+        $key = $this->rsaMechanism->createKey($keyLength);
76
+        // Replace the placeholder label with a more meaningful one
77
+        $key['publickey'] = str_replace('phpseclib-generated-key', gethostname(), $key['publickey']);
78 78
 
79
-		return $key;
80
-	}
79
+        return $key;
80
+    }
81 81
 
82
-	/**
83
-	 * Generates an SSH public/private key pair.
84
-	 *
85
-	 * @NoAdminRequired
86
-	 * @param int $keyLength
87
-	 */
88
-	public function getSshKeys($keyLength = 1024) {
89
-		$key = $this->generateSshKeys($keyLength);
90
-		return new JSONResponse(
91
-			array('data' => array(
92
-				'private_key' => $key['privatekey'],
93
-				'public_key' => $key['publickey']
94
-			),
95
-			'status' => 'success'
96
-		));
97
-	}
82
+    /**
83
+     * Generates an SSH public/private key pair.
84
+     *
85
+     * @NoAdminRequired
86
+     * @param int $keyLength
87
+     */
88
+    public function getSshKeys($keyLength = 1024) {
89
+        $key = $this->generateSshKeys($keyLength);
90
+        return new JSONResponse(
91
+            array('data' => array(
92
+                'private_key' => $key['privatekey'],
93
+                'public_key' => $key['publickey']
94
+            ),
95
+            'status' => 'success'
96
+        ));
97
+    }
98 98
 
99
-	/**
100
-	 * @NoAdminRequired
101
-	 *
102
-	 * @param string $uid
103
-	 * @param string $user
104
-	 * @param string $password
105
-	 * @return bool
106
-	 */
107
-	public function saveGlobalCredentials($uid, $user, $password) {
108
-		$currentUser = $this->userSession->getUser();
99
+    /**
100
+     * @NoAdminRequired
101
+     *
102
+     * @param string $uid
103
+     * @param string $user
104
+     * @param string $password
105
+     * @return bool
106
+     */
107
+    public function saveGlobalCredentials($uid, $user, $password) {
108
+        $currentUser = $this->userSession->getUser();
109 109
 
110
-		// Non-admins can only edit their own credentials
111
-		$allowedToEdit = (
112
-			$this->groupManager->isAdmin($currentUser->getUID()) || $currentUser->getUID() === $uid
113
-		) ? true : false;
110
+        // Non-admins can only edit their own credentials
111
+        $allowedToEdit = (
112
+            $this->groupManager->isAdmin($currentUser->getUID()) || $currentUser->getUID() === $uid
113
+        ) ? true : false;
114 114
 
115
-		if ($allowedToEdit) {
116
-			$this->globalAuth->saveAuth($uid, $user, $password);
117
-			return true;
118
-		} else {
119
-			return false;
120
-		}
121
-	}
115
+        if ($allowedToEdit) {
116
+            $this->globalAuth->saveAuth($uid, $user, $password);
117
+            return true;
118
+        } else {
119
+            return false;
120
+        }
121
+    }
122 122
 }
Please login to merge, or discard this patch.