#include <NGObjWeb/SoHTTPAuthenticator.h>
+/*
+ SOGoAuthenticator
+
+ This just overrides the login/pwd check method and always returns YES since
+ the password is already checked in Apache.
+*/
+
@interface SOGoAuthenticator : SoHTTPAuthenticator
{
}
+2004-10-21 Helge Hess <helge.hess@opengroupware.org>
+
+ * SOGoMailBaseObject.m: extract IMAP4 password from HTTP basic
+ authentication (v0.9.36)
+
2004-10-20 Marcus Mueller <znek@mulle-kybernetik.com>
* SOGoMailAccounts.m: changed methods according to new API of
#include "SOGoMailManager.h"
#include "common.h"
#include <NGObjWeb/SoObject+SoDAV.h>
+#include <NGObjWeb/SoHTTPAuthenticator.h>
#include <NGExtensions/NSURL+misc.h>
@implementation SOGoMailBaseObject
-static BOOL debugOn = YES;
+//static BOOL debugOn = YES;
static BOOL debugTree = NO;
- (id)initWithImap4URL:(NSURL *)_url inContainer:(id)_container {
}
- (NSString *)imap4Password {
- return [[NSUserDefaults standardUserDefaults] stringForKey:@"hackpwd"];
+ /*
+ Extract password from basic authentication.
+
+ TODO: we might want to
+ a) move the primary code to SOGoMailAccount
+ b) cache the password
+ */
+ WORequest *rq;
+ NSString *auth;
+ NSArray *creds;
+
+ rq = [[(WOApplication *)[WOApplication application] context] request];
+ if ((auth = [rq headerForKey:@"authorization"]) == nil) {
+ /* no basic auth */
+ return nil;
+ }
+
+ creds = [SoHTTPAuthenticator parseCredentials:auth];
+ if ([creds count] < 2)
+ /* somehow invalid */
+ return nil;
+
+ return [creds objectAtIndex:1]; /* the password */
}
- (NGImap4Client *)imap4ClientForURL:(NSURL *)_url password:(NSString *)_pwd {