summaryrefslogtreecommitdiffstats
path: root/cipher.c
AgeCommit message (Expand)Author
2017-05-08upstream commitdjm@openbsd.org
2017-05-08upstream commitdjm@openbsd.org
2017-05-01upstream commitdjm@openbsd.org
2017-05-01upstream commitdjm@openbsd.org
2017-05-01upstream commitdjm@openbsd.org
2016-10-28Unbreak AES-CTR ciphers on old (~0.9.8) OpenSSLDamien Miller
2016-08-09upstream commitdjm@openbsd.org
2016-07-15disable ciphers not supported by OpenSSLDamien Miller
2015-12-11upstream commitmmcc@openbsd.org
2015-01-14upstream commitdjm@openbsd.org
2014-07-21- (dtucker) [cipher.c openbsd-compat/openssl-compat.h] Restore the bitsDarren Tucker
2014-07-02 - djm@cvs.openbsd.org 2014/06/24 01:13:21Damien Miller
2014-05-27 - (djm) [cipher.c] Fix merge botch.Damien Miller
2014-05-15 - markus@cvs.openbsd.org 2014/04/29 18:01:49Damien Miller
2014-02-24 - djm@cvs.openbsd.org 2014/02/07 06:55:54Damien Miller
2014-02-04 - djm@cvs.openbsd.org 2014/02/02 03:44:32Damien Miller
2014-02-04 - markus@cvs.openbsd.org 2014/01/27 19:18:54Damien Miller
2014-01-26 - dtucker@cvs.openbsd.org 2014/01/25 10:12:50Damien Miller
2013-12-07 - markus@cvs.openbsd.org 2013/12/06 13:34:54Damien Miller
2013-12-05 - djm@cvs.openbsd.org 2013/12/02 03:13:14Damien Miller
2013-11-21 - djm@cvs.openbsd.org 2013/11/21 00:45:44Damien Miller
2013-11-08 - dtucker@cvs.openbsd.org 2013/11/07 11:58:27Damien Miller
2013-06-02 - djm@cvs.openbsd.org 2013/05/17 00:13:13Darren Tucker
2013-04-23 - djm@cvs.openbsd.org 2013/04/19 01:06:50Damien Miller
2013-02-12 - djm@cvs.openbsd.org 2013/01/26 06:11:05Damien Miller
2013-01-12 - djm@cvs.openbsd.org 2013/01/12 11:22:04Damien Miller
2013-01-09 - (djm) [cipher.c configure.ac openbsd-compat/openssl-compat.h]Damien Miller
2013-01-09 - markus@cvs.openbsd.org 2013/01/08 18:49:04Damien Miller
2012-12-13 - (djm) [cipher.c] Fix missing prototype for compat codeDamien Miller
2012-12-13 - (djm) [configure.ac cipher-ctr.c] Adapt EVP AES CTR change to retain ourDamien Miller
2012-12-12 - markus@cvs.openbsd.org 2012/12/11 22:31:18Damien Miller
2009-01-28 - markus@cvs.openbsd.org 2009/01/26 09:58:15Damien Miller
2006-08-05 - deraadt@cvs.openbsd.org 2006/08/03 03:34:42Damien Miller
2006-07-24 - stevesk@cvs.openbsd.org 2006/07/22 20:48:23Damien Miller
2006-03-26 - djm@cvs.openbsd.org 2006/03/25 13:17:03Damien Miller
2006-03-26 - deraadt@cvs.openbsd.org 2006/03/19 18:51:18Damien Miller
2005-12-19 - (dtucker) [cipher-aes.c cipher-ctr.c cipher.c configure.acDarren Tucker
2005-07-17 - djm@cvs.openbsd.org 2005/07/16 01:35:24Damien Miller
2005-06-17 - (dtucker) [cipher.c openbsd-compat/openbsd-compat.hDarren Tucker
2005-06-17 - djm@cvs.openbsd.org 2005/06/17 02:44:33Damien Miller
2005-06-16 - dtucker@cvs.openbsd.org 2005/06/09 13:43:49Damien Miller
2005-06-09 - (dtucker) [cipher.c openbsd-compat/Makefile.inDarren Tucker
2005-05-26 - djm@cvs.openbsd.org 2005/05/23 23:32:46Damien Miller
2005-01-24 - djm@cvs.openbsd.org 2005/01/23 10:18:12Darren Tucker
2005-01-20 - djm@cvs.openbsd.org 2004/12/22 02:13:19Darren Tucker
2004-08-12 - markus@cvs.openbsd.org 2004/07/28 09:40:29Darren Tucker
2004-07-17 - deraadt@cvs.openbsd.org 2004/07/11 17:48:47Darren Tucker
2004-06-23 - (dtucker) [cipher.c] encrypt->do_encrypt inside SSH_OLD_EVP to matchDarren Tucker
2004-06-22 - avsm@cvs.openbsd.org 2004/06/21 17:36:31Darren Tucker
2004-02-07- (dtucker) [cipher.c] enable AES counter modes with OpenSSL 0.9.5.Darren Tucker
String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
<?php
/**
 * Nextcloud - News
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author    Alessandro Cosentino <cosenal@gmail.com>
 * @author    Bernhard Posselt <dev@bernhard-posselt.com>
 * @author    David Guillot <david@guillot.me>
 * @copyright 2012 Alessandro Cosentino
 * @copyright 2012-2014 Bernhard Posselt
 * @copyright 2018 David Guillot
 */

namespace OCA\News\Controller;

use \OCP\IRequest;
use \OCP\ILogger;
use \OCP\IUserSession;
use \OCP\AppFramework\Http;

use \OCA\News\Service\FeedService;
use \OCA\News\Service\ItemService;
use \OCA\News\Service\ServiceNotFoundException;
use \OCA\News\Service\ServiceConflictException;


class FeedApiController extends ApiController
{

    use JSONHttpError;

    private $itemService;
    private $feedService;
    private $logger;
    private $loggerParams;
    private $serializer;

    public function __construct($appName,
        IRequest $request,
        IUserSession $userSession,
        FeedService $feedService,
        ItemService $itemService,
        ILogger $logger,
        $LoggerParameters
    ) {
        parent::__construct($appName, $request, $userSession);
        $this->feedService = $feedService;
        $this->itemService = $itemService;
        $this->logger = $logger;
        $this->loggerParams = $LoggerParameters;
        $this->serializer = new EntityApiSerializer('feeds');
    }


    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     * @CORS
     */
    public function index() 
    {

        $result = [
            'starredCount' => $this->itemService->starredCount($this->getUserId()),
            'feeds' => $this->feedService->findAll($this->getUserId())
        ];


        try {
            $result['newestItemId'] =
                $this->itemService->getNewestItemId($this->getUserId());

            // in case there are no items, ignore
        } catch(ServiceNotFoundException $ex) {
        }

        return $this->serializer->serialize($result);
    }


    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     * @CORS
     *
     * @param string $url
     * @param int    $folderId
     * @return array|mixed|\OCP\AppFramework\Http\JSONResponse
     */
    public function create($url, $folderId=0) 
    {
        try {
            $this->feedService->purgeDeleted($this->getUserId(), false);

            $feed = $this->feedService->create($url, $folderId, $this->getUserId());
            $result = ['feeds' => [$feed]];

            try {
                $result['newestItemId'] =
                    $this->itemService->getNewestItemId($this->getUserId());

                // in case there are no items, ignore
            } catch(ServiceNotFoundException $ex) {
            }

            return $this->serializer->serialize($result);

        } catch(ServiceConflictException $ex) {
            return $this->error($ex, Http::STATUS_CONFLICT);
        } catch(ServiceNotFoundException $ex) {
            return $this->error($ex, Http::STATUS_NOT_FOUND);
        }
    }


    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     * @CORS
     *
     * @param int $feedId
     * @return array|\OCP\AppFramework\Http\JSONResponse
     */
    public function delete($feedId) 
    {
        try {
            $this->feedService->delete($feedId, $this->getUserId());
        } catch(ServiceNotFoundException $ex) {
            return $this->error($ex, Http::STATUS_NOT_FOUND);
        }

        return [];
    }


    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     * @CORS
     *
     * @param int $feedId
     * @param int $newestItemId
     */
    public function read($feedId, $newestItemId) 
    {
        $this->itemService->readFeed($feedId, $newestItemId, $this->getUserId());
    }


    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     * @CORS
     *
     * @param int $feedId
     * @param int $folderId
     * @return array|\OCP\AppFramework\Http\JSONResponse
     */
    public function move($feedId, $folderId) 
    {
        try {
            $this->feedService->patch(
                $feedId, $this->getUserId(), ['folderId' => $folderId]
            );
        } catch(ServiceNotFoundException $ex) {
            return $this->error($ex, Http::STATUS_NOT_FOUND);
        }

        return [];
    }


    /**
     * @NoAdminRequired
     * @NoCSRFRequired
     * @CORS
     *
     * @param int    $feedId
     * @param string $feedTitle
     * @return array|\OCP\AppFramework\Http\JSONResponse
     */
    public function rename($feedId, $feedTitle) 
    {
        try {
            $this->feedService->patch(
                $feedId, $this->getUserId(), ['title' => $feedTitle]
            );
        } catch(ServiceNotFoundException $ex) {
            return $this->error($ex, Http::STATUS_NOT_FOUND);
        }

        return [];
    }


    /**
     * @NoCSRFRequired
     * @CORS
     */
    public function fromAllUsers() 
    {
        $feeds = $this->feedService->findAllFromAllUsers();
        $result = ['feeds' => []];

        foreach ($feeds as $feed) {
            $result['feeds'][] = [
                'id' => $feed->getId(),
                'userId' => $feed->getUserId()
            ];
        }

        return $result;
    }


    /**
     * @NoCSRFRequired
     *
     * @param string $userId
     * @param int    $feedId
     */
    public function update($userId, $feedId) 
    {
        try {
            $this->feedService->update($feedId, $userId);
            // ignore update failure
        } catch(\Exception $ex) {
            $this->logger->debug(
                'Could not update feed ' . $ex->getMessage(),
                $this->loggerParams
            );
        }
    }


}