diff options
author | Mario <mario@mariovavti.com> | 2019-11-10 12:49:51 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-11-10 14:10:03 +0100 |
commit | 580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch) | |
tree | 82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php | |
parent | d22766f458a8539a40a57f3946459a9be1f21cd6 (diff) | |
download | volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2 volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip |
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php')
-rw-r--r-- | vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php b/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php new file mode 100644 index 000000000..3a1831116 --- /dev/null +++ b/vendor/sabre/dav/lib/DAV/Auth/Backend/IMAP.php @@ -0,0 +1,82 @@ +<?php + +namespace Sabre\DAV\Auth\Backend; + +/** + * This is an authentication backend that uses imap. + * + * @copyright Copyright (C) fruux GmbH (https://fruux.com/) + * @author Michael Niewöhner (foss@mniewoehner.de) + * @author rosali (https://github.com/rosali) + * @author Evert Pot (http://evertpot.com/) + * @license http://sabre.io/license/ Modified BSD License + */ +class IMAP extends AbstractBasic +{ + /** + * IMAP server in the form {host[:port][/flag1/flag2...]}. + * + * @see http://php.net/manual/en/function.imap-open.php + * + * @var string + */ + protected $mailbox; + + /** + * Creates the backend object. + * + * @param string $mailbox + */ + public function __construct($mailbox) + { + $this->mailbox = $mailbox; + } + + /** + * Connects to an IMAP server and tries to authenticate. + * + * @param string $username + * @param string $password + * + * @return bool + */ + protected function imapOpen($username, $password) + { + $success = false; + + try { + $imap = imap_open($this->mailbox, $username, $password, OP_HALFOPEN | OP_READONLY, 1); + if ($imap) { + $success = true; + } + } catch (\ErrorException $e) { + error_log($e->getMessage()); + } + + $errors = imap_errors(); + if ($errors) { + foreach ($errors as $error) { + error_log($error); + } + } + + if (isset($imap) && $imap) { + imap_close($imap); + } + + return $success; + } + + /** + * Validates a username and password by trying to authenticate against IMAP. + * + * @param string $username + * @param string $password + * + * @return bool + */ + protected function validateUserPass($username, $password) + { + return $this->imapOpen($username, $password); + } +} |