See ChangeLog

Monotone-Parent: 4eb36e8b2021cf9b64520bb8434bff43f5716ee9
Monotone-Revision: 2a908e25e6cc0e1dd4272685f53fe6594d1c949c

Monotone-Author: ludovic@Sophos.ca
Monotone-Date: 2009-09-25T14:42:33
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Ludovic Marcotte 2009-09-25 14:42:33 +00:00
parent a8a1f20f35
commit 502279186e
43 changed files with 731 additions and 296 deletions

View File

@ -1,3 +1,16 @@
2009-09-25 Ludovic Marcotte <lmarcotte@inverse.ca>
* Renamed SoObjects/Contacts/SOGoContactLDAPFolder to
SoObjects/Contacts/SOGoContactSourceFolder
* Renamed SoObjects/SOGo/LDAPUserManager to
SoObjects/SOGo/SOGoserManager.m
* Added SoObjects/SOGo/SOGoSource.h and
SoObjects/SOGo/SQLSource.{h,m}
We now support authentication and address book sources
coming from a SQL database. This can be used concurrently
with LDAP sources. Modified many classes to reflect this
change.
2009-09-24 Cyril Robert <crobert@inverse.ca>
* SoObjects/Appointments/SOGoAppointmentFolder.m (bareFetchFields:): Handled

View File

@ -57,7 +57,7 @@
#import <SOGo/NSObject+DAV.h>
#import <SOGo/NSString+Utilities.h>
#import <SOGo/SOGoCache.h>
#import <SOGo/LDAPUserManager.h>
#import <SOGo/SOGoUserManager.h>
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/SOGoPermissions.h>
#import <SOGo/SOGoUser.h>
@ -2873,7 +2873,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
{
/* Note: can return NSNull objects in the array! */
NSMutableArray *uids;
LDAPUserManager *um;
SOGoUserManager *um;
unsigned i, count;
iCalPerson *person;
NSString *email;
@ -2883,7 +2883,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
{
count = [_persons count];
uids = [NSMutableArray arrayWithCapacity:count + 1];
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
for (i = 0; i < count; i++)
{

View File

@ -38,7 +38,7 @@
#import <SOPE/NGCards/NSString+NGCards.h>
#import <SoObjects/SOGo/iCalEntityObject+Utilities.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoUserManager.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
#import <SoObjects/SOGo/NSObject+DAV.h>
#import <SoObjects/SOGo/SOGoObject.h>
@ -971,7 +971,7 @@
BOOL isUpdate, hasChanged;
elements = [NSMutableArray array];
ownerUID = [[LDAPUserManager sharedUserManager]
ownerUID = [[SOGoUserManager sharedUserManager]
getUIDForEmail: originator];
eventOwner = [self iCalPersonWithUID: ownerUID];
emailEvent = [self component: NO secure: NO];
@ -1138,7 +1138,7 @@
elements = [NSMutableArray array];
ownerUID = [[LDAPUserManager sharedUserManager]
ownerUID = [[SOGoUserManager sharedUserManager]
getUIDForEmail: originator];
event = [self component: NO secure: NO];
recipientsEnum = [recipients objectEnumerator];
@ -1272,7 +1272,7 @@
elements = [NSMutableArray array];
event = [self component: NO secure: NO];
[[event parent] setMethod: @""];
ownerUser = [SOGoUser userWithLogin: [[LDAPUserManager sharedUserManager]
ownerUser = [SOGoUser userWithLogin: [[SOGoUserManager sharedUserManager]
getUIDForEmail: originator]];
attendee = [event findParticipant: ownerUser];
eventUID = [event uid];

View File

@ -27,13 +27,13 @@
#import <NGCards/iCalEvent.h>
#import <NGCards/iCalPerson.h>
#import <SOGo/LDAPUserManager.h>
#import <SOGo/SOGoUserManager.h>
#import <SOGo/SOGoDateFormatter.h>
#import <SOGo/SOGoUser.h>
#import "SOGoAptMailReceipt.h"
static LDAPUserManager *um = nil;
static SOGoUserManager *um = nil;
@implementation SOGoAptMailReceipt
@ -41,7 +41,7 @@ static LDAPUserManager *um = nil;
+ (void) initialize
{
if (!um)
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
}
- (id) init

View File

@ -42,7 +42,7 @@
#import <NGMail/NGMimeMessage.h>
#import <SOGo/iCalEntityObject+Utilities.h>
#import <SOGo/LDAPUserManager.h>
#import <SOGo/SOGoUserManager.h>
#import <SOGo/NSCalendarDate+SOGo.h>
#import <SOGo/NSDictionary+Utilities.h>
#import <SOGo/SOGoMailer.h>
@ -590,7 +590,7 @@ static inline BOOL _occurenceHasID (iCalRepeatableEntityObject *occurence, NSStr
{
NSString *uid;
uid = [[LDAPUserManager sharedUserManager] getUIDForEmail: email];
uid = [[SOGoUserManager sharedUserManager] getUIDForEmail: email];
return [[SOGoUser userWithLogin: uid] timeZone];
}
@ -926,10 +926,10 @@ static inline BOOL _occurenceHasID (iCalRepeatableEntityObject *occurence, NSStr
- (iCalPerson *) iCalPersonWithUID: (NSString *) uid
{
iCalPerson *person;
LDAPUserManager *um;
SOGoUserManager *um;
NSDictionary *contactInfos;
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
contactInfos = [um contactInfosForUserWithUIDorEmail: uid];
person = [iCalPerson new];

View File

@ -32,7 +32,7 @@
#import <NGCards/iCalFreeBusy.h>
#import <NGCards/iCalPerson.h>
#import <SOGo/LDAPUserManager.h>
#import <SOGo/SOGoUserManager.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoPermissions.h>
@ -74,10 +74,10 @@ static unsigned int freebusyRangeEnd = 0;
- (iCalPerson *) iCalPersonWithUID: (NSString *) uid
{
iCalPerson *person;
LDAPUserManager *um;
SOGoUserManager *um;
NSDictionary *contactInfos;
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
contactInfos = [um contactInfosForUserWithUIDorEmail: uid];
/* iCal.app compatibility:

View File

@ -1,6 +1,6 @@
/* iCalEvent+SOGo.h - this file is part of SOGo
*
* Copyright (C) 2007 Inverse inc.
* Copyright (C) 2007-2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*

View File

@ -1,6 +1,6 @@
/* iCalPerson+SOGo.h - this file is part of SOGo
*
* Copyright (C) 2007-2008 Inverse inc.
* Copyright (C) 2007-2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@ -25,8 +25,6 @@
#import <NGCards/iCalPerson.h>
#import <SOGo/LDAPUserManager.h>
@class NSString;
@interface iCalPerson (SOGoExtension)

View File

@ -1,6 +1,6 @@
/* iCalPerson+SOGo.m - this file is part of SOGo
*
* Copyright (C) 2007-2008 Inverse inc.
* Copyright (C) 2007-2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@ -21,10 +21,11 @@
*/
#import <Foundation/NSString.h>
#import <SOGo/SOGoUserManager.h>
#import "iCalPerson+SOGo.h"
static LDAPUserManager *um = nil;
static SOGoUserManager *um = nil;
@implementation iCalPerson (SOGoExtension)
@ -45,7 +46,7 @@ static LDAPUserManager *um = nil;
- (NSString *) uid
{
if (!um)
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
return [um getUIDForEmail: [self rfc822Email]];
}

View File

@ -17,7 +17,7 @@ Contacts_OBJC_FILES = \
SOGoContactGCSList.m \
SOGoContactGCSFolder.m \
SOGoContactLDIFEntry.m \
SOGoContactLDAPFolder.m \
SOGoContactSourceFolder.m \
SOGoUserFolder+Contacts.m \
Contacts_RESOURCE_FILES += \

View File

@ -32,10 +32,10 @@
#import <Foundation/NSString.h>
#import <Foundation/NSEnumerator.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoUserManager.h>
#import "SOGoContactGCSFolder.h"
#import "SOGoContactLDAPFolder.h"
#import "SOGoContactSourceFolder.h"
#import "SOGoContactFolders.h"
@implementation SOGoContactFolders
@ -52,20 +52,20 @@
- (NSException *) appendSystemSources
{
LDAPUserManager *um;
SOGoUserManager *um;
NSEnumerator *sourceIDs;
NSString *currentSourceID, *srcDisplayName;
SOGoContactLDAPFolder *currentFolder;
SOGoContactSourceFolder *currentFolder;
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
sourceIDs = [[um addressBookSourceIDs] objectEnumerator];
while ((currentSourceID = [sourceIDs nextObject]))
{
srcDisplayName = [um displayNameForSourceWithID: currentSourceID];
currentFolder = [SOGoContactLDAPFolder folderWithName: currentSourceID
andDisplayName: srcDisplayName
inContainer: self];
[currentFolder setLDAPSource: [um sourceWithID: currentSourceID]];
currentFolder = [SOGoContactSourceFolder folderWithName: currentSourceID
andDisplayName: srcDisplayName
inContainer: self];
[currentFolder setSource: [um sourceWithID: currentSourceID]];
[subFolders setObject: currentFolder forKey: currentSourceID];
}

View File

@ -53,21 +53,6 @@
@implementation SOGoContactGCSFolder
/* name lookup */
//- (id <SOGoContactObject>) lookupContactWithId: (NSString *) recordId
//{
// SOGoContactGCSEntry *contact;
//
// if ([recordId length] > 0)
// contact = [SOGoContactGCSEntry objectWithName: recordId
// inContainer: self];
// else
// contact = nil;
//
// return contact;
//}
- (Class) objectClassForContent: (NSString *) content
{
CardGroup *cardEntry;
@ -171,44 +156,6 @@
return obj;
}
// - (id) lookupName: (NSString *) _key
// inContext: (WOContext *) _ctx
// acquire: (BOOL) _flag
// {
// id obj;
// BOOL isPut;
// isPut = NO;
// obj = [super lookupName:_key inContext:_ctx acquire:NO];
// if (!obj)
// {
// if ([[[_ctx request] method] isEqualToString: @"PUT"])
// {
// if ([_key isEqualToString: @"PUT"])
// isPut = YES;
// else
// obj = [SOGoContactGCSEntry objectWithName: _key
// inContainer: self];
// }
// else
// obj = [self lookupContactWithId: _key];
// }
// if (!(obj || isPut))
// obj = [NSException exceptionWithHTTPStatus:404 /* Not Found */];
// #if 0
// if ([[self ocsFolder] versionOfContentWithName:_key])
// #endif
// return [self contactWithName:_key inContext:_ctx];
// }
// /* return 404 to stop acquisition */
// return obj;
// }
/* fetching */
- (EOQualifier *) _qualifierForFilter: (NSString *) filter
{
NSString *qs;
@ -304,8 +251,6 @@
}
else
records = nil;
// else
//[self errorWithFormat:@"(%s): fetch failed!", __PRETTY_FUNCTION__];
[self debugWithFormat:@"fetched %i records.", [records count]];
return records;
@ -387,7 +332,7 @@
NSComparisonResult comparison;
if ([NSStringFromClass([otherFolder class])
isEqualToString: @"SOGoContactLDAPFolder"])
isEqualToString: @"SOGoContactSourceFolder"])
comparison = NSOrderedAscending;
else
comparison = [super compare: otherFolder];

View File

@ -82,11 +82,11 @@
{
NSString *info;
info = [ldifEntry objectForKey: @"telephoneNumber"];
info = [ldifEntry objectForKey: @"telephonenumber"];
if (info)
[vCard addTel: info
types: [NSArray arrayWithObjects: @"work", @"voice", @"pref", nil]];
info = [ldifEntry objectForKey: @"homePhone"];
info = [ldifEntry objectForKey: @"homephone"];
if (info)
[vCard addTel: info
types: [NSArray arrayWithObjects: @"home", @"voice", nil]];
@ -123,7 +123,7 @@
[vcard setVClass: @"PUBLIC"];
[vcard setProdID: @"-//Inverse inc./SOGo 1.0//EN"];
[vcard setProfile: @"vCard"];
info = [ldifEntry objectForKey: @"displayName"];
info = [ldifEntry objectForKey: @"displayname"];
if (!(info && [info length] > 0))
info = [ldifEntry objectForKey: @"cn"];
[vcard setFn: info];
@ -131,14 +131,14 @@
if (!surname)
surname = [ldifEntry objectForKey: @"surname"];
[vcard setNWithFamily: surname
given: [ldifEntry objectForKey: @"givenName"]
given: [ldifEntry objectForKey: @"givenname"]
additional: nil
prefixes: nil
suffixes: nil];
info = [ldifEntry objectForKey: @"title"];
if (info)
[vcard setTitle: info];
info = [ldifEntry objectForKey: @"mozillaNickname"];
info = [ldifEntry objectForKey: @"mozillanickname"];
if (info)
[vcard setNickname: info];
@ -162,7 +162,7 @@
[self _setPhonesOfVCard: vcard];
streetAddress = [ldifEntry objectForKey: @"street"];
if (!streetAddress) streetAddress = [ldifEntry objectForKey: @"streetAddress"];
if (!streetAddress) streetAddress = [ldifEntry objectForKey: @"streetaddress"];
location = [ldifEntry objectForKey: @"l"];
if (!location) location = [ldifEntry objectForKey: @"locality"];
@ -170,7 +170,7 @@
region = [ldifEntry objectForKey: @"st"];
if (!region) region = [ldifEntry objectForKey: @"region"];
postalCode = [ldifEntry objectForKey: @"postalCode"];
postalCode = [ldifEntry objectForKey: @"postalcode"];
if (!postalCode) postalCode = [ldifEntry objectForKey: @"zip"];
country = [ldifEntry objectForKey: @"c"];
@ -217,7 +217,7 @@
for (count = 1; count < 5; count++)
{
info = [ldifEntry objectForKey:
[NSString stringWithFormat: @"mozillaCustom%d",
[NSString stringWithFormat: @"mozillacustom%d",
count]];
if (info)
[vcard addChildWithTag: [NSString stringWithFormat: @"CUSTOM%d",

View File

@ -1,6 +1,6 @@
/* SOGoContactLDAPFolder.h - this file is part of SOGo
/* SOGoContactSourceFolder.h - this file is part of SOGo
*
* Copyright (C) 2006 Inverse inc.
* Copyright (C) 2006-2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@ -20,19 +20,19 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef SOGOCONTACTLDAPFOLDER_H
#define SOGOCONTACTLDAPFOLDER_H
#ifndef SOGOCONTACTSOURCEFOLDER_H
#define SOGOCONTACTSOURCEFOLDER_H
#import "SOGoContactFolder.h"
#import "SOGoFolder+CardDAV.h"
@class NSMutableDictionary;
@class LDAPSource;
#import "../SOGo/SOGoSource.h"
@interface SOGoContactLDAPFolder : SOGoFolder <SOGoContactFolder>
@interface SOGoContactSourceFolder : SOGoFolder <SOGoContactFolder>
{
LDAPSource *ldapSource;
id source;
NSMutableDictionary *entries;
}
@ -42,9 +42,9 @@
- (id) initWithName: (NSString *) newName
andDisplayName: (NSString *) newDisplayName
inContainer: (id) newContainer;
- (void) setLDAPSource: (LDAPSource *) newLdapSource;
- (void) setSource: (id) newSource;
@end
#endif /* SOGOCONTACTLDAPFOLDER_H */
#endif /* SOGOCONTACTSOURCEFOLDER_H */

View File

@ -1,4 +1,4 @@
/* SOGoContactLDAPFolder.m - this file is part of SOGo
/* SOGoContactSourceFolder.m - this file is part of SOGo
*
* Copyright (C) 2006-2009 Inverse inc.
*
@ -40,14 +40,13 @@
#import <SaxObjC/XMLNamespaces.h>
#import <SoObjects/SOGo/SOGoPermissions.h>
#import <SoObjects/SOGo/LDAPSource.h>
#import <SoObjects/SOGo/NSString+Utilities.h>
#import "SOGoContactLDIFEntry.h"
#import "SOGoContactLDAPFolder.h"
#import "SOGoContactSourceFolder.h"
@class WOContext;
@implementation SOGoContactLDAPFolder
@implementation SOGoContactSourceFolder
#warning this should be unified within SOGoFolder
- (void) appendObject: (NSDictionary *) object
@ -111,7 +110,7 @@
if ((self = [super init]))
{
entries = nil;
ldapSource = nil;
source = nil;
}
return self;
@ -133,13 +132,13 @@
- (void) dealloc
{
[entries release];
[ldapSource release];
[source release];
[super dealloc];
}
- (void) setLDAPSource: (LDAPSource *) newLDAPSource
- (void) setSource: (id) newSource
{
ASSIGN (ldapSource, newLDAPSource);
ASSIGN (source, newSource);
}
- (NSString *) groupDavResourceType
@ -166,17 +165,15 @@
inContext: (WOContext *) lookupContext
acquire: (BOOL) acquire
{
id obj;
NSDictionary *ldifEntry;
//NSLog (@"looking up name '%@'...", objectName);
id obj;
/* first check attributes directly bound to the application */
obj = [super lookupName: objectName inContext: lookupContext acquire: NO];
if (!obj)
{
ldifEntry = [ldapSource lookupContactEntry: objectName];
ldifEntry = [source lookupContactEntry: objectName];
if (ldifEntry)
obj = [SOGoContactLDIFEntry contactEntryWithName: objectName
withLDIFEntry: ldifEntry
@ -190,7 +187,7 @@
- (NSArray *) toOneRelationshipKeys
{
return [ldapSource allEntryIDs];
return [source allEntryIDs];
}
- (NSArray *) _flattenedRecords: (NSArray *) records
@ -218,7 +215,7 @@
[newRecord setObject: [oldRecord objectForKey: @"c_name"]
forKey: @"c_name"];
data = [oldRecord objectForKey: @"displayName"];
data = [oldRecord objectForKey: @"displayname"];
if (!data)
data = [oldRecord objectForKey: @"c_cn"];
if (!data)
@ -230,7 +227,7 @@
data = @"";
[newRecord setObject: data forKey: @"c_mail"];
data = [oldRecord objectForKey: @"nsAIMid"];
data = [oldRecord objectForKey: @"nsaimid"];
if (![data length])
data = [oldRecord objectForKey: @"nscpaimscreenname"];
if (![data length])
@ -242,15 +239,17 @@
data = @"";
[newRecord setObject: data forKey: @"c_o"];
data = [oldRecord objectForKey: @"telephoneNumber"];
data = [oldRecord objectForKey: @"telephonenumber"];
if (![data length])
data = [oldRecord objectForKey: @"cellphone"];
if (![data length])
data = [oldRecord objectForKey: @"homePhone"];
data = [oldRecord objectForKey: @"homephone"];
if (![data length])
data = @"";
[newRecord setObject: data forKey: @"c_telephonenumber"];
// Custom attribute for group-lookups. See LDAPSource.m where
// it's set.
data = [oldRecord objectForKey: @"isGroup"];
if (data)
[newRecord setObject: data forKey: @"isGroup"];
@ -281,7 +280,7 @@
if (filter && [filter length] > 0)
{
records = [self _flattenedRecords:
[ldapSource fetchContactsMatching: filter]];
[source fetchContactsMatching: filter]];
ordering
= [EOSortOrdering sortOrderingWithKey: sortKey
selector: ((sortOrdering == NSOrderedDescending)

View File

@ -20,7 +20,7 @@
SOGoContactGCSList = {
superclass = "SOGoContentObject";
};
SOGoContactLDAPFolder = {
SOGoContactSourceFolder = {
superclass = "SOGoGCSFolder";
protectedBy = "Access Contents Information";
defaultRoles = {

View File

@ -23,8 +23,9 @@ SOGo_HEADER_FILES = \
SOGoParentFolder.h \
SOGoUserFolder.h \
\
LDAPUserManager.h \
SOGoUserManager.h \
LDAPSource.h \
SQLSource.h \
SOGoUserDefaults.h \
SOGoDateFormatter.h \
SOGoPermissions.h \
@ -76,8 +77,9 @@ SOGo_OBJC_FILES = \
\
SOGoDateFormatter.m \
SOGoPermissions.m \
LDAPUserManager.m \
SOGoUserManager.m \
LDAPSource.m \
SQLSource.m \
SOGoUserDefaults.m \
iCalEntityObject+Utilities.m \
NSArray+DAV.m \

View File

@ -25,12 +25,14 @@
#import <Foundation/NSObject.h>
#include "SOGoSource.h"
@class NSDictionary;
@class NSString;
@class NGLdapConnection;
@class NGLdapEntry;
@interface LDAPSource : NSObject
@interface LDAPSource : NSObject <SOGoSource>
{
NSString *sourceID;
NSString *bindDN;

View File

@ -32,7 +32,6 @@
#import <NGLdap/NGLdapAttribute.h>
#import <NGLdap/NGLdapEntry.h>
#import "LDAPUserManager.h"
#import "NSArray+Utilities.h"
#import "NSString+Utilities.h"
@ -68,16 +67,16 @@ static NSLock *lock;
@"title",
@"company",
@"o",
@"displayName",
@"displayname",
@"modifytimestamp",
@"mozillaHomeState",
@"mozillaHomeUrl",
@"mozillahomestate",
@"mozillahomeurl",
@"homeurl",
@"st",
@"region",
@"mozillaCustom2",
@"mozillacustom2",
@"custom2",
@"mozillaHomeCountryName",
@"mozillahomecountryname",
@"description",
@"notes",
@"department",
@ -87,36 +86,36 @@ static NSLock *lock;
@"mobile",
@"cellphone",
@"carphone",
@"mozillaCustom1",
@"mozillacustom1",
@"custom1",
@"mozillaNickname",
@"mozillanickname",
@"xmozillanickname",
@"mozillaWorkUrl",
@"mozillaworkurl",
@"workurl",
@"fax",
@"facsimileTelephoneNumber",
@"telephoneNumber",
@"mozillaHomeStreet",
@"mozillaSecondEmail",
@"facsimiletelephonenumber",
@"telephonenumber",
@"mozillahomestreet",
@"mozillasecondemail",
@"xmozillasecondemail",
@"mozillaCustom4",
@"mozillacustom4",
@"custom4",
@"nsAIMid",
@"nsaimid",
@"nscpaimscreenname",
@"street",
@"streetAddress",
@"postOfficeBox",
@"homePhone",
@"streetaddress",
@"postofficebox",
@"homephone",
@"cn",
@"commonname",
@"givenName",
@"mozillaHomePostalCode",
@"mozillaHomeLocalityName",
@"mozillaWorkStreet2",
@"mozillaUseHtmlMail",
@"givenname",
@"mozillahomepostalcode",
@"mozillahomelocalityname",
@"mozillaworkstreet2",
@"mozillausehtmlmail",
@"xmozillausehtmlmail",
@"mozillaHomeStreet2",
@"postalCode",
@"mozillahomestreet2",
@"postalcode",
@"zip",
@"c",
@"countryname",
@ -125,13 +124,13 @@ static NSLock *lock;
@"mail",
@"sn",
@"surname",
@"mozillaCustom3",
@"mozillacustom3",
@"custom3",
@"l",
@"locality",
@"birthyear",
@"serialNumber",
@"calFBURL", @"proxyAddresses",
@"serialnumber",
@"calfburl", @"proxyaddresses",
nil];
[commonSearchFields retain];
@ -224,7 +223,7 @@ static NSLock *lock;
ASSIGN (_filter, [udSource objectForKey: @"filter"]);
ASSIGN (_scope, ([udSource objectForKey: @"scope"]
? [udSource objectForKey: @"scope"]
: @"sub"));
: (id)@"sub"));
return self;
}
@ -611,7 +610,7 @@ static NSLock *lock;
NSMutableArray *emails;
NSArray *allValues;
emails = [NSMutableArray new];
emails = [[NSMutableArray alloc] init];
emailFields = [mailFields objectEnumerator];
while ((currentFieldName = [emailFields nextObject]))
{
@ -667,34 +666,56 @@ static NSLock *lock;
NSMutableDictionary *contactEntry;
NSEnumerator *attributes;
NSString *currentAttribute, *value;
NSArray *classes;
NSMutableArray *classes;
id o;
contactEntry = [NSMutableDictionary dictionary];
[contactEntry setObject: [ldapEntry dn] forKey: @"dn"];
classes = [ldapEntry objectClasses];
attributes = [[self _searchAttributes] objectEnumerator];
// We get our objectClass attribute values. We lowercase
// everything for ease of search after.
o = [ldapEntry objectClasses];
classes = nil;
if (o)
{
int i, c;
classes = [NSMutableArray arrayWithArray: o];
c = [classes count];
for (i = 0; i < c; i++)
[classes replaceObjectAtIndex: i
withObject: [[classes objectAtIndex: i] lowercaseString]];
}
if (classes)
{
[contactEntry setObject: classes
forKey: @"objectClasses"];
forKey: @"objectclasses"];
// We check if our entry is a group. If so, we set the
// 'isGroup' custom attribute.
if ([classes containsObject: @"group"] ||
[classes containsObject: @"groupOfNames"] ||
[classes containsObject: @"groupOfUniqueNames"] ||
[classes containsObject: @"posixGroup"])
[classes containsObject: @"groupofnames"] ||
[classes containsObject: @"groupofuniquenames"] ||
[classes containsObject: @"posixgroup"])
{
[contactEntry setObject: [NSNumber numberWithInt: 1]
forKey: @"isGroup"];
}
}
while ((currentAttribute = [attributes nextObject]))
{
value = [[ldapEntry attributeWithName: currentAttribute]
stringValueAtIndex: 0];
// It's important here to set our attributes' key in lowercase.
if (value)
[contactEntry setObject: value forKey: currentAttribute];
[contactEntry setObject: value forKey: [currentAttribute lowercaseString]];
}
value = [[ldapEntry attributeWithName: IDField] stringValueAtIndex: 0];
if (!value)
value = @"";

View File

@ -28,7 +28,7 @@
#import <NGObjWeb/WOResponse.h>
#import <NGExtensions/NSObject+Logs.h>
#import "LDAPUserManager.h"
#import "SOGoUserManager.h"
#import "SOGoPermissions.h"
#import "SOGoUser.h"
@ -78,11 +78,11 @@
password: (NSString *) _pwd
{
BOOL accept;
LDAPUserManager *um;
SOGoUserManager *um;
if ([authMethod isEqualToString: @"LDAP"])
{
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
accept = [um checkLogin: _login andPassword: _pwd];
}
else

View File

@ -51,7 +51,7 @@
#import <Foundation/NSString.h>
#include "LDAPSource.h"
#include "LDAPUserManager.h"
#include "SOGoUserManager.h"
#include "SOGoUser.h"
#import <NGLdap/NGLdapConnection.h>
@ -117,12 +117,12 @@
if (!theValue)
return nil;
allSources = [[LDAPUserManager sharedUserManager] sourceIDs];
allSources = [[SOGoUserManager sharedUserManager] sourceIDs];
o = nil;
for (i = 0; i < [allSources count]; i++)
{
source = [[LDAPUserManager sharedUserManager] sourceWithID: [allSources objectAtIndex: i]];
source = [[SOGoUserManager sharedUserManager] sourceWithID: [allSources objectAtIndex: i]];
entry = [source performSelector: theSelector
withObject: theValue];
@ -167,7 +167,7 @@
NSString *dn, *login;
SOGoUser *user;
NSArray *o;
LDAPUserManager *um;
SOGoUserManager *um;
int i, c;
array = [NSMutableArray array];
@ -196,7 +196,7 @@
// We deal with a static group, let's add the members
if (c)
{
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
// We add members for whom we have their associated DN
for (i = 0; i < [dns count]; i++)

View File

@ -1,7 +1,7 @@
/* SOGoGCSFolder.m - this file is part of SOGo
*
* Copyright (C) 2004-2005 SKYRIX Software AG
* Copyright (C) 2006-2008 Inverse inc.
* Copyright (C) 2006-2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@ -51,7 +51,6 @@
#import <NGCards/NSDictionary+NGCards.h>
#import <UI/SOGoUI/SOGoACLAdvisory.h>
#import "LDAPUserManager.h"
#import "NSArray+Utilities.h"
#import "NSCalendarDate+SOGo.h"
#import "NSDictionary+Utilities.h"

View File

@ -31,7 +31,6 @@
#import <NGExtensions/NSObject+Logs.h>
#import "LDAPUserManager.h"
#import "SOGoPermissions.h"
#import "SOGoUser.h"

View File

@ -0,0 +1,49 @@
/* SOGoSource.h - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
*
* Author: Ludovic Marcotte <lmarcotte@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef SOGOSOURCE_H
#define SOGOSOURCE_H
#import <Foundation/NSObject.h>
@class NSDictionary;
@class NSString;
@protocol SOGoSource
+ (id) sourceFromUDSource: (NSDictionary *) udSource;
- (id) initFromUDSource: (NSDictionary *) udSource;
- (BOOL) checkLogin: (NSString *) login
andPassword: (NSString *) password;
- (NSDictionary *) lookupContactEntry: (NSString *) theID;
- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) entryID;
- (NSArray *) allEntryIDs;
- (NSArray *) fetchContactsMatching: (NSString *) filter;
- (NSString *) sourceID;
@end
#endif /* SOGOSOURCE_H */

View File

@ -37,7 +37,7 @@
#import <NGExtensions/NSNull+misc.h>
#import <NGExtensions/NSObject+Logs.h>
#import "LDAPUserManager.h"
#import "SOGoUserManager.h"
#import "NSArray+Utilities.h"
#import "SOGoCache.h"
#import "SOGoDateFormatter.h"
@ -259,7 +259,7 @@ _timeValue (NSString *key)
roles: (NSArray *) newRoles
trust: (BOOL) b
{
LDAPUserManager *um;
SOGoUserManager *um;
NSString *realUID;
_defaults = nil;
@ -274,7 +274,7 @@ _timeValue (NSString *key)
realUID = newLogin;
else
{
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
realUID = [[um contactInfosForUserWithUIDorEmail: newLogin]
objectForKey: @"c_uid"];
}
@ -327,9 +327,9 @@ _timeValue (NSString *key)
- (id) _fetchFieldForUser: (NSString *) field
{
NSDictionary *contactInfos;
LDAPUserManager *um;
SOGoUserManager *um;
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
contactInfos = [um contactInfosForUserWithUIDorEmail: login];
return [contactInfos objectForKey: field];
@ -406,7 +406,7 @@ _timeValue (NSString *key)
[self logWithFormat: @"'SOGoFallbackIMAP4Server' is not set"];
doSave = NO;
}
if (![LDAPUserManager defaultMailDomainIsConfigured])
if (![SOGoUserManager defaultMailDomainIsConfigured])
{
[self logWithFormat: @"'SOGoDefaultMailDomain' is not set"];
doSave = NO;
@ -724,7 +724,7 @@ _timeValue (NSString *key)
NSArray *mails;
unsigned int count, max;
imapLogin = [[LDAPUserManager sharedUserManager] getImapLoginForUID: login];
imapLogin = [[SOGoUserManager sharedUserManager] getImapLoginForUID: login];
imapServer = [self _fetchFieldForUser: @"c_imaphostname"];
if (!imapServer)
imapServer = fallbackIMAP4Server;

View File

@ -1,5 +1,6 @@
/*
Copyright (C) 2004-2005 SKYRIX Software AG
Copyright (C) 2007-2009 Inverse inc.
This file is part of OpenGroupware.org.
@ -51,7 +52,7 @@
#import "NSArray+Utilities.h"
#import "NSDictionary+Utilities.h"
#import "LDAPUserManager.h"
#import "SOGoUserManager.h"
#import "SOGoPermissions.h"
#import "SOGoUser.h"
#import "WORequest+SOGo.h"
@ -229,7 +230,7 @@ static NSString *LDAPContactInfoAttribute = nil;
results = [NSMutableDictionary dictionary];
contacts
= [[LDAPUserManager sharedUserManager] fetchUsersMatching: uid];
= [[SOGoUserManager sharedUserManager] fetchUsersMatching: uid];
enumerator = [contacts objectEnumerator];
while ((contact = [enumerator nextObject]))
{
@ -328,13 +329,13 @@ static NSString *LDAPContactInfoAttribute = nil;
{
NSArray *users, *owners;
NSString *ownerMatch;
LDAPUserManager *um;
SOGoUserManager *um;
owners = [NSMutableArray array];
if (davOwnerMatch)
{
ownerMatch = [self _userFromDAVuser: davOwnerMatch];
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
users = [[um fetchUsersMatching: ownerMatch]
sortedArrayUsingSelector: @selector (caseInsensitiveDisplayNameCompare:)];
owners = [users objectsForKey: @"c_uid" notFoundMarker: nil];
@ -391,7 +392,7 @@ static NSString *LDAPContactInfoAttribute = nil;
- (NSString *) _davFetchUsersMatching: (NSString *) user
{
LDAPUserManager *um;
SOGoUserManager *um;
NSMutableString *fetch;
NSDictionary *currentUser;
NSString *field, *login;
@ -402,7 +403,7 @@ static NSString *LDAPContactInfoAttribute = nil;
fetch = [NSMutableString string];
login = [[context activeUser] login];
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
// We sort our array - this is pretty useful for the
// SOGo Integrator extension, among other things.
@ -609,7 +610,7 @@ static NSString *LDAPContactInfoAttribute = nil;
- (NSString *) davDisplayName
{
return [[LDAPUserManager sharedUserManager]
return [[SOGoUserManager sharedUserManager]
getCNForUID: nameInContainer];
}

View File

@ -1,4 +1,4 @@
/* LDAPUserManager.h - this file is part of SOGo
/* SOGoUserManager.h - this file is part of SOGo
*
* Copyright (C) 2007-2009 Inverse inc.
*
@ -20,8 +20,8 @@
* Boston, MA 02111-1307, USA.
*/
#ifndef LDAPUSERMANAGER_H
#define LDAPUSERMANAGER_H
#ifndef SOGOUSERMANAGER_H
#define SOGOUSERMANAGER_H
#import <Foundation/NSObject.h>
@ -33,11 +33,11 @@
@class LDAPSource;
@interface LDAPUserManager : NSObject
@interface SOGoUserManager : NSObject
{
@private
NSMutableDictionary *sources;
NSMutableDictionary *sourcesMetadata;
NSMutableDictionary *_sources;
NSMutableDictionary *_sourcesMetadata;
}
+ (id) sharedUserManager;
@ -67,4 +67,4 @@
@end
#endif /* LDAPUSERMANAGER_H */
#endif /* SOGOUSERMANAGER_H */

View File

@ -1,4 +1,4 @@
/* LDAPUserManager.m - this file is part of SOGo
/* SOGoUserManager.m - this file is part of SOGo
*
* Copyright (C) 2007-2009 Inverse inc.
*
@ -29,10 +29,14 @@
#import <Foundation/NSValue.h>
#import <NGExtensions/NSObject+Logs.h>
#import "NSArray+Utilities.h"
#import "LDAPSource.h"
#import "LDAPUserManager.h"
#import "SOGoCache.h"
#include "NSArray+Utilities.h"
#include "SOGoSource.h"
#include "SOGoUserManager.h"
#include "SOGoCache.h"
#include "SOGoSource.h"
#include "LDAPSource.h"
#include "SQLSource.h"
static NSString *defaultMailDomain = nil;
static NSString *LDAPContactInfoAttribute = nil;
@ -43,7 +47,7 @@ static BOOL forceImapLoginWithEmail = NO;
static NSLock *lock = nil;
#endif
@implementation LDAPUserManager
@implementation SOGoUserManager
+ (void) initialize
{
@ -97,17 +101,25 @@ static NSLock *lock = nil;
- (void) _registerSource: (NSDictionary *) udSource
{
NSString *sourceID, *value, *type;
NSMutableDictionary *metadata;
LDAPSource *ldapSource;
NSString *sourceID, *value;
id<SOGoSource> ldapSource;
Class c;
sourceID = [udSource objectForKey: @"id"];
ldapSource = [LDAPSource sourceFromUDSource: udSource];
if (sourceID)
[sources setObject: ldapSource forKey: sourceID];
type = [udSource objectForKey: @"type"];
if (!type || [type caseInsensitiveCompare: @"ldap"] == NSOrderedSame)
c = [LDAPSource class];
else
[self errorWithFormat: @"id field missing in a LDAP source,"
@" check the SOGoLDAPSources defaults"];
c = [SQLSource class];
ldapSource = [c sourceFromUDSource: udSource];
if (sourceID)
[_sources setObject: ldapSource forKey: sourceID];
else
[self errorWithFormat: @"id field missing in an user source,"
@" check the SOGoUserSources defaults"];
metadata = [NSMutableDictionary dictionary];
value = [udSource objectForKey: @"canAuthenticate"];
if (value)
@ -121,27 +133,46 @@ static NSLock *lock = nil;
value = [udSource objectForKey: @"MailFieldNames"];
if (value)
[metadata setObject: value forKey: @"MailFieldNames"];
[sourcesMetadata setObject: metadata forKey: sourceID];
[_sourcesMetadata setObject: metadata forKey: sourceID];
}
- (void) _prepareLDAPSourcesWithDefaults: (NSUserDefaults *) ud
- (void) _prepareSourcesWithDefaults: (NSUserDefaults *) ud
{
id udSources;
id o, sources;
unsigned int count, max;
sources = [NSMutableDictionary new];
sourcesMetadata = [NSMutableDictionary new];
_sources = [[NSMutableDictionary alloc] init];
_sourcesMetadata = [[NSMutableDictionary alloc] init];
udSources = [ud arrayForKey: @"SOGoLDAPSources"];
if (udSources && [udSources isKindOfClass: [NSArray class]])
sources = [NSMutableArray array];
o = [ud arrayForKey: @"SOGoLDAPSources"];
if (o)
{
max = [udSources count];
[self errorWithFormat: @"Using depecrated SOGoLDAPSources default. You should now use SOGoUserSources."];
if ([o isKindOfClass: [NSArray class]])
[sources addObjectsFromArray: o];
else
[self errorWithFormat: @"SOGoLDAPSources is NOT an array. Check your defaults. You should now use SOGoUserSources nonetheless."];
}
o = [ud arrayForKey: @"SOGoUserSources"];
if (o)
{
if ([o isKindOfClass: [NSArray class]])
[sources addObjectsFromArray: o];
else
[self errorWithFormat: @"SOGoUserSources is NOT an array. Check your defaults."];
}
if ([sources count])
{
max = [sources count];
for (count = 0; count < max; count++)
[self _registerSource: [udSources objectAtIndex: count]];
}
else
[self errorWithFormat: @"SOGoLDAPSources is not defined or it is not an array. Check your defaults."];
[self _registerSource: [sources objectAtIndex: count]];
}
}
- (id) init
@ -152,9 +183,9 @@ static NSLock *lock = nil;
{
ud = [NSUserDefaults standardUserDefaults];
sources = nil;
sourcesMetadata = nil;
[self _prepareLDAPSourcesWithDefaults: ud];
_sources = nil;
_sourcesMetadata = nil;
[self _prepareSourcesWithDefaults: ud];
}
return self;
@ -162,14 +193,14 @@ static NSLock *lock = nil;
- (void) dealloc
{
[sources release];
[sourcesMetadata release];
[_sources release];
[_sourcesMetadata release];
[super dealloc];
}
- (NSArray *) sourceIDs
{
return [sources allKeys];
return [_sources allKeys];
}
- (NSArray *) _sourcesOfType: (NSString *) sourceType
@ -180,10 +211,10 @@ static NSLock *lock = nil;
NSNumber *canAuthenticate;
sourceIDs = [NSMutableArray array];
allIDs = [[sources allKeys] objectEnumerator];
allIDs = [[_sources allKeys] objectEnumerator];
while ((currentID = [allIDs nextObject]))
{
canAuthenticate = [[sourcesMetadata objectForKey: currentID]
canAuthenticate = [[_sourcesMetadata objectForKey: currentID]
objectForKey: sourceType];
if ([canAuthenticate boolValue])
[sourceIDs addObject: currentID];
@ -194,7 +225,7 @@ static NSLock *lock = nil;
- (NSDictionary *) metadataForSourceID: (NSString *) sourceID
{
return [sourcesMetadata objectForKey: sourceID];
return [_sourcesMetadata objectForKey: sourceID];
}
- (NSArray *) authenticationSourceIDs
@ -209,14 +240,14 @@ static NSLock *lock = nil;
- (LDAPSource *) sourceWithID: (NSString *) sourceID
{
return [sources objectForKey: sourceID];
return [_sources objectForKey: sourceID];
}
- (NSString *) displayNameForSourceWithID: (NSString *) sourceID
{
NSDictionary *metadata;
metadata = [sourcesMetadata objectForKey: sourceID];
metadata = [_sourcesMetadata objectForKey: sourceID];
return [metadata objectForKey: @"displayName"];
}
@ -267,20 +298,20 @@ static NSLock *lock = nil;
return [contactInfos objectForKey: @"c_uid"];
}
- (BOOL) _ldapCheckLogin: (NSString *) login
andPassword: (NSString *) password
- (BOOL) _sourceCheckLogin: (NSString *) login
andPassword: (NSString *) password
{
BOOL checkOK;
LDAPSource *ldapSource;
id<SOGoSource> ldapSource;
NSEnumerator *authIDs;
NSString *currentID;
BOOL checkOK;
checkOK = NO;
authIDs = [[self authenticationSourceIDs] objectEnumerator];
while (!checkOK && (currentID = [authIDs nextObject]))
{
ldapSource = [sources objectForKey: currentID];
ldapSource = [_sources objectForKey: currentID];
checkOK = [ldapSource checkLogin: login andPassword: password];
}
@ -302,7 +333,7 @@ static NSLock *lock = nil;
dictPassword = [currentUser objectForKey: @"password"];
if (currentUser && dictPassword)
checkOK = ([dictPassword isEqualToString: password]);
else if ([self _ldapCheckLogin: login andPassword: password])
else if ([self _sourceCheckLogin: login andPassword: password])
{
checkOK = YES;
if (!currentUser)
@ -329,8 +360,8 @@ static NSLock *lock = nil;
- (void) _fillContactMailRecords: (NSMutableDictionary *) contact
{
NSMutableArray *emails;
NSString *uid, *systemEmail;
NSMutableArray *emails;
emails = [contact objectForKey: @"emails"];
uid = [contact objectForKey: @"c_uid"];
@ -367,7 +398,7 @@ static NSLock *lock = nil;
ldapSources = [[self authenticationSourceIDs] objectEnumerator];
while ((sourceID = [ldapSources nextObject]))
{
currentSource = [sources objectForKey: sourceID];
currentSource = [_sources objectForKey: sourceID];
userEntry = [currentSource lookupContactEntryWithUIDorEmail: uid];
if (userEntry)
{
@ -522,7 +553,7 @@ static NSLock *lock = nil;
email = [userEntry objectForKey: @"mail"];
if (email && ![emails containsObject: email])
[emails addObject: email];
email = [userEntry objectForKey: @"mozillaSecondEmail"];
email = [userEntry objectForKey: @"mozillasecondemail"];
if (email && ![emails containsObject: email])
[emails addObject: email];
email = [userEntry objectForKey: @"xmozillasecondemail"];
@ -551,15 +582,15 @@ static NSLock *lock = nil;
matching: (NSString *) filter
{
NSMutableArray *contacts;
NSEnumerator *ldapSources;
NSEnumerator *sources;
NSString *sourceID;
LDAPSource *currentSource;
id currentSource;
contacts = [NSMutableArray array];
ldapSources = [sourcesList objectEnumerator];
while ((sourceID = [ldapSources nextObject]))
sources = [sourcesList objectEnumerator];
while ((sourceID = [sources nextObject]))
{
currentSource = [sources objectForKey: sourceID];
currentSource = [_sources objectForKey: sourceID];
[contacts addObjectsFromArray:
[currentSource fetchContactsMatching: filter]];
}
@ -586,7 +617,7 @@ static NSLock *lock = nil;
LDAPSource *currentSource;
login = nil;
ldapSources = [[sources allValues] objectEnumerator];
ldapSources = [[_sources allValues] objectEnumerator];
while ((currentSource = [ldapSources nextObject]))
{
if ([theDN hasSuffix: [currentSource baseDN]])

View File

@ -1,6 +1,6 @@
/* SOGoWebAuthenticator.m - this file is part of SOGo
*
* Copyright (C) 2007 Inverse inc.
* Copyright (C) 2007-2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@ -37,7 +37,7 @@
#import <UI/MainUI/SOGoRootPage.h>
#import "LDAPUserManager.h"
#import "SOGoUserManager.h"
#import "SOGoPermissions.h"
#import "SOGoUser.h"
@ -88,11 +88,11 @@
password: (NSString *) _pwd
{
BOOL accept;
LDAPUserManager *um;
SOGoUserManager *um;
if ([authMethod isEqualToString: @"LDAP"])
{
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
accept = [um checkLogin: _login andPassword: _pwd];
}
else

View File

@ -0,0 +1,45 @@
/* SQLSource.h - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
*
* Author: Ludovic Marcotte <lmarcotte@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef SQLSOURCE_H
#define SQLSOURCE_H
#import <Foundation/NSObject.h>
#include "SOGoSource.h"
@class NSArray;
@class NSDictionary;
@class NSString;
@class NSURL;
@interface SQLSource : NSObject <SOGoSource>
{
NSString *_sourceID;
NSArray *_mailFields;
NSString *_userPasswordAlgorithm;
NSURL *_viewURL;
}
@end
#endif /* SQLSOURCE_H */

View File

@ -0,0 +1,329 @@
/* SQLSource.h - this file is part of SOGo
*
* Copyright (C) 2009 Inverse inc.
*
* Author: Ludovic Marcotte <lmarcotte@inverse.ca>
*
* This file is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This file is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#import <Foundation/NSArray.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSString.h>
#import <Foundation/NSValue.h>
#import <Foundation/NSURL.h>
#import <NGExtensions/NSObject+Logs.h>
#import <GDLContentStore/GCSChannelManager.h>
#import <GDLContentStore/NSURL+GCS.h>
#import <GDLAccess/EOAdaptorChannel.h>
#import <GDLAccess/EOAdaptorContext.h>
#import <GDLAccess/EOAttribute.h>
#include <openssl/evp.h>
#include <openssl/md5.h>
#include "SQLSource.h"
/**
* The view MUST contain the following columns:
*
* c_uid - will be used for authentication - it's a username or username@domain.tld)
* c_name - which can be identical to c_uid - will be used to uniquely identify entries)
* c_password - password of the user, plain-text or md5 encoded for now
* c_cn - the user's common name
* mail - hte user's mail address
*
* Other columns can be defined - see LDAPSource.m for the complete list.
*
*
* A SQL source can be defined like this:
*
* {
* id = zot;
* type = sql;
* viewURL = "http://sogo:sogo@127.0.0.1:5432/sogo/sogo_view";
* canAuthenticate = YES;
* isAddressBook = YES;
* userPasswordAlgorithm = md5;
* }
*
*/
@implementation SQLSource
+ (id) sourceFromUDSource: (NSDictionary *) udSource
{
return [[[self alloc] initFromUDSource: udSource] autorelease];
}
- (id) init
{
if ((self = [super init]))
{
_sourceID = nil;
_mailFields = nil;
_userPasswordAlgorithm = nil;
_viewURL = nil;
}
return self;
}
- (void) dealloc
{
[_sourceID release];
[_mailFields release];
[_userPasswordAlgorithm release];
[_viewURL release];
[super dealloc];
}
- (id) initFromUDSource: (NSDictionary *) udSource
{
self = [self init];
ASSIGN(_sourceID, [udSource objectForKey: @"id"]);
ASSIGN(_mailFields, [udSource objectForKey: @"MailFieldNames"]);
ASSIGN(_userPasswordAlgorithm, [udSource objectForKey: @"userPasswordAlgorithm"]);
if (!_userPasswordAlgorithm)
_userPasswordAlgorithm = @"none";
if ([udSource objectForKey: @"viewURL"])
_viewURL = [[NSURL alloc] initWithString: [udSource objectForKey: @"viewURL"]];
if (!_viewURL)
{
[self autorelease];
return nil;
}
return self;
}
- (BOOL) _isPassword: (NSString *) plainPassword
equalTo: (NSString *) encryptedPassword
{
if ([_userPasswordAlgorithm caseInsensitiveCompare: @"none"] == NSOrderedSame)
{
return [plainPassword isEqualToString: encryptedPassword];
}
else if ([_userPasswordAlgorithm caseInsensitiveCompare: @"md5"] == NSOrderedSame)
{
NSString *s;
unsigned char md[MD5_DIGEST_LENGTH];
char buf[80];
int i;
memset(md, 0, MD5_DIGEST_LENGTH);
memset(buf, 0, 80);
EVP_Digest([plainPassword UTF8String], strlen([plainPassword UTF8String]), md, NULL, EVP_md5(), NULL);
for (i = 0; i < MD5_DIGEST_LENGTH; i++)
sprintf(&(buf[i*2]), "%02x", md[i]);
s = [NSString stringWithUTF8String: buf];
return [s isEqualToString: encryptedPassword];
}
[self errorWithFormat: @"Unsupported user-password algorithm: %@", _userPasswordAlgorithm];
return NO;
}
- (BOOL) checkLogin: (NSString *) login
andPassword: (NSString *) password
{
EOAdaptorChannel *channel;
GCSChannelManager *cm;
NSException *ex;
NSString *sql;
cm = [GCSChannelManager defaultChannelManager];
channel = [cm acquireOpenChannelForURL: _viewURL];
sql = [NSString stringWithFormat: (@"SELECT c_password"
@" FROM %@"
@" WHERE c_uid = '%@'"),
[_viewURL gcsTableName], login];
ex = [channel evaluateExpressionX: sql];
if (!ex)
{
NSDictionary *row;
NSArray *attrs;
NSString *value;
attrs = [channel describeResults: NO];
row = [channel fetchAttributes: attrs withZone: NULL];
value = [row objectForKey: @"c_password"];
return [self _isPassword: password equalTo: value];
}
else
[self errorWithFormat: @"could not run SQL '%@': %@", sql, ex];
return NO;
}
- (NSDictionary *) _lookupContactEntry: (NSString *) theID
considerEmail: (BOOL) b
{
EOAdaptorChannel *channel;
GCSChannelManager *cm;
NSException *ex;
NSString *sql;
cm = [GCSChannelManager defaultChannelManager];
channel = [cm acquireOpenChannelForURL: _viewURL];
if (!b)
sql = [NSString stringWithFormat: (@"SELECT *"
@" FROM %@"
@" WHERE c_uid = '%@'"),
[_viewURL gcsTableName], theID];
else
sql = [NSString stringWithFormat: (@"SELECT *"
@" FROM %@"
@" WHERE c_uid = '%@' OR"
@" LOWER(mail) = '%@'"),
[_viewURL gcsTableName], theID, [theID lowercaseString]];
ex = [channel evaluateExpressionX: sql];
if (!ex)
{
NSMutableDictionary *d;
d = [NSMutableDictionary dictionaryWithDictionary: [channel fetchAttributes:
[channel describeResults: NO]
withZone: NULL]];
// We have to do this here since we do not manage modules constraints right
// now over a SQL backend.
[d setObject: [NSNumber numberWithBool: YES] forKey: @"CalendarAccess"];
[d setObject: [NSNumber numberWithBool: YES] forKey: @"MailAccess"];
return d;
}
else
[self errorWithFormat: @"could not run SQL '%@': %@", sql, ex];
return nil;
}
- (NSDictionary *) lookupContactEntry: (NSString *) theID
{
return [self _lookupContactEntry: theID considerEmail: NO];
}
- (NSDictionary *) lookupContactEntryWithUIDorEmail: (NSString *) entryID
{
return [self _lookupContactEntry: entryID considerEmail: YES];
}
- (NSArray *) allEntryIDs
{
EOAdaptorChannel *channel;
NSMutableArray *results;
GCSChannelManager *cm;
NSException *ex;
NSString *sql;
results = [NSMutableArray array];
cm = [GCSChannelManager defaultChannelManager];
channel = [cm acquireOpenChannelForURL: _viewURL];
sql = [NSString stringWithFormat: (@"SELECT c_uid"
@" FROM %@"),
[_viewURL gcsTableName]];
ex = [channel evaluateExpressionX: sql];
if (!ex)
{
NSDictionary *row;
NSArray *attrs;
NSString *value;
attrs = [channel describeResults: NO];
while ((row = [channel fetchAttributes: attrs withZone: NULL]))
{
value = [row objectForKey: @"c_uid"];
if (value)
[results addObject: value];
}
}
else
[self errorWithFormat: @"could not run SQL '%@': %@", sql, ex];
return results;
}
- (NSArray *) fetchContactsMatching: (NSString *) filter
{
EOAdaptorChannel *channel;
NSMutableArray *results;
GCSChannelManager *cm;
NSException *ex;
NSString *sql;
results = [NSMutableArray array];
cm = [GCSChannelManager defaultChannelManager];
channel = [cm acquireOpenChannelForURL: _viewURL];
sql = [NSString stringWithFormat: (@"SELECT *"
@" FROM %@"
@" WHERE LOWER(c_cn) LIKE '%%%@%%' OR LOWER(mail) LIKE '%%%@%%'"),
[_viewURL gcsTableName], [filter lowercaseString], [filter lowercaseString]];
ex = [channel evaluateExpressionX: sql];
if (!ex)
{
NSDictionary *row;
NSArray *attrs;
attrs = [channel describeResults: NO];
while ((row = [channel fetchAttributes: attrs withZone: NULL]))
{
[results addObject: row];
}
}
else
[self errorWithFormat: @"could not run SQL '%@': %@", sql, ex];
return results;
}
- (NSString *) sourceID
{
return _sourceID;
}
@end

View File

@ -32,7 +32,7 @@
#import <GDLContentStore/GCSFolder.h>
#import <GDLContentStore/NSURL+GCS.h>
#import <SOGo/LDAPUserManager.h>
#import <SOGo/SOGoUserManager.h>
#import <SOGo/LDAPSource.h>
#import <SOGo/NSArray+Utilities.h>
#import <SOGo/NSDictionary+Utilities.h>
@ -118,13 +118,13 @@
- (BOOL) fetchUserIDs: (NSArray *) users
{
LDAPUserManager *lm;
SOGoUserManager *lm;
NSDictionary *infos;
NSString *user;
id allUsers;
int count, max;
lm = [LDAPUserManager sharedUserManager];
lm = [SOGoUserManager sharedUserManager];
max = [users count];
user = [users objectAtIndex: 0];
if (max == 1 && [user isEqualToString: @"ALL"])
@ -302,11 +302,11 @@
NSEnumerator *ldapSources;
NSString *sourceID;
LDAPSource *currentSource;
LDAPUserManager *lm;
SOGoUserManager *lm;
NSDictionary *userEntry;
BOOL done;
lm = [LDAPUserManager sharedUserManager];
lm = [SOGoUserManager sharedUserManager];
done = NO;
ldapSources = [[lm authenticationSourceIDs] objectEnumerator];

View File

@ -33,7 +33,7 @@
#import <GDLContentStore/GCSFolder.h>
#import <GDLContentStore/NSURL+GCS.h>
#import <SOGo/LDAPUserManager.h>
#import <SOGo/SOGoUserManager.h>
#import <SOGo/NSArray+Utilities.h>
#import <SOGo/SOGoUser.h>
#import <SOGo/SOGoUserDefaults.h>
@ -130,10 +130,10 @@
- (BOOL) fetchUserID: (NSString *) identifier
{
BOOL rc;
LDAPUserManager *lm;
SOGoUserManager *lm;
NSDictionary *infos;
lm = [LDAPUserManager sharedUserManager];
lm = [SOGoUserManager sharedUserManager];
infos = [lm contactInfosForUserWithUIDorEmail: identifier];
ASSIGN (userID, [infos objectForKey: @"c_uid"]);
if (userID)

View File

@ -1,6 +1,6 @@
/* UIxAclEditor.m - this file is part of SOGo
*
* Copyright (C) 2006, 2007 Inverse inc.
* Copyright (C) 2006-2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@ -29,7 +29,7 @@
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/SoSecurityManager.h>
#import <NGCards/iCalPerson.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoUserManager.h>
#import <SoObjects/SOGo/SOGoContentObject.h>
#import <SoObjects/SOGo/SOGoPermissions.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
@ -74,10 +74,10 @@
- (NSString *) _displayNameForUID: (NSString *) uid
{
LDAPUserManager *um;
SOGoUserManager *um;
NSString *s;
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
s = [uid hasPrefix: @"@"] ? [uid substringFromIndex: 1] : uid;
return [NSString stringWithFormat: @"%@ <%@>",

View File

@ -35,7 +35,7 @@
#import <NGObjWeb/SoClassSecurityInfo.h>
#import <NGObjWeb/NSException+HTTP.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoUserManager.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
#import <SoObjects/SOGo/SOGoContentObject.h>
#import <SoObjects/SOGo/SOGoGCSFolder.h>
@ -61,7 +61,7 @@
baseFolder = [[clientObject container] nameInContainer];
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
ud = [activeUser userSettings];
moduleSettings = [ud objectForKey: baseFolder];
if (!moduleSettings)

View File

@ -27,7 +27,6 @@
#import <NGObjWeb/WOContext+SoObjects.h>
#import <NGObjWeb/WORequest.h>
#import <NGObjWeb/WOResponse.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoObject.h>
#import <SoObjects/SOGo/SOGoPermissions.h>

View File

@ -1,6 +1,6 @@
/* UIxUserRightsEditor.m - this file is part of SOGo
*
* Copyright (C) 2007 Inverse inc.
* Copyright (C) 2007-2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@ -24,7 +24,7 @@
#import <NGObjWeb/WOApplication.h>
#import <NGObjWeb/WOResponse.h>
#import <NGObjWeb/WORequest.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoUserManager.h>
#import <SoObjects/SOGo/SOGoPermissions.h>
#import <SoObjects/SOGo/SOGoObject.h>
#import <SoObjects/SOGo/SOGoGroup.h>
@ -81,9 +81,9 @@ static BOOL sendACLAdvisories = NO;
- (NSString *) userDisplayName
{
LDAPUserManager *um;
SOGoUserManager *um;
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
return [NSString stringWithFormat: @"%@ <%@>",
[um getCNForUID: uid],
@ -94,7 +94,7 @@ static BOOL sendACLAdvisories = NO;
{
BOOL response;
NSString *newUID;
LDAPUserManager *um;
SOGoUserManager *um;
SOGoObject *clientObject;
SOGoGroup *group;
@ -106,7 +106,7 @@ static BOOL sendACLAdvisories = NO;
if (!defaultUserID)
ASSIGN (defaultUserID, [[self clientObject] defaultUserID]);
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
if ([newUID isEqualToString: defaultUserID]
|| [[um getEmailForUID: newUID] length] > 0)
{

View File

@ -1,6 +1,6 @@
/* UIxContactFoldersView.m - this file is part of SOGo
*
* Copyright (C) 2006-2008 Inverse inc.
* Copyright (C) 2006-2009 Inverse inc.
*
* Author: Wolfgang Sourdeau <wsourdeau@inverse.ca>
*
@ -38,7 +38,7 @@
#import <GDLContentStore/GCSFolder.h>
#import <GDLContentStore/GCSFolderManager.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoUserManager.h>
#import <SoObjects/SOGo/SOGoPermissions.h>
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
@ -47,7 +47,7 @@
#import <SoObjects/Contacts/SOGoContactFolders.h>
#import <SoObjects/Contacts/SOGoContactFolder.h>
#import <SoObjects/Contacts/SOGoContactGCSFolder.h>
#import <SoObjects/Contacts/SOGoContactLDAPFolder.h>
#import <SoObjects/Contacts/SOGoContactSourceFolder.h>
#import "UIxContactFoldersView.h"
@ -220,7 +220,7 @@
for (i = 0; i < [folders count]; i++)
{
folder = [folders objectAtIndex: i];
if ([folder isKindOfClass: [SOGoContactLDAPFolder class]])
if ([folder isKindOfClass: [SOGoContactSourceFolder class]])
[sortedFolders insertObject: folder atIndex: 0];
else
[sortedFolders addObject: folder];
@ -281,12 +281,12 @@
NSArray *contacts;
NSString *searchText;
id <WOActionResults> result;
LDAPUserManager *um;
SOGoUserManager *um;
searchText = [self queryParameterForKey: @"search"];
if ([searchText length] > 0)
{
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
contacts
= [self _responseForResults: [um fetchContactsMatching: searchText]];
data = [NSDictionary dictionaryWithObjectsAndKeys: searchText, @"searchText",
@ -420,7 +420,7 @@
- (NSString *) currentContactFolderClass
{
return ([currentFolder isKindOfClass: [SOGoContactLDAPFolder class]]? @"remote" : @"local");
return ([currentFolder isKindOfClass: [SOGoContactSourceFolder class]]? @"remote" : @"local");
}
- (WOResponse *) saveDragHandleStateAction

View File

@ -120,7 +120,7 @@
};
};
SOGoContactLDAPFolder = {
SOGoContactSourceFolder = {
slots = {
toolbar = {
protectedBy = "View";

View File

@ -36,7 +36,7 @@
#import <NGExtensions/NSObject+Logs.h>
#import <Appointments/SOGoFreeBusyObject.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoUserManager.h>
#import <SoObjects/SOGo/SOGoWebAuthenticator.h>
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/SOGoUserFolder.h>
@ -334,6 +334,8 @@ static NSString *LDAPContactInfoAttribute = nil;
{
contact = [allUsers objectAtIndex: i];
uid = [contact objectForKey: @"c_uid"];
// We do NOT return the current authenticated user.
if (![uid isEqualToString: login])
{
if ([LDAPContactInfoAttribute length])
@ -360,9 +362,9 @@ static NSString *LDAPContactInfoAttribute = nil;
{
NSString *contact;
id <WOActionResults> result;
LDAPUserManager *um;
SOGoUserManager *um;
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
contact = [self queryParameterForKey: @"search"];
if ([contact length])
{

View File

@ -31,7 +31,7 @@
#import <SoObjects/SOGo/SOGoMailer.h>
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/SOGoObject.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoUserManager.h>
#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
#import <SoObjects/SOGo/NSString+Utilities.h>
@ -203,7 +203,7 @@
fullMail = [NSString stringWithFormat: @"%@ <%@>",
[identity objectForKey: @"fullName"], from];
recipient = [[LDAPUserManager sharedUserManager]
recipient = [[SOGoUserManager sharedUserManager]
getFullEmailForUID: recipientUID];
headerMap = [NGMutableHashMap hashMapWithCapacity: 5];

View File

@ -31,7 +31,7 @@
#import <SoObjects/SOGo/SOGoMailer.h>
#import <SoObjects/SOGo/SOGoUser.h>
#import <SoObjects/SOGo/SOGoObject.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoUserManager.h>
#import <SoObjects/SOGo/NSCalendarDate+SOGo.h>
#import <SoObjects/SOGo/NSString+Utilities.h>
@ -182,7 +182,7 @@
fullMail = [NSString stringWithFormat: @"%@ <%@>",
[identity objectForKey: @"fullName"], from];
recipient = [[LDAPUserManager sharedUserManager]
recipient = [[SOGoUserManager sharedUserManager]
getFullEmailForUID: recipientUID];
headerMap = [NGMutableHashMap hashMapWithCapacity: 5];

View File

@ -55,7 +55,7 @@
#import <SoObjects/Appointments/SOGoAppointmentOccurence.h>
#import <SoObjects/Appointments/SOGoTaskObject.h>
#import <SoObjects/SOGo/iCalEntityObject+Utilities.h>
#import <SoObjects/SOGo/LDAPUserManager.h>
#import <SoObjects/SOGo/SOGoUserManager.h>
#import <SoObjects/SOGo/NSArray+Utilities.h>
#import <SoObjects/SOGo/NSDictionary+Utilities.h>
#import <SoObjects/SOGo/NSScanner+BSJSONAdditions.h>
@ -243,10 +243,10 @@ iRANGE(2);
NSMutableDictionary *currentAttendeeData;
iCalPerson *currentAttendee;
NSString *uid;
LDAPUserManager *um;
SOGoUserManager *um;
jsonAttendees = [NSMutableDictionary new];
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
attendees = [[component attendees] objectEnumerator];
while ((currentAttendee = [attendees nextObject]))
@ -527,7 +527,7 @@ iRANGE(2);
{
// iCalRecurrenceRule *rrule;
SOGoObject *co;
LDAPUserManager *um;
SOGoUserManager *um;
NSString *owner, *ownerEmail;
if (!component)
@ -560,7 +560,7 @@ iRANGE(2);
componentCalendar = [componentCalendar container];
[componentCalendar retain];
um = [LDAPUserManager sharedUserManager];
um = [SOGoUserManager sharedUserManager];
owner = [componentCalendar ownerInContext: context];
ownerEmail = [um getEmailForUID: owner];
ASSIGN (ownerAsAttendee, [component findParticipantWithEmail: (id)ownerEmail]);