Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/user_saml.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2016-09-26 22:12:51 +0300
committerLukas Reschke <lukas@statuscode.ch>2016-09-26 22:24:44 +0300
commit9b97c7350bda2f12869b1301beffbf172570273b (patch)
treea01cc12cdea154d727d3763839fc32acf5ff976e /lib
parent5ca41b2b2bfa88d692eac08444260037e2fba6fa (diff)
Remove unused code
This is now also part of core Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'lib')
-rw-r--r--lib/Settings/Section.php3
-rw-r--r--lib/appinfo/application.php15
-rw-r--r--lib/controller/authsettingscontroller.php167
3 files changed, 4 insertions, 181 deletions
diff --git a/lib/Settings/Section.php b/lib/Settings/Section.php
index 085462a7..5fed8cd2 100644
--- a/lib/Settings/Section.php
+++ b/lib/Settings/Section.php
@@ -30,6 +30,9 @@ class Section implements ISection {
/** @var IL10N */
private $l;
+ /**
+ * @param IL10N $l
+ */
public function __construct(IL10N $l) {
$this->l = $l;
}
diff --git a/lib/appinfo/application.php b/lib/appinfo/application.php
index c4587b17..240027ae 100644
--- a/lib/appinfo/application.php
+++ b/lib/appinfo/application.php
@@ -38,19 +38,6 @@ class Application extends App {
/**
* Controller
*/
- $container->registerService('AuthSettingsController', function(IAppContainer $c) {
- /** @var \OC\Server $server */
- $server = $c->query('ServerContainer');
- return new AuthSettingsController(
- $c->getAppName(),
- $server->getRequest(),
- $server->getUserManager(),
- $server->getSession(),
- $server->getSecureRandom(),
- $server->getDb(),
- $server->getUserSession()->getUser()->getUID()
- );
- });
$container->registerService('SettingsController', function(IAppContainer $c) {
/** @var \OC\Server $server */
$server = $c->query('ServerContainer');
@@ -87,6 +74,6 @@ class Application extends App {
$c->query('ServerContainer')->getUserSession()
);
});
- $container->registerMiddleware('OnlyLoggedInMiddleware');
+ $container->registerMiddleWare('OnlyLoggedInMiddleware');
}
}
diff --git a/lib/controller/authsettingscontroller.php b/lib/controller/authsettingscontroller.php
deleted file mode 100644
index ddc0fad6..00000000
--- a/lib/controller/authsettingscontroller.php
+++ /dev/null
@@ -1,167 +0,0 @@
-<?php
-/**
- * @author Christoph Wurst <christoph@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-namespace OCA\User_SAML\Controller;
-
-use OC\AppFramework\Http;
-use OCP\AppFramework\Controller;
-use OCP\AppFramework\Http\JSONResponse;
-use OCP\DB\QueryBuilder\IQueryBuilder;
-use OCP\IDb;
-use OCP\IRequest;
-use OCP\ISession;
-use OCP\IUserManager;
-use OCP\Security\ISecureRandom;
-
-class AuthSettingsController extends Controller {
- /** @var IUserManager */
- private $userManager;
- /** @var ISession */
- private $session;
- /** @var string */
- private $uid;
- /** @var ISecureRandom */
- private $random;
- /** @var IDb */
- private $db;
-
- /**
- * @param string $appName
- * @param IRequest $request
- * @param IUserManager $userManager
- * @param ISession $session
- * @param ISecureRandom $random
- * @param IDb $db
- * @param string $uid
- */
- public function __construct($appName,
- IRequest $request,
- IUserManager $userManager,
- ISession $session,
- ISecureRandom $random,
- IDb $db,
- $uid) {
- parent::__construct($appName, $request);
- $this->userManager = $userManager;
- $this->uid = $uid;
- $this->session = $session;
- $this->random = $random;
- $this->db = $db;
- }
- /**
- * @NoAdminRequired
- *
- * @return JSONResponse
- */
- public function index() {
- $user = $this->userManager->get($this->uid);
- if (is_null($user)) {
- return [];
- }
-
- /* @var $qb IQueryBuilder */
- $qb = $this->db->getQueryBuilder();
- $qb->select('id', 'uid', 'name', 'token')
- ->from('user_saml_auth_token')
- ->where($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())))
- ->setMaxResults(1000);
- $result = $qb->execute();
- $data = $result->fetchAll();
- $result->closeCursor();
-
- foreach($data as $key => $entry) {
- unset($data[$key]['token']);
- unset($data[$key]['uid']);
- $data[$key]['id'] = (int)$data[$key]['id'];
- $data[$key]['type'] = 1;
- }
-
- return $data;
- }
-
- /**
- * @NoAdminRequired
- *
- * @param string $name
- * @return JSONResponse
- */
- public function create($name) {
- $token = $this->generateRandomDeviceToken();
-
- $values = [
- 'uid' => $this->uid,
- 'name' => $name,
- 'token' => password_hash($token, PASSWORD_DEFAULT),
- ];
-
- /* @var $qb IQueryBuilder */
- $qb = $this->db->getQueryBuilder();
- $qb->insert('user_saml_auth_token');
- foreach($values as $column => $value) {
- $qb->setValue($column, $qb->createNamedParameter($value));
- }
- $qb->execute();
-
- return [
- 'token' => $token,
- 'loginName' => $name,
- 'deviceToken' => [
- 'id' => $qb->getLastInsertId(),
- 'name' => $name,
- 'type' => 1,
- ],
- ];
- }
- /**
- * Return a 20 digit device password
- *
- * Example: ABCDE-FGHIJ-KLMNO-PQRST
- *
- * @return string
- */
- private function generateRandomDeviceToken() {
- $groups = [];
- for ($i = 0; $i < 4; $i++) {
- $groups[] = $this->random->generate(5, implode('', range('A', 'Z')));
- }
- return implode('-', $groups);
- }
- /**
- * @NoAdminRequired
- *
- * @param string $id
- * @return JSONResponse
- */
- public function destroy($id) {
- $user = $this->userManager->get($this->uid);
- if (is_null($user)) {
- return [];
- }
-
- /* @var $qb IQueryBuilder */
- $qb = $this->db->getQueryBuilder();
- $qb->delete('user_saml_auth_token')
- ->where($qb->expr()->eq('id', $qb->createNamedParameter($id)))
- ->andWhere($qb->expr()->eq('uid', $qb->createNamedParameter($user->getUID())));
- $qb->execute();
-
- return [];
- }
-} \ No newline at end of file