mirror of
https://github.com/nextcloud/server.git
synced 2026-06-13 18:50:47 -04:00
PHPDoc cleanup - clean code \o/
This commit is contained in:
parent
b9e4e61759
commit
111fbabfb4
6 changed files with 42 additions and 43 deletions
|
|
@ -205,8 +205,6 @@ class UserHooks implements IHook {
|
|||
* Change a user's encryption passphrase
|
||||
*
|
||||
* @param array $params keys: uid, password
|
||||
* @param IUserSession $user
|
||||
* @param Util $util
|
||||
* @return bool
|
||||
*/
|
||||
public function setPassphrase($params) {
|
||||
|
|
|
|||
|
|
@ -34,11 +34,10 @@ use OCP\IUserSession;
|
|||
|
||||
class Crypt {
|
||||
|
||||
const BLOCKSIZE = 8192;
|
||||
const DEFAULT_CIPHER = 'AES-256-CFB';
|
||||
|
||||
const HEADERSTART = 'HBEGIN';
|
||||
const HEADEREND = 'HEND';
|
||||
const HEADER_START = 'HBEGIN';
|
||||
const HEADER_END = 'HEND';
|
||||
/**
|
||||
* @var ILogger
|
||||
*/
|
||||
|
|
@ -64,7 +63,7 @@ class Crypt {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array|bool
|
||||
*/
|
||||
public function createKeyPair() {
|
||||
|
||||
|
|
@ -121,8 +120,8 @@ class Crypt {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $plainContent
|
||||
* @param $passPhrase
|
||||
* @param string $plainContent
|
||||
* @param string $passPhrase
|
||||
* @return bool|string
|
||||
* @throws GenericEncryptionException
|
||||
*/
|
||||
|
|
@ -148,8 +147,8 @@ class Crypt {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $plainContent
|
||||
* @param $iv
|
||||
* @param string $plainContent
|
||||
* @param string $iv
|
||||
* @param string $passPhrase
|
||||
* @param string $cipher
|
||||
* @return string
|
||||
|
|
@ -187,8 +186,8 @@ class Crypt {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $encryptedContent
|
||||
* @param $iv
|
||||
* @param string $encryptedContent
|
||||
* @param string $iv
|
||||
* @return string
|
||||
*/
|
||||
private function concatIV($encryptedContent, $iv) {
|
||||
|
|
@ -204,20 +203,20 @@ class Crypt {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $recoveryKey
|
||||
* @param $password
|
||||
* @param string $recoveryKey
|
||||
* @param string $password
|
||||
* @return bool|string
|
||||
*/
|
||||
public function decryptPrivateKey($recoveryKey, $password) {
|
||||
|
||||
$header = $this->parseHeader($recoveryKey);
|
||||
$cipher = $this->getCipher($header);
|
||||
$cipher = $this->getCipher();
|
||||
|
||||
// If we found a header we need to remove it from the key we want to decrypt
|
||||
if (!empty($header)) {
|
||||
$recoveryKey = substr($recoveryKey,
|
||||
strpos($recoveryKey,
|
||||
self::HEADEREND) + strlen(self::HEADERSTART));
|
||||
self::HEADER_END) + strlen(self::HEADER_START));
|
||||
}
|
||||
|
||||
$plainKey = $this->symmetricDecryptFileContent($recoveryKey,
|
||||
|
|
@ -318,17 +317,17 @@ class Crypt {
|
|||
private function parseHeader($data) {
|
||||
$result = [];
|
||||
|
||||
if (substr($data, 0, strlen(self::HEADERSTART)) === self::HEADERSTART) {
|
||||
$endAt = strpos($data, self::HEADEREND);
|
||||
$header = substr($data, 0, $endAt + strlen(self::HEADEREND));
|
||||
if (substr($data, 0, strlen(self::HEADER_START)) === self::HEADER_START) {
|
||||
$endAt = strpos($data, self::HEADER_END);
|
||||
$header = substr($data, 0, $endAt + strlen(self::HEADER_END));
|
||||
|
||||
// +1 not to start with an ':' which would result in empty element at the beginning
|
||||
$exploded = explode(':',
|
||||
substr($header, strlen(self::HEADERSTART) + 1));
|
||||
substr($header, strlen(self::HEADER_START) + 1));
|
||||
|
||||
$element = array_shift($exploded);
|
||||
|
||||
while ($element != self::HEADEREND) {
|
||||
while ($element != self::HEADER_END) {
|
||||
$result[$element] = array_shift($exploded);
|
||||
$element = array_shift($exploded);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ class Util {
|
|||
/** @var array */
|
||||
protected $ocHeaderKeys;
|
||||
|
||||
/** @var Manager */
|
||||
/** @var \OC\User\Manager */
|
||||
protected $userManager;
|
||||
|
||||
/** @var IConfig */
|
||||
|
|
|
|||
|
|
@ -394,7 +394,7 @@ class Encryption extends Wrapper {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param string $encryptionModule
|
||||
* @param string $encryptionModuleId
|
||||
* @return \OCP\Encryption\Keys\IStorage
|
||||
*/
|
||||
protected function getKeyStorage($encryptionModuleId) {
|
||||
|
|
|
|||
|
|
@ -32,38 +32,39 @@ class OC_Hook{
|
|||
|
||||
/**
|
||||
* connects a function to a hook
|
||||
* @param string $signalclass class name of emitter
|
||||
* @param string $signalname name of signal
|
||||
* @param string $slotclass class name of slot
|
||||
* @param string $slotname name of slot
|
||||
*
|
||||
* @param string $signalClass class name of emitter
|
||||
* @param string $signalName name of signal
|
||||
* @param string|object $slotClass class name of slot
|
||||
* @param string $slotName name of slot
|
||||
* @return bool
|
||||
*
|
||||
* This function makes it very easy to connect to use hooks.
|
||||
*
|
||||
* TODO: write example
|
||||
*/
|
||||
static public function connect( $signalclass, $signalname, $slotclass, $slotname ) {
|
||||
static public function connect($signalClass, $signalName, $slotClass, $slotName ) {
|
||||
// If we're trying to connect to an emitting class that isn't
|
||||
// yet registered, register it
|
||||
if( !array_key_exists( $signalclass, self::$registered )) {
|
||||
self::$registered[$signalclass] = array();
|
||||
if( !array_key_exists($signalClass, self::$registered )) {
|
||||
self::$registered[$signalClass] = array();
|
||||
}
|
||||
// If we're trying to connect to an emitting method that isn't
|
||||
// yet registered, register it with the emitting class
|
||||
if( !array_key_exists( $signalname, self::$registered[$signalclass] )) {
|
||||
self::$registered[$signalclass][$signalname] = array();
|
||||
if( !array_key_exists( $signalName, self::$registered[$signalClass] )) {
|
||||
self::$registered[$signalClass][$signalName] = array();
|
||||
}
|
||||
|
||||
// dont connect hooks twice
|
||||
foreach (self::$registered[$signalclass][$signalname] as $hook) {
|
||||
if ($hook['class'] === $slotclass and $hook['name'] === $slotname) {
|
||||
foreach (self::$registered[$signalClass][$signalName] as $hook) {
|
||||
if ($hook['class'] === $slotClass and $hook['name'] === $slotName) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Connect the hook handler to the requested emitter
|
||||
self::$registered[$signalclass][$signalname][] = array(
|
||||
"class" => $slotclass,
|
||||
"name" => $slotname
|
||||
self::$registered[$signalClass][$signalName][] = array(
|
||||
"class" => $slotClass,
|
||||
"name" => $slotName
|
||||
);
|
||||
|
||||
// No chance for failure ;-)
|
||||
|
|
|
|||
|
|
@ -394,18 +394,19 @@ class Util {
|
|||
|
||||
/**
|
||||
* connects a function to a hook
|
||||
* @param string $signalclass class name of emitter
|
||||
* @param string $signalname name of signal
|
||||
* @param string $slotclass class name of slot
|
||||
* @param string $slotname name of slot
|
||||
*
|
||||
* @param string $signalClass class name of emitter
|
||||
* @param string $signalName name of signal
|
||||
* @param string|object $slotClass class name of slot
|
||||
* @param string $slotName name of slot
|
||||
* @return bool
|
||||
*
|
||||
* This function makes it very easy to connect to use hooks.
|
||||
*
|
||||
* TODO: write example
|
||||
*/
|
||||
static public function connectHook( $signalclass, $signalname, $slotclass, $slotname ) {
|
||||
return(\OC_Hook::connect( $signalclass, $signalname, $slotclass, $slotname ));
|
||||
static public function connectHook($signalClass, $signalName, $slotClass, $slotName ) {
|
||||
return(\OC_Hook::connect($signalClass, $signalName, $slotClass, $slotName ));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue