steffen: server/kolab-resource-handlers/kolab-resource-handlers/freebusy freebusy, 1.1.1.1, 1.2

cvs at intevation.de cvs at intevation.de
Tue Jun 15 01:48:23 CEST 2004


Author: steffen

Update of /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy
In directory doto:/tmp/cvs-serv28038/kolab-resource-handlers/freebusy

Modified Files:
	freebusy 
Log Message:
use supplied credentials

Index: freebusy
===================================================================
RCS file: /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/freebusy,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- freebusy	11 Jun 2004 10:52:23 -0000	1.1.1.1
+++ freebusy	14 Jun 2004 23:48:21 -0000	1.2
@@ -45,17 +45,18 @@
     exit;
 }
 
-function forbidden($errortext = '')
+function unauthorized($errortext = '')
 {
     shutdown();
 
-    header('HTTP/1.0 403 Forbidden');
+    header('WWW-Authenticate: Basic realm="freebusy-'.$params['email_domain'].'"');
+    header('HTTP/1.0 401 Unauthorized');
 
     echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
 <html><head>
-<title>403 Forbidden</title>
+<title>401 Unauthorized</title>
 </head><body>
-<h1>Forbidden</h1>
+<h1>Unauthorized</h1>
 <p>You are not authorized to access the requested URL.</p>
 ';
 
@@ -87,8 +88,9 @@
 
     $errortext .= 'IMAP Error: ' . join("\nIMAP Error: ", $errors);
 
-    if (array_pop($errors) == 'Permission denied') {
-        forbidden($errortext);
+    $err = array_pop($errors);
+    if ( $err == 'Permission denied' || $err == 'Invalid credentials' || $err == 'Login aborted' ) {
+        unauthorized($errortext);
     }
 
     notFound($errortext);
@@ -283,12 +285,21 @@
 }
 
 // Get our mailbox strings for use in the imap_X functions
-$server = '{' . $params['server'] . '/imap/notls/novalidate-cert}';
+$server = '{' . $params['server'] . ':143/imap/notls/novalidate-cert}';
 $mailbox = "user/$prefix/" . $params['calendar_store'] . "$suffix";
 $fullmbox = $server . $mailbox;
 
+$imapuser = $_SERVER['PHP_AUTH_USER'];
+$imappw = $_SERVER['PHP_AUTH_PW'];
+if( !$imapuser ) {
+	$imapuser = $params['calendar_user'];
+	$imapps = $params['calendar_pass'];
+}
+
+trigger_error( "user=$imapuser, mailbox=$fullmbox", E_USER_NOTICE );
+
 // Open an IMAP connection to the requested users' calendar
-$imap = @imap_open($fullmbox, $params['calendar_user'], $params['calendar_pass']);
+$imap = @imap_open($fullmbox, $imapuser, $imappw);
 testIMAPError();
 
 // Enumerate our calendar events





More information about the commits mailing list