Completed
Push — stable13 ( 8a0ced...f67879 )
by
unknown
23:00 queued 11:14
created
core/Command/Security/ImportCertificate.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -33,36 +33,36 @@
 block discarded – undo
33 33
 
34 34
 class ImportCertificate extends Base {
35 35
 
36
-	/** @var ICertificateManager */
37
-	protected $certificateManager;
36
+    /** @var ICertificateManager */
37
+    protected $certificateManager;
38 38
 
39
-	public function __construct(ICertificateManager $certificateManager) {
40
-		$this->certificateManager = $certificateManager;
41
-		parent::__construct();
42
-	}
39
+    public function __construct(ICertificateManager $certificateManager) {
40
+        $this->certificateManager = $certificateManager;
41
+        parent::__construct();
42
+    }
43 43
 
44
-	protected function configure() {
45
-		$this
46
-			->setName('security:certificates:import')
47
-			->setDescription('import trusted certificate')
48
-			->addArgument(
49
-				'path',
50
-				InputArgument::REQUIRED,
51
-				'path to the certificate to import'
52
-			);
53
-	}
44
+    protected function configure() {
45
+        $this
46
+            ->setName('security:certificates:import')
47
+            ->setDescription('import trusted certificate')
48
+            ->addArgument(
49
+                'path',
50
+                InputArgument::REQUIRED,
51
+                'path to the certificate to import'
52
+            );
53
+    }
54 54
 
55
-	protected function execute(InputInterface $input, OutputInterface $output) {
56
-		$path = $input->getArgument('path');
55
+    protected function execute(InputInterface $input, OutputInterface $output) {
56
+        $path = $input->getArgument('path');
57 57
 
58
-		if (!file_exists($path)) {
59
-			$output->writeln('<error>certificate not found</error>');
60
-			return;
61
-		}
58
+        if (!file_exists($path)) {
59
+            $output->writeln('<error>certificate not found</error>');
60
+            return;
61
+        }
62 62
 
63
-		$certData = file_get_contents($path);
64
-		$name = basename($path);
63
+        $certData = file_get_contents($path);
64
+        $name = basename($path);
65 65
 
66
-		$this->certificateManager->addCertificate($certData, $name);
67
-	}
66
+        $this->certificateManager->addCertificate($certData, $name);
67
+    }
68 68
 }
Please login to merge, or discard this patch.
core/Command/Log/Manage.php 1 patch
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -34,167 +34,167 @@
 block discarded – undo
34 34
 
35 35
 class Manage extends Command implements CompletionAwareInterface {
36 36
 
37
-	const DEFAULT_BACKEND = 'file';
38
-	const DEFAULT_LOG_LEVEL = 2;
39
-	const DEFAULT_TIMEZONE = 'UTC';
40
-
41
-	/** @var IConfig */
42
-	protected $config;
43
-
44
-	public function __construct(IConfig $config) {
45
-		$this->config = $config;
46
-		parent::__construct();
47
-	}
48
-
49
-	protected function configure() {
50
-		$this
51
-			->setName('log:manage')
52
-			->setDescription('manage logging configuration')
53
-			->addOption(
54
-				'backend',
55
-				null,
56
-				InputOption::VALUE_REQUIRED,
57
-				'set the logging backend [file, syslog, errorlog]'
58
-			)
59
-			->addOption(
60
-				'level',
61
-				null,
62
-				InputOption::VALUE_REQUIRED,
63
-				'set the log level [debug, info, warning, error]'
64
-			)
65
-			->addOption(
66
-				'timezone',
67
-				null,
68
-				InputOption::VALUE_REQUIRED,
69
-				'set the logging timezone'
70
-			)
71
-		;
72
-	}
73
-
74
-	protected function execute(InputInterface $input, OutputInterface $output) {
75
-		// collate config setting to the end, to avoid partial configuration
76
-		$toBeSet = [];
77
-
78
-		if ($backend = $input->getOption('backend')) {
79
-			$this->validateBackend($backend);
80
-			$toBeSet['log_type'] = $backend;
81
-		}
82
-
83
-		$level = $input->getOption('level');
84
-		if ($level !== null) {
85
-			if (is_numeric($level)) {
86
-				$levelNum = $level;
87
-				// sanity check
88
-				$this->convertLevelNumber($levelNum);
89
-			} else {
90
-				$levelNum = $this->convertLevelString($level);
91
-			}
92
-			$toBeSet['loglevel'] = $levelNum;
93
-		}
94
-
95
-		if ($timezone = $input->getOption('timezone')) {
96
-			$this->validateTimezone($timezone);
97
-			$toBeSet['logtimezone'] = $timezone;
98
-		}
99
-
100
-		// set config
101
-		foreach ($toBeSet as $option => $value) {
102
-			$this->config->setSystemValue($option, $value);
103
-		}
104
-
105
-		// display configuration
106
-		$backend = $this->config->getSystemValue('log_type', self::DEFAULT_BACKEND);
107
-		$output->writeln('Enabled logging backend: '.$backend);
108
-
109
-		$levelNum = $this->config->getSystemValue('loglevel', self::DEFAULT_LOG_LEVEL);
110
-		$level = $this->convertLevelNumber($levelNum);
111
-		$output->writeln('Log level: '.$level.' ('.$levelNum.')');
112
-
113
-		$timezone = $this->config->getSystemValue('logtimezone', self::DEFAULT_TIMEZONE);
114
-		$output->writeln('Log timezone: '.$timezone);
115
-	}
116
-
117
-	/**
118
-	 * @param string $backend
119
-	 * @throws \InvalidArgumentException
120
-	 */
121
-	protected function validateBackend($backend) {
122
-		if (!class_exists('OC\\Log\\'.ucfirst($backend))) {
123
-			throw new \InvalidArgumentException('Invalid backend');
124
-		}
125
-	}
126
-
127
-	/**
128
-	 * @param string $timezone
129
-	 * @throws \Exception
130
-	 */
131
-	protected function validateTimezone($timezone) {
132
-		new \DateTimeZone($timezone);
133
-	}
134
-
135
-	/**
136
-	 * @param string $level
137
-	 * @return int
138
-	 * @throws \InvalidArgumentException
139
-	 */
140
-	protected function convertLevelString($level) {
141
-		$level = strtolower($level);
142
-		switch ($level) {
143
-		case 'debug':
144
-			return 0;
145
-		case 'info':
146
-			return 1;
147
-		case 'warning':
148
-		case 'warn':
149
-			return 2;
150
-		case 'error':
151
-		case 'err':
152
-			return 3;
153
-		}
154
-		throw new \InvalidArgumentException('Invalid log level string');
155
-	}
156
-
157
-	/**
158
-	 * @param int $levelNum
159
-	 * @return string
160
-	 * @throws \InvalidArgumentException
161
-	 */
162
-	protected function convertLevelNumber($levelNum) {
163
-		switch ($levelNum) {
164
-		case 0:
165
-			return 'Debug';
166
-		case 1:
167
-			return 'Info';
168
-		case 2:
169
-			return 'Warning';
170
-		case 3:
171
-			return 'Error';
172
-		}
173
-		throw new \InvalidArgumentException('Invalid log level number');
174
-	}
175
-
176
-	/**
177
-	 * @param string $optionName
178
-	 * @param CompletionContext $context
179
-	 * @return string[]
180
-	 */
181
-	public function completeOptionValues($optionName, CompletionContext $context) {
182
-		if ($optionName === 'backend') {
183
-			return ['file', 'syslog', 'errorlog'];
184
-		} else if ($optionName === 'level') {
185
-			return ['debug', 'info', 'warning', 'error'];
186
-		} else if ($optionName === 'timezone') {
187
-			return \DateTimeZone::listIdentifiers();
188
-		}
189
-		return [];
190
-	}
191
-
192
-	/**
193
-	 * @param string $argumentName
194
-	 * @param CompletionContext $context
195
-	 * @return string[]
196
-	 */
197
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
198
-		return [];
199
-	}
37
+    const DEFAULT_BACKEND = 'file';
38
+    const DEFAULT_LOG_LEVEL = 2;
39
+    const DEFAULT_TIMEZONE = 'UTC';
40
+
41
+    /** @var IConfig */
42
+    protected $config;
43
+
44
+    public function __construct(IConfig $config) {
45
+        $this->config = $config;
46
+        parent::__construct();
47
+    }
48
+
49
+    protected function configure() {
50
+        $this
51
+            ->setName('log:manage')
52
+            ->setDescription('manage logging configuration')
53
+            ->addOption(
54
+                'backend',
55
+                null,
56
+                InputOption::VALUE_REQUIRED,
57
+                'set the logging backend [file, syslog, errorlog]'
58
+            )
59
+            ->addOption(
60
+                'level',
61
+                null,
62
+                InputOption::VALUE_REQUIRED,
63
+                'set the log level [debug, info, warning, error]'
64
+            )
65
+            ->addOption(
66
+                'timezone',
67
+                null,
68
+                InputOption::VALUE_REQUIRED,
69
+                'set the logging timezone'
70
+            )
71
+        ;
72
+    }
73
+
74
+    protected function execute(InputInterface $input, OutputInterface $output) {
75
+        // collate config setting to the end, to avoid partial configuration
76
+        $toBeSet = [];
77
+
78
+        if ($backend = $input->getOption('backend')) {
79
+            $this->validateBackend($backend);
80
+            $toBeSet['log_type'] = $backend;
81
+        }
82
+
83
+        $level = $input->getOption('level');
84
+        if ($level !== null) {
85
+            if (is_numeric($level)) {
86
+                $levelNum = $level;
87
+                // sanity check
88
+                $this->convertLevelNumber($levelNum);
89
+            } else {
90
+                $levelNum = $this->convertLevelString($level);
91
+            }
92
+            $toBeSet['loglevel'] = $levelNum;
93
+        }
94
+
95
+        if ($timezone = $input->getOption('timezone')) {
96
+            $this->validateTimezone($timezone);
97
+            $toBeSet['logtimezone'] = $timezone;
98
+        }
99
+
100
+        // set config
101
+        foreach ($toBeSet as $option => $value) {
102
+            $this->config->setSystemValue($option, $value);
103
+        }
104
+
105
+        // display configuration
106
+        $backend = $this->config->getSystemValue('log_type', self::DEFAULT_BACKEND);
107
+        $output->writeln('Enabled logging backend: '.$backend);
108
+
109
+        $levelNum = $this->config->getSystemValue('loglevel', self::DEFAULT_LOG_LEVEL);
110
+        $level = $this->convertLevelNumber($levelNum);
111
+        $output->writeln('Log level: '.$level.' ('.$levelNum.')');
112
+
113
+        $timezone = $this->config->getSystemValue('logtimezone', self::DEFAULT_TIMEZONE);
114
+        $output->writeln('Log timezone: '.$timezone);
115
+    }
116
+
117
+    /**
118
+     * @param string $backend
119
+     * @throws \InvalidArgumentException
120
+     */
121
+    protected function validateBackend($backend) {
122
+        if (!class_exists('OC\\Log\\'.ucfirst($backend))) {
123
+            throw new \InvalidArgumentException('Invalid backend');
124
+        }
125
+    }
126
+
127
+    /**
128
+     * @param string $timezone
129
+     * @throws \Exception
130
+     */
131
+    protected function validateTimezone($timezone) {
132
+        new \DateTimeZone($timezone);
133
+    }
134
+
135
+    /**
136
+     * @param string $level
137
+     * @return int
138
+     * @throws \InvalidArgumentException
139
+     */
140
+    protected function convertLevelString($level) {
141
+        $level = strtolower($level);
142
+        switch ($level) {
143
+        case 'debug':
144
+            return 0;
145
+        case 'info':
146
+            return 1;
147
+        case 'warning':
148
+        case 'warn':
149
+            return 2;
150
+        case 'error':
151
+        case 'err':
152
+            return 3;
153
+        }
154
+        throw new \InvalidArgumentException('Invalid log level string');
155
+    }
156
+
157
+    /**
158
+     * @param int $levelNum
159
+     * @return string
160
+     * @throws \InvalidArgumentException
161
+     */
162
+    protected function convertLevelNumber($levelNum) {
163
+        switch ($levelNum) {
164
+        case 0:
165
+            return 'Debug';
166
+        case 1:
167
+            return 'Info';
168
+        case 2:
169
+            return 'Warning';
170
+        case 3:
171
+            return 'Error';
172
+        }
173
+        throw new \InvalidArgumentException('Invalid log level number');
174
+    }
175
+
176
+    /**
177
+     * @param string $optionName
178
+     * @param CompletionContext $context
179
+     * @return string[]
180
+     */
181
+    public function completeOptionValues($optionName, CompletionContext $context) {
182
+        if ($optionName === 'backend') {
183
+            return ['file', 'syslog', 'errorlog'];
184
+        } else if ($optionName === 'level') {
185
+            return ['debug', 'info', 'warning', 'error'];
186
+        } else if ($optionName === 'timezone') {
187
+            return \DateTimeZone::listIdentifiers();
188
+        }
189
+        return [];
190
+    }
191
+
192
+    /**
193
+     * @param string $argumentName
194
+     * @param CompletionContext $context
195
+     * @return string[]
196
+     */
197
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
198
+        return [];
199
+    }
200 200
 }
Please login to merge, or discard this patch.
core/Command/Log/File.php 1 patch
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -35,123 +35,123 @@
 block discarded – undo
35 35
 
36 36
 class File extends Command implements Completion\CompletionAwareInterface {
37 37
 
38
-	/** @var IConfig */
39
-	protected $config;
40
-
41
-	public function __construct(IConfig $config) {
42
-		$this->config = $config;
43
-		parent::__construct();
44
-	}
45
-
46
-	protected function configure() {
47
-		$this
48
-			->setName('log:file')
49
-			->setDescription('manipulate logging backend')
50
-			->addOption(
51
-				'enable',
52
-				null,
53
-				InputOption::VALUE_NONE,
54
-				'enable this logging backend'
55
-			)
56
-			->addOption(
57
-				'file',
58
-				null,
59
-				InputOption::VALUE_REQUIRED,
60
-				'set the log file path'
61
-			)
62
-			->addOption(
63
-				'rotate-size',
64
-				null,
65
-				InputOption::VALUE_REQUIRED,
66
-				'set the file size for log rotation, 0 = disabled'
67
-			)
68
-		;
69
-	}
70
-
71
-	protected function execute(InputInterface $input, OutputInterface $output) {
72
-		$toBeSet = [];
73
-
74
-		if ($input->getOption('enable')) {
75
-			$toBeSet['log_type'] = 'file';
76
-		}
77
-
78
-		if ($file = $input->getOption('file')) {
79
-			$toBeSet['logfile'] = $file;
80
-		}
81
-
82
-		if (($rotateSize = $input->getOption('rotate-size')) !== null) {
83
-			$rotateSize = \OCP\Util::computerFileSize($rotateSize);
84
-			$this->validateRotateSize($rotateSize);
85
-			$toBeSet['log_rotate_size'] = $rotateSize;
86
-		}
87
-
88
-		// set config
89
-		foreach ($toBeSet as $option => $value) {
90
-			$this->config->setSystemValue($option, $value);
91
-		}
92
-
93
-		// display config
94
-		// TODO: Drop backwards compatibility for config in the future
95
-		$logType = $this->config->getSystemValue('log_type', 'file');
96
-		if ($logType === 'file' || $logType === 'owncloud') {
97
-			$enabledText = 'enabled';
98
-		} else {
99
-			$enabledText = 'disabled';
100
-		}
101
-		$output->writeln('Log backend file: '.$enabledText);
102
-
103
-		$dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
104
-		$defaultLogFile = rtrim($dataDir, '/').'/nextcloud.log';
105
-		$output->writeln('Log file: '.$this->config->getSystemValue('logfile', $defaultLogFile));
106
-
107
-		$rotateSize = $this->config->getSystemValue('log_rotate_size', 0);
108
-		if ($rotateSize) {
109
-			$rotateString = \OCP\Util::humanFileSize($rotateSize);
110
-		} else {
111
-			$rotateString = 'disabled';
112
-		}
113
-		$output->writeln('Rotate at: '.$rotateString);
114
-	}
115
-
116
-	/**
117
-	 * @param mixed $rotateSize
118
-	 * @throws \InvalidArgumentException
119
-	 */
120
-	protected function validateRotateSize(&$rotateSize) {
121
-		if ($rotateSize === false) {
122
-			throw new \InvalidArgumentException('Error parsing log rotation file size');
123
-		}
124
-		$rotateSize = (int) $rotateSize;
125
-		if ($rotateSize < 0) {
126
-			throw new \InvalidArgumentException('Log rotation file size must be non-negative');
127
-		}
128
-	}
129
-
130
-	/**
131
-	 * @param string $optionName
132
-	 * @param CompletionContext $context
133
-	 * @return string[]
134
-	 */
135
-	public function completeOptionValues($optionName, CompletionContext $context) {
136
-		if ($optionName === 'file') {
137
-			$helper = new ShellPathCompletion(
138
-				$this->getName(),
139
-				'file',
140
-				Completion::TYPE_OPTION
141
-			);
142
-			return $helper->run();
143
-		} else if ($optionName === 'rotate-size') {
144
-			return [0];
145
-		}
146
-		return [];
147
-	}
148
-
149
-	/**
150
-	 * @param string $argumentName
151
-	 * @param CompletionContext $context
152
-	 * @return string[]
153
-	 */
154
-	public function completeArgumentValues($argumentName, CompletionContext $context) {
155
-		return [];
156
-	}
38
+    /** @var IConfig */
39
+    protected $config;
40
+
41
+    public function __construct(IConfig $config) {
42
+        $this->config = $config;
43
+        parent::__construct();
44
+    }
45
+
46
+    protected function configure() {
47
+        $this
48
+            ->setName('log:file')
49
+            ->setDescription('manipulate logging backend')
50
+            ->addOption(
51
+                'enable',
52
+                null,
53
+                InputOption::VALUE_NONE,
54
+                'enable this logging backend'
55
+            )
56
+            ->addOption(
57
+                'file',
58
+                null,
59
+                InputOption::VALUE_REQUIRED,
60
+                'set the log file path'
61
+            )
62
+            ->addOption(
63
+                'rotate-size',
64
+                null,
65
+                InputOption::VALUE_REQUIRED,
66
+                'set the file size for log rotation, 0 = disabled'
67
+            )
68
+        ;
69
+    }
70
+
71
+    protected function execute(InputInterface $input, OutputInterface $output) {
72
+        $toBeSet = [];
73
+
74
+        if ($input->getOption('enable')) {
75
+            $toBeSet['log_type'] = 'file';
76
+        }
77
+
78
+        if ($file = $input->getOption('file')) {
79
+            $toBeSet['logfile'] = $file;
80
+        }
81
+
82
+        if (($rotateSize = $input->getOption('rotate-size')) !== null) {
83
+            $rotateSize = \OCP\Util::computerFileSize($rotateSize);
84
+            $this->validateRotateSize($rotateSize);
85
+            $toBeSet['log_rotate_size'] = $rotateSize;
86
+        }
87
+
88
+        // set config
89
+        foreach ($toBeSet as $option => $value) {
90
+            $this->config->setSystemValue($option, $value);
91
+        }
92
+
93
+        // display config
94
+        // TODO: Drop backwards compatibility for config in the future
95
+        $logType = $this->config->getSystemValue('log_type', 'file');
96
+        if ($logType === 'file' || $logType === 'owncloud') {
97
+            $enabledText = 'enabled';
98
+        } else {
99
+            $enabledText = 'disabled';
100
+        }
101
+        $output->writeln('Log backend file: '.$enabledText);
102
+
103
+        $dataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data');
104
+        $defaultLogFile = rtrim($dataDir, '/').'/nextcloud.log';
105
+        $output->writeln('Log file: '.$this->config->getSystemValue('logfile', $defaultLogFile));
106
+
107
+        $rotateSize = $this->config->getSystemValue('log_rotate_size', 0);
108
+        if ($rotateSize) {
109
+            $rotateString = \OCP\Util::humanFileSize($rotateSize);
110
+        } else {
111
+            $rotateString = 'disabled';
112
+        }
113
+        $output->writeln('Rotate at: '.$rotateString);
114
+    }
115
+
116
+    /**
117
+     * @param mixed $rotateSize
118
+     * @throws \InvalidArgumentException
119
+     */
120
+    protected function validateRotateSize(&$rotateSize) {
121
+        if ($rotateSize === false) {
122
+            throw new \InvalidArgumentException('Error parsing log rotation file size');
123
+        }
124
+        $rotateSize = (int) $rotateSize;
125
+        if ($rotateSize < 0) {
126
+            throw new \InvalidArgumentException('Log rotation file size must be non-negative');
127
+        }
128
+    }
129
+
130
+    /**
131
+     * @param string $optionName
132
+     * @param CompletionContext $context
133
+     * @return string[]
134
+     */
135
+    public function completeOptionValues($optionName, CompletionContext $context) {
136
+        if ($optionName === 'file') {
137
+            $helper = new ShellPathCompletion(
138
+                $this->getName(),
139
+                'file',
140
+                Completion::TYPE_OPTION
141
+            );
142
+            return $helper->run();
143
+        } else if ($optionName === 'rotate-size') {
144
+            return [0];
145
+        }
146
+        return [];
147
+    }
148
+
149
+    /**
150
+     * @param string $argumentName
151
+     * @param CompletionContext $context
152
+     * @return string[]
153
+     */
154
+    public function completeArgumentValues($argumentName, CompletionContext $context) {
155
+        return [];
156
+    }
157 157
 }
Please login to merge, or discard this patch.
core/Command/Integrity/CheckApp.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -36,39 +36,39 @@
 block discarded – undo
36 36
  */
37 37
 class CheckApp extends Base {
38 38
 
39
-	/**
40
-	 * @var Checker
41
-	 */
42
-	private $checker;
39
+    /**
40
+     * @var Checker
41
+     */
42
+    private $checker;
43 43
 
44
-	public function __construct(Checker $checker) {
45
-		parent::__construct();
46
-		$this->checker = $checker;
47
-	}
44
+    public function __construct(Checker $checker) {
45
+        parent::__construct();
46
+        $this->checker = $checker;
47
+    }
48 48
 	
49
-	/**
50
-	 * {@inheritdoc }
51
-	 */
52
-	protected function configure() {
53
-		parent::configure();
54
-		$this
55
-			->setName('integrity:check-app')
56
-			->setDescription('Check integrity of an app using a signature.')
57
-			->addArgument('appid', null, InputArgument::REQUIRED, 'Application to check')
58
-			->addOption('path', null, InputOption::VALUE_OPTIONAL, 'Path to application. If none is given it will be guessed.');
59
-	}
49
+    /**
50
+     * {@inheritdoc }
51
+     */
52
+    protected function configure() {
53
+        parent::configure();
54
+        $this
55
+            ->setName('integrity:check-app')
56
+            ->setDescription('Check integrity of an app using a signature.')
57
+            ->addArgument('appid', null, InputArgument::REQUIRED, 'Application to check')
58
+            ->addOption('path', null, InputOption::VALUE_OPTIONAL, 'Path to application. If none is given it will be guessed.');
59
+    }
60 60
 
61
-	/**
62
-	 * {@inheritdoc }
63
-	 */
64
-	protected function execute(InputInterface $input, OutputInterface $output) {
65
-		$appid = $input->getArgument('appid');
66
-		$path = strval($input->getOption('path'));
67
-		$result = $this->checker->verifyAppSignature($appid, $path);
68
-		$this->writeArrayInOutputFormat($input, $output, $result);
69
-		if (count($result)>0){
70
-			return 1;
71
-		}
72
-	}
61
+    /**
62
+     * {@inheritdoc }
63
+     */
64
+    protected function execute(InputInterface $input, OutputInterface $output) {
65
+        $appid = $input->getArgument('appid');
66
+        $path = strval($input->getOption('path'));
67
+        $result = $this->checker->verifyAppSignature($appid, $path);
68
+        $this->writeArrayInOutputFormat($input, $output, $result);
69
+        if (count($result)>0){
70
+            return 1;
71
+        }
72
+    }
73 73
 
74 74
 }
Please login to merge, or discard this patch.
core/Command/Integrity/SignCore.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -37,69 +37,69 @@
 block discarded – undo
37 37
  * @package OC\Core\Command\Integrity
38 38
  */
39 39
 class SignCore extends Command {
40
-	/** @var Checker */
41
-	private $checker;
42
-	/** @var FileAccessHelper */
43
-	private $fileAccessHelper;
40
+    /** @var Checker */
41
+    private $checker;
42
+    /** @var FileAccessHelper */
43
+    private $fileAccessHelper;
44 44
 
45
-	/**
46
-	 * @param Checker $checker
47
-	 * @param FileAccessHelper $fileAccessHelper
48
-	 */
49
-	public function __construct(Checker $checker,
50
-								FileAccessHelper $fileAccessHelper) {
51
-		parent::__construct(null);
52
-		$this->checker = $checker;
53
-		$this->fileAccessHelper = $fileAccessHelper;
54
-	}
45
+    /**
46
+     * @param Checker $checker
47
+     * @param FileAccessHelper $fileAccessHelper
48
+     */
49
+    public function __construct(Checker $checker,
50
+                                FileAccessHelper $fileAccessHelper) {
51
+        parent::__construct(null);
52
+        $this->checker = $checker;
53
+        $this->fileAccessHelper = $fileAccessHelper;
54
+    }
55 55
 
56
-	protected function configure() {
57
-		$this
58
-			->setName('integrity:sign-core')
59
-			->setDescription('Sign core using a private key.')
60
-			->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing')
61
-			->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing')
62
-			->addOption('path', null, InputOption::VALUE_REQUIRED, 'Path of core to sign');
63
-	}
56
+    protected function configure() {
57
+        $this
58
+            ->setName('integrity:sign-core')
59
+            ->setDescription('Sign core using a private key.')
60
+            ->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing')
61
+            ->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing')
62
+            ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Path of core to sign');
63
+    }
64 64
 
65
-	/**
66
-	 * {@inheritdoc }
67
-	 */
68
-	protected function execute(InputInterface $input, OutputInterface $output) {
69
-		$privateKeyPath = $input->getOption('privateKey');
70
-		$keyBundlePath = $input->getOption('certificate');
71
-		$path = $input->getOption('path');
72
-		if(is_null($privateKeyPath) || is_null($keyBundlePath) || is_null($path)) {
73
-			$output->writeln('--privateKey, --certificate and --path are required.');
74
-			return null;
75
-		}
65
+    /**
66
+     * {@inheritdoc }
67
+     */
68
+    protected function execute(InputInterface $input, OutputInterface $output) {
69
+        $privateKeyPath = $input->getOption('privateKey');
70
+        $keyBundlePath = $input->getOption('certificate');
71
+        $path = $input->getOption('path');
72
+        if(is_null($privateKeyPath) || is_null($keyBundlePath) || is_null($path)) {
73
+            $output->writeln('--privateKey, --certificate and --path are required.');
74
+            return null;
75
+        }
76 76
 
77
-		$privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath);
78
-		$keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath);
77
+        $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath);
78
+        $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath);
79 79
 
80
-		if($privateKey === false) {
81
-			$output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath));
82
-			return null;
83
-		}
80
+        if($privateKey === false) {
81
+            $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath));
82
+            return null;
83
+        }
84 84
 
85
-		if($keyBundle === false) {
86
-			$output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath));
87
-			return null;
88
-		}
85
+        if($keyBundle === false) {
86
+            $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath));
87
+            return null;
88
+        }
89 89
 
90
-		$rsa = new RSA();
91
-		$rsa->loadKey($privateKey);
92
-		$x509 = new X509();
93
-		$x509->loadX509($keyBundle);
94
-		$x509->setPrivateKey($rsa);
90
+        $rsa = new RSA();
91
+        $rsa->loadKey($privateKey);
92
+        $x509 = new X509();
93
+        $x509->loadX509($keyBundle);
94
+        $x509->setPrivateKey($rsa);
95 95
 
96
-		try {
97
-			$this->checker->writeCoreSignature($x509, $rsa, $path);
98
-			$output->writeln('Successfully signed "core"');
99
-		} catch (\Exception $e){
100
-			$output->writeln('Error: ' . $e->getMessage());
101
-			return 1;
102
-		}
103
-		return 0;
104
-	}
96
+        try {
97
+            $this->checker->writeCoreSignature($x509, $rsa, $path);
98
+            $output->writeln('Successfully signed "core"');
99
+        } catch (\Exception $e){
100
+            $output->writeln('Error: ' . $e->getMessage());
101
+            return 1;
102
+        }
103
+        return 0;
104
+    }
105 105
 }
Please login to merge, or discard this patch.
core/Command/Integrity/SignApp.php 1 patch
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -38,76 +38,76 @@
 block discarded – undo
38 38
  * @package OC\Core\Command\Integrity
39 39
  */
40 40
 class SignApp extends Command {
41
-	/** @var Checker */
42
-	private $checker;
43
-	/** @var FileAccessHelper */
44
-	private $fileAccessHelper;
45
-	/** @var IURLGenerator */
46
-	private $urlGenerator;
41
+    /** @var Checker */
42
+    private $checker;
43
+    /** @var FileAccessHelper */
44
+    private $fileAccessHelper;
45
+    /** @var IURLGenerator */
46
+    private $urlGenerator;
47 47
 
48
-	/**
49
-	 * @param Checker $checker
50
-	 * @param FileAccessHelper $fileAccessHelper
51
-	 * @param IURLGenerator $urlGenerator
52
-	 */
53
-	public function __construct(Checker $checker,
54
-								FileAccessHelper $fileAccessHelper,
55
-								IURLGenerator $urlGenerator) {
56
-		parent::__construct(null);
57
-		$this->checker = $checker;
58
-		$this->fileAccessHelper = $fileAccessHelper;
59
-		$this->urlGenerator = $urlGenerator;
60
-	}
48
+    /**
49
+     * @param Checker $checker
50
+     * @param FileAccessHelper $fileAccessHelper
51
+     * @param IURLGenerator $urlGenerator
52
+     */
53
+    public function __construct(Checker $checker,
54
+                                FileAccessHelper $fileAccessHelper,
55
+                                IURLGenerator $urlGenerator) {
56
+        parent::__construct(null);
57
+        $this->checker = $checker;
58
+        $this->fileAccessHelper = $fileAccessHelper;
59
+        $this->urlGenerator = $urlGenerator;
60
+    }
61 61
 
62
-	protected function configure() {
63
-		$this
64
-			->setName('integrity:sign-app')
65
-			->setDescription('Signs an app using a private key.')
66
-			->addOption('path', null, InputOption::VALUE_REQUIRED, 'Application to sign')
67
-			->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing')
68
-			->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing');
69
-	}
62
+    protected function configure() {
63
+        $this
64
+            ->setName('integrity:sign-app')
65
+            ->setDescription('Signs an app using a private key.')
66
+            ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Application to sign')
67
+            ->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing')
68
+            ->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing');
69
+    }
70 70
 
71
-	/**
72
-	 * {@inheritdoc }
73
-	 */
74
-	protected function execute(InputInterface $input, OutputInterface $output) {
75
-		$path = $input->getOption('path');
76
-		$privateKeyPath = $input->getOption('privateKey');
77
-		$keyBundlePath = $input->getOption('certificate');
78
-		if(is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) {
79
-			$documentationUrl = $this->urlGenerator->linkToDocs('developer-code-integrity');
80
-			$output->writeln('This command requires the --path, --privateKey and --certificate.');
81
-			$output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"');
82
-			$output->writeln('For more information please consult the documentation: '. $documentationUrl);
83
-			return null;
84
-		}
71
+    /**
72
+     * {@inheritdoc }
73
+     */
74
+    protected function execute(InputInterface $input, OutputInterface $output) {
75
+        $path = $input->getOption('path');
76
+        $privateKeyPath = $input->getOption('privateKey');
77
+        $keyBundlePath = $input->getOption('certificate');
78
+        if(is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) {
79
+            $documentationUrl = $this->urlGenerator->linkToDocs('developer-code-integrity');
80
+            $output->writeln('This command requires the --path, --privateKey and --certificate.');
81
+            $output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"');
82
+            $output->writeln('For more information please consult the documentation: '. $documentationUrl);
83
+            return null;
84
+        }
85 85
 
86
-		$privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath);
87
-		$keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath);
86
+        $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath);
87
+        $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath);
88 88
 
89
-		if($privateKey === false) {
90
-			$output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath));
91
-			return null;
92
-		}
89
+        if($privateKey === false) {
90
+            $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath));
91
+            return null;
92
+        }
93 93
 
94
-		if($keyBundle === false) {
95
-			$output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath));
96
-			return null;
97
-		}
94
+        if($keyBundle === false) {
95
+            $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath));
96
+            return null;
97
+        }
98 98
 
99
-		$rsa = new RSA();
100
-		$rsa->loadKey($privateKey);
101
-		$x509 = new X509();
102
-		$x509->loadX509($keyBundle);
103
-		$x509->setPrivateKey($rsa);
104
-		try {
105
-			$this->checker->writeAppSignature($path, $x509, $rsa);
106
-			$output->writeln('Successfully signed "'.$path.'"');
107
-		} catch (\Exception $e){
108
-			$output->writeln('Error: ' . $e->getMessage());
109
-			return 1;
110
-		}
111
-		return 0;
112
-	}
99
+        $rsa = new RSA();
100
+        $rsa->loadKey($privateKey);
101
+        $x509 = new X509();
102
+        $x509->loadX509($keyBundle);
103
+        $x509->setPrivateKey($rsa);
104
+        try {
105
+            $this->checker->writeAppSignature($path, $x509, $rsa);
106
+            $output->writeln('Successfully signed "'.$path.'"');
107
+        } catch (\Exception $e){
108
+            $output->writeln('Error: ' . $e->getMessage());
109
+            return 1;
110
+        }
111
+        return 0;
112
+    }
113 113
 }
Please login to merge, or discard this patch.
core/Command/Integrity/CheckCore.php 1 patch
Indentation   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -34,34 +34,34 @@
 block discarded – undo
34 34
  * @package OC\Core\Command\Integrity
35 35
  */
36 36
 class CheckCore extends Base {
37
-	/**
38
-	 * @var Checker
39
-	 */
40
-	private $checker;
37
+    /**
38
+     * @var Checker
39
+     */
40
+    private $checker;
41 41
 
42
-	public function __construct(Checker $checker) {
43
-		parent::__construct();
44
-		$this->checker = $checker;
45
-	}
42
+    public function __construct(Checker $checker) {
43
+        parent::__construct();
44
+        $this->checker = $checker;
45
+    }
46 46
 
47
-	/**
48
-	 * {@inheritdoc }
49
-	 */
50
-	protected function configure() {
51
-		parent::configure();
52
-		$this
53
-			->setName('integrity:check-core')
54
-			->setDescription('Check integrity of core code using a signature.');
55
-	}
47
+    /**
48
+     * {@inheritdoc }
49
+     */
50
+    protected function configure() {
51
+        parent::configure();
52
+        $this
53
+            ->setName('integrity:check-core')
54
+            ->setDescription('Check integrity of core code using a signature.');
55
+    }
56 56
 
57
-	/**
58
-	 * {@inheritdoc }
59
-	 */
60
-	protected function execute(InputInterface $input, OutputInterface $output) {
61
-		$result = $this->checker->verifyCoreSignature();
62
-		$this->writeArrayInOutputFormat($input, $output, $result);
63
-		if (count($result)>0){
64
-			return 1;
65
-		}
66
-	}
57
+    /**
58
+     * {@inheritdoc }
59
+     */
60
+    protected function execute(InputInterface $input, OutputInterface $output) {
61
+        $result = $this->checker->verifyCoreSignature();
62
+        $this->writeArrayInOutputFormat($input, $output, $result);
63
+        if (count($result)>0){
64
+            return 1;
65
+        }
66
+    }
67 67
 }
Please login to merge, or discard this patch.
core/Command/User/LastSeen.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -32,44 +32,44 @@
 block discarded – undo
32 32
 use Symfony\Component\Console\Input\InputArgument;
33 33
 
34 34
 class LastSeen extends Command {
35
-	/** @var IUserManager */
36
-	protected $userManager;
35
+    /** @var IUserManager */
36
+    protected $userManager;
37 37
 
38
-	/**
39
-	 * @param IUserManager $userManager
40
-	 */
41
-	public function __construct(IUserManager $userManager) {
42
-		$this->userManager = $userManager;
43
-		parent::__construct();
44
-	}
38
+    /**
39
+     * @param IUserManager $userManager
40
+     */
41
+    public function __construct(IUserManager $userManager) {
42
+        $this->userManager = $userManager;
43
+        parent::__construct();
44
+    }
45 45
 
46
-	protected function configure() {
47
-		$this
48
-			->setName('user:lastseen')
49
-			->setDescription('shows when the user was logged in last time')
50
-			->addArgument(
51
-				'uid',
52
-				InputArgument::REQUIRED,
53
-				'the username'
54
-			);
55
-	}
46
+    protected function configure() {
47
+        $this
48
+            ->setName('user:lastseen')
49
+            ->setDescription('shows when the user was logged in last time')
50
+            ->addArgument(
51
+                'uid',
52
+                InputArgument::REQUIRED,
53
+                'the username'
54
+            );
55
+    }
56 56
 
57
-	protected function execute(InputInterface $input, OutputInterface $output) {
58
-		$user = $this->userManager->get($input->getArgument('uid'));
59
-		if(is_null($user)) {
60
-			$output->writeln('<error>User does not exist</error>');
61
-			return;
62
-		}
57
+    protected function execute(InputInterface $input, OutputInterface $output) {
58
+        $user = $this->userManager->get($input->getArgument('uid'));
59
+        if(is_null($user)) {
60
+            $output->writeln('<error>User does not exist</error>');
61
+            return;
62
+        }
63 63
 
64
-		$lastLogin = $user->getLastLogin();
65
-		if($lastLogin === 0) {
66
-			$output->writeln('User ' . $user->getUID() .
67
-				' has never logged in, yet.');
68
-		} else {
69
-			$date = new \DateTime();
70
-			$date->setTimestamp($lastLogin);
71
-			$output->writeln($user->getUID() .
72
-				'`s last login: ' . $date->format('d.m.Y H:i'));
73
-		}
74
-	}
64
+        $lastLogin = $user->getLastLogin();
65
+        if($lastLogin === 0) {
66
+            $output->writeln('User ' . $user->getUID() .
67
+                ' has never logged in, yet.');
68
+        } else {
69
+            $date = new \DateTime();
70
+            $date->setTimestamp($lastLogin);
71
+            $output->writeln($user->getUID() .
72
+                '`s last login: ' . $date->format('d.m.Y H:i'));
73
+        }
74
+    }
75 75
 }
Please login to merge, or discard this patch.
core/Command/User/ListCommand.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -32,58 +32,58 @@
 block discarded – undo
32 32
 use Symfony\Component\Console\Output\OutputInterface;
33 33
 
34 34
 class ListCommand extends Base {
35
-	/** @var IUserManager */
36
-	protected $userManager;
35
+    /** @var IUserManager */
36
+    protected $userManager;
37 37
 
38
-	/**
39
-	 * @param IUserManager $userManager
40
-	 */
41
-	public function __construct(IUserManager $userManager) {
42
-		$this->userManager = $userManager;
43
-		parent::__construct();
44
-	}
38
+    /**
39
+     * @param IUserManager $userManager
40
+     */
41
+    public function __construct(IUserManager $userManager) {
42
+        $this->userManager = $userManager;
43
+        parent::__construct();
44
+    }
45 45
 
46
-	protected function configure() {
47
-		$this
48
-			->setName('user:list')
49
-			->setDescription('list configured users')
50
-			->addOption(
51
-				'limit',
52
-				'l',
53
-				InputOption::VALUE_OPTIONAL,
54
-				'Number of users to retrieve',
55
-				500
56
-			)->addOption(
57
-				'offset',
58
-				'o',
59
-				InputOption::VALUE_OPTIONAL,
60
-				'Offset for retrieving users',
61
-				0
62
-			)->addOption(
63
-				'output',
64
-				null,
65
-				InputOption::VALUE_OPTIONAL,
66
-				'Output format (plain, json or json_pretty, default is plain)',
67
-				$this->defaultOutputFormat
68
-			);
69
-	}
46
+    protected function configure() {
47
+        $this
48
+            ->setName('user:list')
49
+            ->setDescription('list configured users')
50
+            ->addOption(
51
+                'limit',
52
+                'l',
53
+                InputOption::VALUE_OPTIONAL,
54
+                'Number of users to retrieve',
55
+                500
56
+            )->addOption(
57
+                'offset',
58
+                'o',
59
+                InputOption::VALUE_OPTIONAL,
60
+                'Offset for retrieving users',
61
+                0
62
+            )->addOption(
63
+                'output',
64
+                null,
65
+                InputOption::VALUE_OPTIONAL,
66
+                'Output format (plain, json or json_pretty, default is plain)',
67
+                $this->defaultOutputFormat
68
+            );
69
+    }
70 70
 
71
-	protected function execute(InputInterface $input, OutputInterface $output) {
72
-		$users = $this->userManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset'));
73
-		$this->writeArrayInOutputFormat($input, $output, $this->formatUsers($users));
74
-	}
71
+    protected function execute(InputInterface $input, OutputInterface $output) {
72
+        $users = $this->userManager->search('', (int)$input->getOption('limit'), (int)$input->getOption('offset'));
73
+        $this->writeArrayInOutputFormat($input, $output, $this->formatUsers($users));
74
+    }
75 75
 
76
-	/**
77
-	 * @param IUser[] $users
78
-	 * @return array
79
-	 */
80
-	private function formatUsers(array $users) {
81
-		$keys = array_map(function (IUser $user) {
82
-			return $user->getUID();
83
-		}, $users);
84
-		$values = array_map(function (IUser $user) {
85
-			return $user->getDisplayName();
86
-		}, $users);
87
-		return array_combine($keys, $values);
88
-	}
76
+    /**
77
+     * @param IUser[] $users
78
+     * @return array
79
+     */
80
+    private function formatUsers(array $users) {
81
+        $keys = array_map(function (IUser $user) {
82
+            return $user->getUID();
83
+        }, $users);
84
+        $values = array_map(function (IUser $user) {
85
+            return $user->getDisplayName();
86
+        }, $users);
87
+        return array_combine($keys, $values);
88
+    }
89 89
 }
Please login to merge, or discard this patch.