Example #1
0
 protected function scan($fileView, $filepath)
 {
     $this->status = new Status();
     if ($this->useSocket) {
         $av_socket = \OCP\Config::getAppValue('files_antivirus', 'av_socket', '');
         $shandler = stream_socket_client('unix://' . $av_socket, $errno, $errstr, 5);
         if (!$shandler) {
             throw new \RuntimeException('Cannot connect to "' . $av_socket . '": ' . $errstr . ' (code ' . $errno . ')');
         }
     } else {
         $av_host = \OCP\Config::getAppValue('files_antivirus', 'av_host', '');
         $av_port = \OCP\Config::getAppValue('files_antivirus', 'av_port', '');
         $shandler = $av_host && $av_port ? @fsockopen($av_host, $av_port) : false;
         if (!$shandler) {
             throw new \RuntimeException('The clamav module is not configured for daemon mode.');
         }
     }
     $fhandler = $this->getFileHandle($fileView, $filepath);
     \OCP\Util::writeLog('files_antivirus', 'Exec scan: ' . $filepath, \OCP\Util::DEBUG);
     // request scan from the daemon
     fwrite($shandler, "nINSTREAM\n");
     while (!feof($fhandler)) {
         $chunk = fread($fhandler, $this->chunkSize);
         $chunk_len = pack('N', strlen($chunk));
         fwrite($shandler, $chunk_len . $chunk);
     }
     fwrite($shandler, pack('N', 0));
     $response = fgets($shandler);
     \OCP\Util::writeLog('files_antivirus', 'Response :: ' . $response, \OCP\Util::DEBUG);
     fclose($shandler);
     fclose($fhandler);
     $this->status->parseResponse($response);
     return $this->status->getNumericStatus();
 }
Example #2
0
 public static function getSites()
 {
     if (($sites = json_decode(\OCP\Config::getAppValue("external", "sites", ''))) != null) {
         return $sites;
     }
     return array();
 }
Example #3
0
 public static function scan($id, $path, $storage)
 {
     $file = $storage->getLocalFile($path);
     $result = OC_Files_Antivirus::clamav_scan($file);
     switch ($result) {
         case CLAMAV_SCANRESULT_UNCHECKED:
             \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is not checked', \OCP\Util::ERROR);
             break;
         case CLAMAV_SCANRESULT_INFECTED:
             $infected_action = \OCP\Config::getAppValue('files_antivirus', 'infected_action', 'only_log');
             if ($infected_action == 'delete') {
                 \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is infected, file deleted', \OCP\Util::ERROR);
                 unlink($file);
             } else {
                 \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" from user "' . $user . '": is infected', \OCP\Util::ERROR);
             }
             break;
         case CLAMAV_SCANRESULT_CLEAN:
             $stmt = OCP\DB::prepare('INSERT INTO `*PREFIX*files_antivirus` (`fileid`, `check_time`) VALUES (?, ?)');
             try {
                 $result = $stmt->execute(array($id, time()));
                 if (\OC_DB::isError($result)) {
                     \OC_Log::write('files_antivirus', __METHOD__ . ', DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                     return;
                 }
             } catch (\Exception $e) {
                 \OCP\Util::writeLog('files_antivirus', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
             }
             break;
     }
 }
 /**
  * @NoAdminRequired
  * @NoCSRFRequired
  */
 public function backendStatus()
 {
     $response = new JSONResponse();
     $params = $this->request->urlParams;
     $backend = $params['backend'];
     $enabled = \OCP\Config::getAppValue('contacts', 'backend_' . $backend, "false");
     return $response->setData($enabled);
 }
Example #5
0
 public function __construct($user = null, $addressBooksTableName = '*PREFIX*addressbook', $backendsTableName = '*PREFIX*addressbooks_backend', $dbBackend = null)
 {
     $this->user = $user ? $user : \OC::$server->getUserSession()->getUser()->getUId();
     $this->addressBooksTableName = $addressBooksTableName;
     $this->backendsTableName = $backendsTableName;
     $this->dbBackend = $dbBackend ? $dbBackend : new Backend\Database($user);
     if (\OCP\Config::getAppValue('contacts', 'backend_ldap', "false") === "true") {
         self::$backendClasses['ldap'] = 'OCA\\Contacts\\Backend\\Ldap';
     }
 }
Example #6
0
 public function __construct()
 {
     parent::__construct();
     // get the path to the executable
     $avPath = \OCP\Config::getAppValue('files_antivirus', 'av_path', '/usr/bin/clamscan');
     // check that the executable is available
     if (!file_exists($avPath)) {
         throw new \RuntimeException('The antivirus executable could not be found at ' . $avPath);
     }
     $this->avPath = $avPath;
 }
Example #7
0
function isSecure()
{
    $url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
    if (false !== strpos($url, 'd=1')) {
        OC_Log::write('passwords', 'Passwords app accessed without secure connection.', OC_Log::WARN);
        return true;
    }
    // test if at least one is true in:
    // (1) header, (2) port number, (3) config.php setting, (4) admin setting
    return !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 || \OC_Config::getValue('forcessl', '') || \OCP\Config::getAppValue('passwords', 'https_check', 'true') == 'false';
}
Example #8
0
 /**
  * Returns the list of allowed "versions"
  * @return array
  */
 public static function getVersions()
 {
     $versions = array();
     $result = json_decode(\OCP\Config::getAppValue('user_files_restore', 'versions', ''));
     if (is_array($result)) {
         foreach ($result as $item) {
             array_push($versions, $item);
         }
     }
     return $versions;
 }
Example #9
0
 public function __construct()
 {
     $this->autocreate = OCP\Config::getAppValue('user_cas', 'cas_autocreate', true);
     $this->cas_link_to_ldap_backend = \OCP\Config::getAppValue('user_cas', 'cas_link_to_ldap_backend', false);
     $this->updateUserData = OCP\Config::getAppValue('user_cas', 'cas_update_user_data', true);
     $this->defaultGroup = OCP\Config::getAppValue('user_cas', 'cas_default_group', '');
     $this->protectedGroups = explode(',', str_replace(' ', '', OCP\Config::getAppValue('user_cas', 'cas_protected_groups', '')));
     $this->mailMapping = OCP\Config::getAppValue('user_cas', 'cas_email_mapping', '');
     $this->displayNameMapping = OCP\Config::getAppValue('user_cas', 'cas_displayName_mapping', '');
     $this->groupMapping = OCP\Config::getAppValue('user_cas', 'cas_group_mapping', '');
     self::initialized_php_cas();
 }
Example #10
0
 /**
  * Initialize Image data handler
  */
 function __construct()
 {
     // Check if ImageMagick is enabled; use standard GD otherwise
     $useImageMagick = intval(\OCP\Config::getAppValue('oclife', 'useImageMagick'));
     $this->imagick = extension_loaded('imagick') && $useImageMagick === 1;
     if ($this->imagick) {
         $this->handableImageType = array('gif', 'jpeg', 'jpg', 'png', 'bmp', 'xbm', 'nef', 'cr2', 'tif', 'pcd');
     } else {
         $this->handableImageType = array('gif', 'jpeg', 'jpg', 'png', 'bmp', 'xbm');
     }
     // Set default background color as black
     $this->htmlBgColor = '#000000';
     $this->setColorFromHTML($this->htmlBgColor);
 }
 public function initializeUser($attr)
 {
     //check backend status
     if (!$this->enabled) {
         return false;
     }
     //retrieve UUID from LDAP server
     $this->connect();
     $linkattr = \OCP\Config::getAppValue('user_shibboleth', 'ldap_link_attribute', 'mail');
     $uuidattr = \OCP\Config::getAppValue('user_shibboleth', 'ldap_uuid_attribute', 'dn');
     $filter = $linkattr . '=' . $attr;
     $result = $this->access->searchUsers($filter, $uuidattr);
     if (count($result) === 1) {
         return $this->access->dn2ocname($result[0]);
     }
     return false;
 }
Example #12
0
 /**
  * Check if a file requires encryption
  * @param string $path
  * @return bool
  *
  * Tests if server side encryption is enabled, and file is allowed by blacklists
  */
 private static function shouldEncrypt($path)
 {
     $userId = Helper::getUser($path);
     if (\OCP\App::isEnabled('files_encryption') === false || Crypt::mode() !== 'server' || strpos($path, '/' . $userId . '/files') !== 0) {
         return false;
     }
     if (is_null(self::$blackList)) {
         self::$blackList = explode(',', \OCP\Config::getAppValue('files_encryption', 'type_blacklist', ''));
     }
     if (Crypt::isCatfileContent($path)) {
         return true;
     }
     $extension = substr($path, strrpos($path, '.') + 1);
     if (array_search($extension, self::$blackList) === false) {
         return true;
     }
     return false;
 }
Example #13
0
 public function setUp()
 {
     \OC_User::clearBackends();
     \OC_User::useBackend(new \OC_User_Dummy());
     //login
     \OC_User::createUser('test', 'test');
     $this->user = \OC_User::getUser();
     \OC_User::setUserId('test');
     \OC\Files\Filesystem::clearMounts();
     $textData = "sample file\n";
     $this->storage = new \OC\Files\Storage\Temporary(array());
     $this->storage->file_put_contents(self::TEST_CLEAN_FILENAME, $textData);
     $this->storage->file_put_contents(self::TEST_INFECTED_FILENAME, $textData);
     \OC\Files\Filesystem::mount($this->storage, array(), '/');
     $this->config['av_mode'] = \OCP\Config::getAppValue('files_antivirus', 'av_mode', null);
     $this->config['av_path'] = \OCP\Config::getAppValue('files_antivirus', 'av_path', null);
     \OCP\Config::setAppValue('files_antivirus', 'av_mode', 'executable');
     \OCP\Config::setAppValue('files_antivirus', 'av_path', __DIR__ . '/avir.sh');
 }
Example #14
0
 private static function webStep()
 {
     // Iterate over all users
     $lastid = \OCP\Config::getAppValue('news', 'backgroundjob_lastid', 0);
     $feedmapper = new FeedMapper();
     $feeds = $feedmapper->findAll();
     usort($feeds, array('OCA\\News\\Backgroundjob', 'sortFeeds'));
     $done = false;
     foreach ($feeds as $feed) {
         if ($feed['id'] > $lastid) {
             // set lastid BEFORE updating feed!
             \OCP\Config::setAppValue('news', 'backgroundjob_lastid', $feed['id']);
             $done = true;
             self::updateFeed($feedmapper, $feed);
         }
     }
     if (!$done) {
         \OCP\Config::setAppValue('news', 'backgroundjob_lastid', 0);
     }
 }
Example #15
0
 public static function scan($id, $path, $storage)
 {
     $fileStatus = \OCA\Files_Antivirus\Scanner::scanFile($storage, $path);
     $result = $fileStatus->getNumericStatus();
     //TODO: Fix undefined $user here
     switch ($result) {
         case \OCA\Files_Antivirus\Status::SCANRESULT_UNCHECKED:
             \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" with id "' . $id . '": is not checked', \OCP\Util::ERROR);
             break;
         case \OCA\Files_Antivirus\Status::SCANRESULT_INFECTED:
             $infected_action = \OCP\Config::getAppValue('files_antivirus', 'infected_action', 'only_log');
             if ($infected_action == 'delete') {
                 \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" with id "' . $id . '": is infected, file deleted', \OCP\Util::ERROR);
                 $storage->unlink($path);
             } else {
                 \OCP\Util::writeLog('files_antivirus', 'File "' . $path . '" with id "' . $id . '": is infected', \OCP\Util::ERROR);
             }
             break;
         case \OCA\Files_Antivirus\Status::SCANRESULT_CLEAN:
             try {
                 $stmt = \OCP\DB::prepare('DELETE FROM `*PREFIX*files_antivirus` WHERE `fileid` = ?');
                 $result = $stmt->execute(array($id));
                 if (\OCP\DB::isError($result)) {
                     \OCP\Util::writeLog('files_antivirus', __METHOD__ . ', DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                     return;
                 }
                 $stmt = \OCP\DB::prepare('INSERT INTO `*PREFIX*files_antivirus` (`fileid`, `check_time`) VALUES (?, ?)');
                 $result = $stmt->execute(array($id, time()));
                 if (\OCP\DB::isError($result)) {
                     \OCP\Util::writeLog('files_antivirus', __METHOD__ . ', DB error: ' . \OC_DB::getErrorMessage($result), \OCP\Util::ERROR);
                     return;
                 }
             } catch (\Exception $e) {
                 \OCP\Util::writeLog('files_antivirus', __METHOD__ . ', exception: ' . $e->getMessage(), \OCP\Util::ERROR);
             }
             break;
     }
 }
Example #16
0
 protected function scan($fileView, $filepath)
 {
     $this->status = new Status();
     $fhandler = $this->getFileHandle($fileView, $filepath);
     \OCP\Util::writeLog('files_antivirus', 'Exec scan: ' . $filepath, \OCP\Util::DEBUG);
     $avCmdOptions = \OCP\Config::getAppValue('files_antivirus', 'av_cmd_options', '');
     $shellArgs = explode(',', $avCmdOptions);
     $shellArgs = array_map(function ($i) {
         return escapeshellarg($i);
     }, $shellArgs);
     $preparedArgs = '';
     if (count($shellArgs)) {
         $preparedArgs = implode(' ', $shellArgs);
     }
     // using 2>&1 to grab the full command-line output.
     $cmd = escapeshellcmd($this->avPath) . " " . $preparedArgs . " - 2>&1";
     $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"));
     $pipes = array();
     $process = proc_open($cmd, $descriptorSpec, $pipes);
     if (!is_resource($process)) {
         fclose($fhandler);
         throw new \RuntimeException('Error starting process');
     }
     // write to stdin
     $shandler = $pipes[0];
     while (!feof($fhandler)) {
         $chunk = fread($fhandler, $this->chunkSize);
         fwrite($shandler, $chunk);
     }
     fclose($shandler);
     fclose($fhandler);
     $output = stream_get_contents($pipes[1]);
     fclose($pipes[1]);
     $result = proc_close($process);
     $this->status->parseResponse($output, $result);
     return $this->status->getNumericStatus();
 }
Example #17
0
 /**
  * Check if a file requires encryption
  * @param string $path
  * @return bool
  *
  * Tests if server side encryption is enabled, and file is allowed by blacklists
  */
 private static function shouldEncrypt($path)
 {
     if (is_null(self::$enableEncryption)) {
         if (\OCP\Config::getAppValue('files_encryption', 'enable_encryption', 'true') === 'true' && Crypt::mode() === 'server') {
             self::$enableEncryption = true;
         } else {
             self::$enableEncryption = false;
         }
     }
     if (!self::$enableEncryption) {
         return false;
     }
     if (is_null(self::$blackList)) {
         self::$blackList = explode(',', \OCP\Config::getAppValue('files_encryption', 'type_blacklist', ''));
     }
     if (Crypt::isCatfileContent($path)) {
         return true;
     }
     $extension = substr($path, strrpos($path, '.') + 1);
     if (array_search($extension, self::$blackList) === false) {
         return true;
     }
     return false;
 }
Example #18
0
<?php

/**
 * ownCloud - Documents App
 *
 * @author Victor Dubiniuk
 * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 */
namespace OCA\Documents;

\OCP\JSON::callCheck();
$unstable = isset($_POST['unstable']) ? $_POST['unstable'] : null;
if (!is_null($unstable)) {
    \OCP\JSON::checkAdminUser();
    \OCP\Config::setAppValue('documents', 'unstable', $unstable);
    \OCP\JSON::success();
    exit;
}
if (isset($_GET['unstable'])) {
    \OCP\JSON::success(array('value' => \OCP\Config::getAppValue('documents', 'unstable', 'false')));
}
exit;
Example #19
0
 * 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 along with this library.  If not, see <http://www.gnu.org/licenses/>.
 * 
 */
namespace OCA\Documents;

\OCP\User::checkLoggedIn();
\OCP\JSON::checkAppEnabled('documents');
\OCP\App::setActiveNavigationEntry('documents_index');
\OCP\Util::addStyle('documents', 'style');
\OCP\Util::addStyle('documents', '3rdparty/webodf/dojo-app');
\OCP\Util::addScript('documents', 'documents');
\OCP\Util::addScript('files', 'file-upload');
\OCP\Util::addScript('files', 'jquery.iframe-transport');
\OCP\Util::addScript('files', 'jquery.fileupload');
$tmpl = new \OCP\Template('documents', 'documents', 'user');
$previewsEnabled = \OC::$server->getConfig()->getSystemValue('enable_previews', true);
$unstable = \OCP\Config::getAppValue('documents', 'unstable', 'false');
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
$savePath = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/');
$tmpl->assign('enable_previews', $previewsEnabled);
$tmpl->assign('useUnstable', $unstable);
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
$tmpl->assign('uploadMaxHumanFilesize', \OCP\Util::humanFileSize($maxUploadFilesize));
$tmpl->assign('savePath', $savePath);
$tmpl->assign("allowShareWithLink", \OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes'));
$tmpl->printPage();
Example #20
0
 /**
  * Check the password against privacyIDEA
  */
 public function checkPassword($uid, $password)
 {
     $authenticated_user = "";
     // check if we are called by a desktop client
     $allow_api = \OCP\Config::getAppValue('privacyIDEA', 'allow_api') === "yes";
     $client_call = basename($_SERVER['SCRIPT_NAME']) === 'remote.php';
     OC_Log::write('user_privacyidea', 'API: ' . $allow_api, OC_Log::DEBUG);
     OC_Log::write('user_privacyidea', 'Client Call: ' . $client_call, OC_Log::DEBUG);
     if ($client_call === true && $allow_api === true) {
         OC_Log::write('user_privacyidea', 'Authenticating with normal password', OC_Log::DEBUG);
         foreach (self::$_backends as $backendObj) {
             $r = $backendObj->checkPassword($uid, $password);
             if ($r) {
                 $authenticated_user = $r;
             }
         }
     } else {
         // We are called from within a browser.
         OCP\Util::writeLog('user_privacyidea', 'privacyIDEA checkPassword', OCP\Util::DEBUG);
         $sslcheck = \OCP\Config::getAppValue('privacyIDEA', 'verify_ssl');
         $allow_normal_login = \OCP\Config::getAppValue('privacyIDEA', 'allow_normal_login');
         $url = \OCP\Config::getAppValue('privacyIDEA', 'privacyidea_url');
         OCP\Util::writeLog('user_privacyidea', "calling " . $url . " for user " . $uid . " (" . $sslcheck . ")", OCP\Util::DEBUG);
         $result = $this->checkOtp($url, $uid, $password, $sslcheck);
         OCP\Util::writeLog('user_privacyidea', 'privacyidea returned ' . $result, OCP\Util::INFO);
         if ($result) {
             $authenticated_user = $uid;
         } else {
             if ($allow_normal_login === "yes") {
                 foreach (self::$_backends as $backendObj) {
                     $r = $backendObj->checkPassword($uid, $password);
                     if ($r) {
                         $authenticated_user = $r;
                     }
                 }
             }
         }
     }
     return $authenticated_user;
 }
Example #21
0
			<li class="special">
				<input class="add-group hidden" type="text" tabindex="0" autofocus placeholder="<?php p($l->t('Group name')); ?>" title="<?php p($l->t('New group')); ?>" />
			</li>
		</ul>
		<div id="app-settings">
			<div id="app-settings-header">
				<button class="settings-button" tabindex="0"></button>
			</div>
			<div id="app-settings-content">
				<div id="addressbooks">
				<h2 data-id="addressbooks" tabindex="0" role="button"><?php p($l->t('Address books')); ?></h2>
					<ul class="addressbooklist">
					</ul>
					<input type="text" tabindex="0" autofocus id="add-address-book" placeholder="<?php p($l->t('Display name')); ?>" title="<?php p($l->t('Add Address Book')); ?>" />
					<?php
					if (\OCP\Config::getAppValue('contacts', 'backend_ldap', "false") === "true") {
					?>
					<ul class="oc-addnew">
						<li id="add-ldap-address-book-element"><a class="oc-addnew-init"><?php p($l->t('Add LDAP Address Book')); ?></a></li>
					</ul>
					<?php
					}
					?>
				</div>
				<div id="import">
					<ul class="oc-addnew">
						<li id="import-contacts"><a class="oc-addnew-init"><?php p($l->t('Import')); ?></a></li>
					</ul>
				</div>
			</div> <!-- app-settings-content -->
		</div>
Example #22
0
File: jobs.php Project: evanjt/core
 /**
  * @return int
  */
 private static function getRefreshInterval()
 {
     //defaults to every hour
     return \OCP\Config::getAppValue('user_ldap', 'bgjRefreshInterval', 3600);
 }
Example #23
0
 /**
  * @param string $varName
  * @return string
  */
 protected function getValue($varName)
 {
     static $defaults;
     if (is_null($defaults)) {
         $defaults = $this->getDefaults();
     }
     return \OCP\Config::getAppValue('user_ldap', $this->configPrefix . $varName, $defaults[$varName]);
 }
Example #24
0
 /**
  * @return int
  */
 public static function getExpireInterval()
 {
     return (int) \OCP\Config::getAppValue('core', 'shareapi_expire_after_n_days', '7');
 }
Example #25
0
<?php

/**
 * Copyright (c) 2014 Victor Dubiniuk <*****@*****.**>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */
$installedVersion = \OCP\Config::getAppValue('files_antivirus', 'installed_version');
if (version_compare($installedVersion, '0.5', '<')) {
    \OCA\Files_Antivirus\Status::init();
}
if (version_compare($installedVersion, '0.6', '<')) {
    // remove the old job with old classname
    $jobList = new \OC\BackgroundJob\JobList();
    $jobs = $jobList->getAll();
    foreach ($jobs as $job) {
        $jobArg = $job->getArgument();
        if ($jobArg[0] == 'OC_Files_Antivirus_BackgroundScanner') {
            $jobList->remove($job);
        }
    }
}
Example #26
0
	/**
	 * Looks up an app wide defined value
	 *
	 * @param string $appName the appName that we stored the value under
	 * @param string $key the key of the value, under which it was saved
	 * @param string $default the default value to be returned if the value isn't set
	 * @return string the saved value
	 */
	public function getAppValue($appName, $key, $default = '') {
		return \OCP\Config::getAppValue($appName, $key, $default);
	}
Example #27
0
 /**
  * check if share API enforces a default expire date
  *
  * @return boolean
  */
 public static function isDefaultExpireDateEnforced()
 {
     $isDefaultExpireDateEnabled = \OCP\Config::getAppValue('core', 'shareapi_default_expire_date', 'no');
     $enforceDefaultExpireDate = false;
     if ($isDefaultExpireDateEnabled === 'yes') {
         $value = \OCP\Config::getAppValue('core', 'shareapi_enforce_expire_date', 'no');
         $enforceDefaultExpireDate = $value === 'yes' ? true : false;
     }
     return $enforceDefaultExpireDate;
 }
Example #28
0
 $dn = \OCA\user_shibboleth\Auth::getDisplayName();
 //exit if attributes weren't retrieved
 if ($persistentId === false || $mail === false) {
     $msg = 'unavailable attributes: ';
     if ($persistentId === false) {
         $msg .= 'persistentID ';
     }
     if ($mail === false) {
         $msg .= 'mail';
     }
     \OCP\Util::writeLog('user_shibboleth', $msg, \OCP\Util::ERROR);
     \OCA\user_shibboleth\LoginLib::printPage('Attributes unavailable', 'Some attributes could not be retrieved from the identity provider.<p/><a href="' . \OC::$WEBROOT . '">Return to the login page</a>');
     exit;
 }
 //check for potential email address spoofing
 if (\OCP\Config::getAppValue('user_shibboleth', 'enforce_domain_similarity', '0') === '1' && !\OCA\user_shibboleth\LoginLib::checkMailOrigin($idp, $mail)) {
     //log and print error page
     \OCP\Util::writeLog('user_shibboleth', 'domain mismatch: ' . $idp . ' ' . $mail, \OCP\Util::ERROR);
     \OCA\user_shibboleth\LoginLib::printPage('Domain Mismatch', 'The domain of your identity provider does not match the domain part of your email address. This event has been logged.');
     exit;
 }
 //distinguish between internal (those in the LDAP) and external Shibboleth users
 $adapter = new \OCA\user_shibboleth\LdapBackendAdapter();
 $loginName = $adapter->getUuid($mail);
 if ($loginName) {
     //user is internal, backends are enabled, and user mapping is active
     $adapter->initializeUser($loginName);
 } else {
     //user is external
     //crop $mail to fit into display_name column of oc_shibboleth_user
     if (strlen($mail) > 64) {
Example #29
0
*
* You should have received a copy of the GNU Affero General Public
* License along with this library.
* If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
 * @file content.php
 * Content of the imprint as configured
 * @access public
 */
// Session checks
// \OCP\User::checkLoggedIn();
\OCP\App::checkAppEnabled('imprint');
// prepare content
if (FALSE === ($content = \OCP\Config::getAppValue('imprint', 'content', FALSE))) {
    $tmpl = new \OCP\Template('imprint', 'tmpl_dummy');
    \OCP\Util::addStyle('imprint', 'reference');
} else {
    // detect type of stored content and process accordingly
    if (strlen($content) != strlen(strip_tags($content))) {
        $processed_content = $content;
    } else {
        $processed_content = sprintf("<pre>\n%s\n</pre>", $content);
    }
    // output processed content
    \OCP\Util::addStyle('imprint', 'content');
    $tmpl = new \OCP\Template('imprint', 'tmpl_content');
    $tmpl->assign('processed-content', $processed_content);
}
// render template
Example #30
0
 public static function getRecentBackupPath()
 {
     return \OCP\Config::getAppValue(self::APP_ID, self::LAST_BACKUP_PATH, '');
 }