From 76cbbe3a05094386ad01286011a2499b78a736ad Mon Sep 17 00:00:00 2001 From: Wolfgang Sourdeau Date: Mon, 18 Jun 2007 15:37:37 +0000 Subject: [PATCH] Monotone-Parent: 3972d71b4e36835c89743644fadfbba2dbb04d93 Monotone-Revision: aef31cd9268feda455bc506f04dcaee7b64ed80d Monotone-Author: wsourdeau@inverse.ca Monotone-Date: 2007-06-18T15:37:37 Monotone-Branch: ca.inverse.sogo --- SoObjects/SOGo/SOGoAuthenticator.m | 35 +++++++++++++--- SoObjects/SOGo/SOGoContentObject.m | 9 +++- SoObjects/SOGo/SOGoFolder.m | 15 +++++-- SoObjects/SOGo/SOGoGroupsFolder.m | 66 ++++++++++++++++++------------ 4 files changed, 89 insertions(+), 36 deletions(-) diff --git a/SoObjects/SOGo/SOGoAuthenticator.m b/SoObjects/SOGo/SOGoAuthenticator.m index 19d1fbdc2..0c8d5c0a8 100644 --- a/SoObjects/SOGo/SOGoAuthenticator.m +++ b/SoObjects/SOGo/SOGoAuthenticator.m @@ -19,14 +19,19 @@ 02111-1307, USA. */ +#import +#import +#import + +#import +#import #import -#import "SOGoPermissions.h" #import "LDAPUserManager.h" +#import "SOGoPermissions.h" +#import "SOGoUser.h" #import "SOGoAuthenticator.h" -#import "SOGoUser.h" -#import "common.h" @implementation SOGoAuthenticator @@ -79,6 +84,23 @@ && [_pwd isEqualToString: @"freebusy"])); } +- (NSString *) _passwordInContext: (WOContext *) context +{ + NSString *auth, *password; + NSArray *creds; + + password = nil; + auth = [[context request] headerForKey:@"authorization"]; + if (auth) + { + creds = [self parseCredentials: auth]; + if ([creds count] > 1) + password = [creds objectAtIndex: 1]; + } + + return password; +} + /* create SOGoUser */ - (SOGoUser *) userInContext: (WOContext *)_ctx @@ -109,8 +131,11 @@ user = anonymous; } else - user = [SOGoUser userWithLogin: login - roles: [self rolesForLogin: login]]; + { + user = [SOGoUser userWithLogin: login + roles: [self rolesForLogin: login]]; + [user setCurrentPassword: [self _passwordInContext: _ctx]]; + } } else user = nil; diff --git a/SoObjects/SOGo/SOGoContentObject.m b/SoObjects/SOGo/SOGoContentObject.m index 344e9c286..945382da5 100644 --- a/SoObjects/SOGo/SOGoContentObject.m +++ b/SoObjects/SOGo/SOGoContentObject.m @@ -19,9 +19,16 @@ 02111-1307, USA. */ +#import +#import +#import + +#import +#import +#import +#import #import -#import "common.h" #import "SOGoFolder.h" #import "SOGoUser.h" #import "SOGoPermissions.h" diff --git a/SoObjects/SOGo/SOGoFolder.m b/SoObjects/SOGo/SOGoFolder.m index db2a8946c..7d914d396 100644 --- a/SoObjects/SOGo/SOGoFolder.m +++ b/SoObjects/SOGo/SOGoFolder.m @@ -19,7 +19,18 @@ 02111-1307, USA. */ +#import +#import + +#import +#import +#import +#import + #import +#import +#import +#import #import #import #import @@ -27,10 +38,8 @@ #import #import "SOGoPermissions.h" + #import "SOGoFolder.h" -#import "common.h" -#import -#import static NSString *defaultUserID = @""; diff --git a/SoObjects/SOGo/SOGoGroupsFolder.m b/SoObjects/SOGo/SOGoGroupsFolder.m index ee71c7f70..b29aeb667 100644 --- a/SoObjects/SOGo/SOGoGroupsFolder.m +++ b/SoObjects/SOGo/SOGoGroupsFolder.m @@ -18,28 +18,31 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -// $Id: SOGoGroupsFolder.m 115 2004-06-30 11:57:37Z helge $ -#include "SOGoGroupsFolder.h" -#include "common.h" +#import +#import + +#import "SOGoGroupsFolder.h" @implementation SOGoGroupsFolder -- (void)dealloc { - [super dealloc]; -} +// - (void)dealloc { +// [super dealloc]; +// } /* accessors */ /* SOPE */ -- (BOOL)isFolderish { +- (BOOL) isFolderish +{ return YES; } /* looking up shared objects */ -- (SOGoGroupsFolder *)lookupGroupsFolder { +- (SOGoGroupsFolder *) lookupGroupsFolder +{ return self; } @@ -47,33 +50,42 @@ /* name lookup */ -- (id)customGroup:(NSString *)_key inContext:(id)_ctx { +- (id) customGroup: (NSString *) _key + inContext: (id) _ctx +{ static Class groupClass = Nil; id group; - - if (groupClass == Nil) + + if (!groupClass) groupClass = NSClassFromString(@"SOGoCustomGroupFolder"); - if (groupClass == Nil) { - [self logWithFormat:@"ERROR: missing SOGoCustomGroupFolder class!"]; - return nil; - } - - group = [[groupClass alloc] initWithName:_key inContainer:self]; - return [group autorelease]; + if (!groupClass) + { + [self logWithFormat:@"ERROR: missing SOGoCustomGroupFolder class!"]; + group = nil; + } + else + group = [groupClass objectWithName: _key inContainer: self]; + + return group; } -- (id)lookupName:(NSString *)_key inContext:(id)_ctx acquire:(BOOL)_flag { +- (id) lookupName: (NSString *) _key + inContext: (id) _ctx + acquire: (BOOL) _flag +{ id obj; /* first check attributes directly bound to the application */ - if ((obj = [super lookupName:_key inContext:_ctx acquire:NO])) - return obj; - - if ([_key hasPrefix:@"_custom_"]) - return [self customGroup:_key inContext:_ctx]; - - /* return 404 to stop acquisition */ - return [NSException exceptionWithHTTPStatus:404 /* Not Found */]; + obj = [super lookupName: _key inContext: _ctx acquire: NO]; + if (!obj) + { + if ([_key hasPrefix: @"_custom_"]) + obj = [self customGroup: _key inContext: _ctx]; + else + obj = [NSException exceptionWithHTTPStatus:404 /* Not Found */]; + } + + return obj; } @end /* SOGoGroupsFolder */